I'm working on my python script as I would like to store the strings in the language file called strings.po
which it would allow me to change the texts in the label.
I want to know how do you write the code to input the strings in the label control using the id that I store in strings.po?
First, for XBMC Frodo and above its suggested to use the string-ID range 32000-32999 for script add-ons.
Also, its still no requirement to use the .po format for translations, you still are allowed to use the .xml format.
Anayway, here is an example for both:
YOUR_ADDON_DIR/resources/language/english/strings.po
# XBMC Media Center language file
# Addon Provider: Tristan Fischer (sphere@dersphere.de)
msgid ""
msgstr ""
"Project-Id-Version: XBMC Addons\n"
"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: XBMC Translation Team\n"
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgctxt "#32000"
msgid "Hello"
msgstr ""
YOUR_ADDON_DIR/resources/language/english/strings.xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="32000">Hello</string>
</strings>
Again, you don't need both, one of them is fine.
To use the "Hello"-string (with ID=32000) in the skin xml files:
<control type="label">
<description>My hello label</description>
<posx>0</posx>
<posy>0</posy>
<width>80</width>
<height>36</height>
<align>left</align>
<font>font12</font>
<textcolor>white</textcolor>
<visible>true</visible>
<label>$LOCALIZE[SCRIPT32000]</label>
</control>
And if you need the translation in python:
import xbmcaddon
addon = xbmcaddon.Addon()
my_hello_string = addon.getLocalizedString(32000)