2010-06-21, 07:02
Hi dear developers!
I just wanted to write a script with localized labels, something like this:
scriptname/default.py
scriptname/resources/skins/Default/PAL/main.xml
scriptanme/resources/language/English/strings.xml
scriptname/resources/settings.xml
For some reason, first time I run this script I just get a label with "This:" when I expected to see "This: Hello world!".
However, if you access script settings (via context menu) and just click ok (as there is nothing to configure), next time you run the script you will get a label with "This: Hello world!".
If you happen to modify strings.xml (without restarting XBMC), let's say you change "Hello world!" with "XBMC!", and run the script again, you will get a label with "This: Hello world!".
Now, if you access the script settings (via context menu) again, and then run the script, you will now get "This: XBMC!".
So, in conclusion, Labels are not localized as I understand it should work.
I've been reading the online manual (wiki), searching on some others code (from xbmc-addon, etc), and I can't still figure out if this is a bug, a feature or just me doing something wrong.
Hope someone can guide me here!
Thanks a lot!
Hernan.-
I just wanted to write a script with localized labels, something like this:
scriptname/default.py
Code:
import xbmc,xbmcgui
import os
CWD = os.getcwd()
print CWD
__language__ = xbmc.Language(CWD).getLocalizedString
print xbmc.getLanguage()
ACTION_EXIT_SCRIPT = (9, 10)
class MainGUI(xbmcgui.WindowXML):
def __init__(self,*args,**kwargs):
xbmcgui.WindowXML.__init__(self)
def onInit(self):
pass
def onAction(self,action):
if (action in ACTION_EXIT_SCRIPT):
self.close()
def onClick(self,controlId):
pass
def onFocus(self,controlId):
pass
if __name__ == '__main__':
ui = MainGUI("main.xml",CWD)
ui.doModal()
del ui
scriptname/resources/skins/Default/PAL/main.xml
Code:
<window>
<controls>
<control type="label">
<description>XBMC PBX Addon</description>
<posx>150</posx>
<posy>40</posy>
<align>right</align>
<label>This: $LOCALIZE[32000]</label>
<font>special14</font>
</control>
</controls>
</window>
scriptanme/resources/language/English/strings.xml
Code:
<strings>
<string id="32000">Hello world!</string>
</strings>
scriptname/resources/settings.xml
Code:
<settings>
</settings>
For some reason, first time I run this script I just get a label with "This:" when I expected to see "This: Hello world!".
However, if you access script settings (via context menu) and just click ok (as there is nothing to configure), next time you run the script you will get a label with "This: Hello world!".
If you happen to modify strings.xml (without restarting XBMC), let's say you change "Hello world!" with "XBMC!", and run the script again, you will get a label with "This: Hello world!".
Now, if you access the script settings (via context menu) again, and then run the script, you will now get "This: XBMC!".
So, in conclusion, Labels are not localized as I understand it should work.
I've been reading the online manual (wiki), searching on some others code (from xbmc-addon, etc), and I can't still figure out if this is a bug, a feature or just me doing something wrong.
Hope someone can guide me here!
Thanks a lot!
Hernan.-