Label Parsing: Difference between revisions
>Martijn No edit summary |
|||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
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[] 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). | 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[] 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=== | === Example === | ||
< | <syntaxhighlight lang="xml" enclose="div"> | ||
<label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label> | <label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label> | ||
</ | </syntaxhighlight> | ||
== | <syntaxhighlight lang="xml" enclose="div"> | ||
<label>$LOCALIZE[31005]</label> | |||
</syntaxhighlight> | |||
# | <syntaxhighlight lang="xml" enclose="div"> | ||
# | <label>The following will be localized from an addons strings - $ADDON[addon.id.here 32001]</label> | ||
#If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block. | </syntaxhighlight> | ||
#If the Info manager returns a non-empty string from the infolabel, then | |||
#Any pieces of information outside of the $INFO blocks are rendered unchanged. | === How the parsing works === | ||
# Kodi runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.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 $COMMA fields 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: | So, in the above example, if nothing is playing then the label will print: | ||
A good example of a<br><br> | A good example of a<br /><br /> | ||
If a song is playing but it has no Title (ie MusicPlayer.Title | If a song is playing but it has no Title (ie MusicPlayer.Title returns an empty string) but does have an artist, it will return: | ||
A good example of a song artist: <Artist><br><br> | A good example of a song artist: <Artist><br /><br /> | ||
If a song is playing that has title and artist information, it will return: | 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> | A good example of a song title: <Title>, and a song artist: <Artist> | ||
Line 30: | Line 38: | ||
If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the builtin as a single parameter. | If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the builtin as a single parameter. | ||
==See also== | == See also == | ||
'''Development:''' | '''Development:''' | ||
* [[Add-on development]] | * [[Add-on development]] | ||
* [[Skinning]] | * [[Skinning]] | ||
[[Category:Skin | [[Category:Skin development]] |
Latest revision as of 00:49, 14 April 2022
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[] 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 addons strings - $ADDON[addon.id.here 32001]</label>
How the parsing works
- Kodi runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.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 $COMMA fields 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 (ie 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 builtin 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 builtin as a single parameter.
See also
Development: