Kodi Community Forum

Full Version: variables in $LOCALIZE[x] possible?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, is it possible to use a variable to pass a number to a $LOCALIZE[] label?

This is my variable:

Code:
<variable name="ViewtypeLabel">
    <value condition="Control.IsVisible(50)">315002</value>
    <value condition="Control.IsVisible(51)">315003</value>
    <value condition="Control.IsVisible(500)">315007</value>        
</variable>

This is my label:

Code:
<label>$LOCALIZE[$VAR[ViewtypeLabel]]</label>

From what I can tell, it's translating the var to 0, so instead of printing the string with id 315002, it's printing the string with id 0, which is "programs".
Try it like this instead.

Code:
<variable name="ViewtypeLabel">
    <value condition="Control.IsVisible(50)">$LOCALIZE[315002]</value>
    <value condition="Control.IsVisible(51)">$LOCALIZE[315003]</value>
    <value condition="Control.IsVisible(500)">$LOCALIZE[315007]</value>        
</variable>

Code:
<label>$VAR[ViewtypeLabel]</label>

Your localized string numbers seem a bit off too, kodi reserves 31000 to 31999 for skins.
language_support (wiki)
(2017-09-21, 00:29)Mr. V Wrote: [ -> ]Try it like this instead.

Code:
<variable name="ViewtypeLabel">
    <value condition="Control.IsVisible(50)">$LOCALIZE[315002]</value>
    <value condition="Control.IsVisible(51)">$LOCALIZE[315003]</value>
    <value condition="Control.IsVisible(500)">$LOCALIZE[315007]</value>        
</variable>

Code:
<label>$VAR[ViewtypeLabel]</label>

Your localized string numbers seem a bit off too, kodi reserves 31000 to 31999 for skins.
language_support (wiki)

Thanks, I had it like that initially and encountered severe slowdown when the label changed. Maybe it was because I'm using a reserved id. I'll try to change it and see if that helps,

Thanks!
FYI, you shouldn't need to do this to get the ViewtypeLabel anyway.

The correct way to do this is to set your viewtype labels in the list container for that view like so:
Code:
<control type="list" id="50">
    <viewtype label="$LOCALIZE[31502]">list</viewtype>

Replace $LOCALIZE[31502] part with the particular string id being used.

Then you can use the following to retrieve the label for the current view:
Code:
<label>$INFO[Container.Viewmode]</label>