Label Parsing
In label controls, fadelabel controls, built-in functions as well as in the LCD label definition files you can specify more than one piece of information to be displayed in a single line of text (or across multiple lines of text) by using the $INFO[], $ESCINFO[], $MAP[], $ESCMAP[] and $LOCALIZE[] keywords in a <label> tag. In addition to this, you can use the Label Formatting syntax to specify color and style information for the text, changeable within a single label.
Example
<label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label>
<label>$LOCALIZE[31005]</label>
<label>The following will be localized from an addon strings - $ADDON[addon.id.here 32001]</label>
How the parsing works
- Kodi runs through and replaces any
$LOCALIZE[number]blocks with the real string fromstrings.po. - Kodi then runs through and translates the
$INFO[infolabel,prefix,postfix]blocks from left to right. - If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block.
- If the Info manager returns a non-empty string from the infolabel, then Kodi prints the prefix string, then the returned infolabel information, then the postfix string. Note that any
$COMMAfields are replaced by real commas, and$$is replaced by$. - Any pieces of information outside of the
$INFO[]blocks are rendered unchanged.
So, in the above example, if nothing is playing then the label will print:
A good example of a
If a song is playing but it has no Title, i.e. MusicPlayer.Title returns an empty string, but does have an artist, it will return:
A good example of a song artist: <Artist>
If a song is playing that has title and artist information, it will return:
A good example of a song title: <Title>, and a song artist: <Artist>
$ESCINFO[] should be used when passing an infolabel to a built-in function, when this infolabel is likely to contain commas, ,, and/or quotes, ".
eg: PlayMedia($INFO[ListItem.Path]) might return: PlayMedia(/some/path/with_a_file_that_includes,a_comma.avi)
This will be read by the built-in function generator as PlayMedia called with 2 parameters: "/some/path/with_a_file_that_includes" and "a_comma.avi".
If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the built-in as a single parameter.
Map labels
Skins can use $MAP[] to translate the runtime value of an infolabel through a map defined in an includes file.
$MAP[MapName, infolabel]
Example:
<label>$MAP[DefaultCodecMap, ListItem.AudioCodec]</label>
If the map or key is not found, the raw infolabel value is returned unchanged.
Prefix and postfix arguments are supported:
<label>$MAP[DefaultCodecMap, ListItem.AudioCodec, (, )]</label>
The escaped form $ESCMAP[] is also supported and behaves like $ESCINFO[]. See Maps for defining maps in includes files.
See also
Development: