Language support: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Mad-max
mNo edit summary
(30 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{mininav|[[Development]]{{l2|[[Add-on development]]}}}}
{{cleanup}}
{{cleanup}}
{{outdated}}
The following page explains exactly how to add a new language translation to Kodi, and how to maintain/update an existing language file in Kodi. English (United Kingdom) is the default language of Kodi so it is the English language in the Git repository that is always up-to-date, please always base your translations of the latest English language file from Git. The latest language files for Kodi can be found and downloaded [https://github.com/xbmc/xbmc/tree/master/language here (link)].
{{XBMC wiki toc}}
The following page explains exactly how to add a new language translation to XBMC, and how to maintain/update an existing language file in XBMC. English is the default language of XBMC so it is the English language in the Git repository that is always up-to-date, please always base your translations of the latest English language file from Git. The latest language files for XBMC can be found and downloaded [https://github.com/xbmc/xbmc/tree/master/language here (link)].


===The Language Folders===
=== Language add-ons ===
The "language" folder in XBMC contains one directory for each language. Each language folder contains two files, langinfo.xml and strings.xml. There are also a language folder in skin/PM3.HD that needs translation as well.
By default Kodi only includes one language which is English (united Kingdom). All other languages have been moved to individual language add-ons which are available form our Kodi repository for download and install. They are auto update by Team Kodi once in a while and pushed to our repository from which you will receive these updates depending on what language(s) you have installed.


===What is langinfo.xml===
=== What is langinfo.xml ===
The langinfo.xml file contains language and region specific localization settings used internally by XBMC. Basically it is the default [http://en.wikipedia.org/wiki/Code_page code page] XBMC uses for this language file.
The langinfo.xml file contains language and region specific localization settings used internally by Kodi. Basically it is the default [http://en.wikipedia.org/wiki/Code_page code page] Kodi uses for this language file.


====Layout of a langinfo.xml file====
==== Layout of a langinfo.xml file ====
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
   <language>
   <language>
     <charsets>
     <charsets>
Line 24: Line 24:
     </dvd>
     </dvd>
   </language>
   </language>
</source>
</syntaxhighlight>


The <charset> section:
The <charset> section:
<gui>: Specifies the character encoding of everything within XBMC that is not unicode. E.g. id3 tags with none unicode encoding.
<gui>: Specifies the character encoding of everything within Kodi that is not unicode. E.g. id3 tags with none unicode encoding.
<subtitle>: Default character encoding of subtitles when using a TTF (True-Type-Font).
<subtitle>: Default character encoding of subtitles when using a TTF (True-Type-Font).
Choose one encoding for each in the list below. The values may differ if you like.
Choose one encoding for each in the list below. The values may differ if you like.
Line 34: Line 34:
Defines the default languages for DVD-Video menu, audio and subtitle language for the [[DVDPlayer]]. Choose one for each entry out of the list of ISO-639 language abbreviations. If the DVD-Video you are playing does not support the language that you specified then it will default to English.
Defines the default languages for DVD-Video menu, audio and subtitle language for the [[DVDPlayer]]. Choose one for each entry out of the list of ISO-639 language abbreviations. If the DVD-Video you are playing does not support the language that you specified then it will default to English.


===What is strings.xml===
=== What is strings.po ===
This files contains all strings displayed in the user interface of XBMC.
This files contains all strings displayed in the user interface of Kodi.
 
 
==== Layout of the strings.po file ====
 


====Layout of the strings.xml file====
<syntaxhighlight lang="python" enclose="div">
<source lang="xml">
# Kodi Media Center language file
  <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
# Addon Name: Skin Widgets
  <strings>
# Addon id: service.skin.widgets
    <string><id>0</id><value>My Programs</value></string>
# Addon Provider: Martijn, phil65
    <string><id>1</id><value>My Pictures</value></string>
msgid ""
    <string><id>2</id><value>My Music</value></string>
msgstr ""
    <string><id>3</id><value>My Videos</value></string>
"Project-Id-Version: Kodi Addons\n"
    <string><id>4</id><value>TV Guide</value></string>
"Report-Msgid-Bugs-To: [email protected]\n"
    <string><id>5</id><value>Settings</value></string>
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
    .
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    .
"Last-Translator: Kodi Translation Team\n"
    .
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
  </strings>
"MIME-Version: 1.0\n"
</source>
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"


Each string is enclosed in a <string> tag. It contains a tag named <id> with a number xbmc uses to reference a string internally. The <value> tag is the string displayed by xbmc.
msgctxt "#32001"
msgid "Recommended"
msgstr ""
 
msgctxt "#32002"
msgid "Random Items"
msgstr ""
 
# empty string with id 32003
 
msgctxt "#32004"
msgid "Randomize time (minutes)"
msgstr ""
 
msgctxt "#32005"
msgid "Use season folders"
msgstr ""
 
</syntaxhighlight>
 
==== Layout of the language folders ====
 
Kodi loads the strings.po file depending on the set interface language. Should it find a matching language it will try to load that strings.po. If not available it will always fall back to English (United Kingdom).
For this to work you will need to place the strings.po in the correctly named folder depending on the language. These folders use "language-country" naming scheme.
<syntaxhighlight lang="python" enclose="div">
/resources/language/resource.language.en_gb/strings.po
/resources/language/resource.language.fr_fr/strings.po
/resources/language/resource.language.it_it/strings.po
</syntaxhighlight>
 
An extensive example list of used languages can be found here https://github.com/xbmc/xbmc/tree/master/addons/skin.estuary/language
 
==== Layout of the old strings.xml file ====
 
{{warning|1=Strings.xml support was completely removed from v19 Matrix. Addons should update and comply to the strings.po file from now on.}}
 
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <strings>
        <string id="32001">Recommended</string>
        <string id="32002">Random Items</string>
        <string id="32003">Only unplayed</string>
        <string id="32004">Randomize time (minutes)</string>
        <string id="32005">Use season folders</string>
        <string id="32006">Use timer</string>
        <string id="32007">After database update</string>
        <string id="32008">Update method</string>
        <string id="32009">Recent Items</string>
    </strings>
 
 
Each string is enclosed in a <string> tag. It contains a tag named id="32001" with a number Kodi uses to reference a string internally.




'''Hint: Multi-Line Text-Values'''<br />
'''Hint: Multi-Line Text-Values'''<br />
If you want your text-values to span multiple lines, you can insert a new line character in your <value> tag.<br />
If you want your text-values to span multiple lines, you can insert a new line character [br] in your tag. Although we highly discourage this as it could cause skin problems as not all text boxes have enough room to display these.


For example:
For example:
<source lang="xml">
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <string><id>0</id><value>This will be on the first line
    <strings>
And this will be on the second line</value></string>
      <string id="32001"><value>This will be on the first line[br]And this will be on the second line</string>
</source>
    </strings>
 


The encoding attribute of the XML header sets the charset the file is encoded with. See List of charsets of possible values.
The encoding attribute of the XML header sets the charset the file is encoded with. See List of charsets of possible values.
If you don't know what charset your language uses please follow [http://www.science.co.il/Language/Locale-Codes.asp this link] to find out.
If you don't know what charset your language uses please follow [http://www.science.co.il/Language/Locale-Codes.asp this link] to find out.


==Adding a new language to XBMC==
=== String ID range ===
If you want to add a new language to xbmc, this is the easiest way to start:<br />
1. Copy the english language folder and name it like the language you want to add. The foldername must be in english<br />
2. Edit the langinfo.xml to the defaults of your language<br />
3. Edit the strings.xml and set the encoding attribute of the xml header to the appropriate of your language<br />
4. Translate the strings in strings.xml. For easier translation you can use our [[Information on Language Support#XBMC Translator|XBMC Translator]] program.<br />


It is also possible to set the encoding to UTF-8 but then make sure the file is also encoded to UTF-8.
Follow the specified string ID range
(A textfile can be encoded to UTF-8 with the Editor of Windows)


XBMC currently needs a workaround for Indic languages. It is necessary to use unicode fonts like arialuni.ttf and then rename them as arial.ttf so as to display properly. This font should be copied over to the font directory in xbmc folder. You also need to set the font in xbmc to "arial based" (Go to System -> Appearance -> Skin -> Fonts -> Arial Based).
* strings 30000 thru 30999 reserved for plugins and plugin settings
* strings 31000 thru 31999 reserved for skins
* strings 32000 thru 32999 reserved for scripts
* strings 33000 thru 33999 reserved for common strings used in add-ons


If you have everything ready you can upload your new language files as a patch (preferably the entire strings.xml file) to [http://trac.xbmc.org/newticket Trac] (our tracker-system)
== Adding a new language to Kodi ==


==Maintaining a language==
{{see|Translation System}}
The English language file ([https://github.com/xbmc/xbmc/blob/master/language/English/strings.xml]) is the master for all language files. From time to time the english language file changes. The file is updated with new strings or existing strings are replaced. You will have to keep track of the changes to the english language file and add them to your file.
 
== Maintaining a language ==
The English (UK) language file ([https://github.com/xbmc/xbmc/blob/master/addons/resource.language.en_gb/resources/strings.po]) is the master for all language files. From time to time the English (UK) language file changes. This will be automatically update from time to time to Transifex translation pages.


How to keep track of changes:
How to keep track of changes:
From time to time check the [http://xbmc.svn.sourceforge.net/viewvc/xbmc/branches/linuxport/XBMC/language/English/ xbmc Git repository] for updates to the english language file. (the link takes you directly to the english language folder.)
Use our [[Translation System]]


After you are done you can upload your edited language file as a patch (preferably the entire strings.xml file) to [http://trac.xbmc.org/newticket/ Trac] (our tracker-system)
== Related articles in the Kodi online manual ==
 
==Related articles in the XBMC online manual==
* [[List of Supported Charsets]]
* [[List of Supported Charsets]]
* [[List of language codes (ISO-639:1988)]]
* [[List of language codes (ISO-639:1988)]]




==[[XBMC Translator]]==
== Notes for developers ==
The XBMC Translator tool can be used to easily translate each strings contained in the english language file to other languages.<br />
Kodi uses UTF-8 as internal character encoding. Please make sure if you add new features to Kodi which depend on external data to convert these to UTF-8 if they aren't already. Use the languagefile from branches/linuxport, since we merge that file into trunk.
<br />
You may also use the translator on Linux (using wine), see this [[Translator on Linux|guide]].<br />
On the following link you can find detailed information on using the '''[[XBMC Translator]]'''.
 
==Notes for developers==
XBMC uses UTF-8 as internal character encoding. Please make sure if you add new features to xbmc which depend on external data to convert these to UTF-8 if they aren't already. Use the languagefile from branches/linuxport, since we merge that file into trunk.


[[Category:Manual]]
[[Category:Development]]
[[Category:Development]]
[[Category:Skin Development]]
[[Category:Skin development]]
[[Category:Languages|*]]
[[Category:Languages|*]]

Revision as of 21:47, 28 May 2019

Home icon grey.png   ▶ Development
▶ Add-on development
▶ Language support
Cleanup.png This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions.


The following page explains exactly how to add a new language translation to Kodi, and how to maintain/update an existing language file in Kodi. English (United Kingdom) is the default language of Kodi so it is the English language in the Git repository that is always up-to-date, please always base your translations of the latest English language file from Git. The latest language files for Kodi can be found and downloaded here (link).

Language add-ons

By default Kodi only includes one language which is English (united Kingdom). All other languages have been moved to individual language add-ons which are available form our Kodi repository for download and install. They are auto update by Team Kodi once in a while and pushed to our repository from which you will receive these updates depending on what language(s) you have installed.

What is langinfo.xml

The langinfo.xml file contains language and region specific localization settings used internally by Kodi. Basically it is the default code page Kodi uses for this language file.

Layout of a langinfo.xml file

  <language>
    <charsets>
      <gui>GB2312</gui>
      <subtitle>GB2312</subtitle>
    </charsets>
  
    <dvd>
      <menu>cn</menu>
      <audio>cn</audio>
      <subtitle>cn</subtitle>
    </dvd>
  </language>

The <charset> section: <gui>: Specifies the character encoding of everything within Kodi that is not unicode. E.g. id3 tags with none unicode encoding. <subtitle>: Default character encoding of subtitles when using a TTF (True-Type-Font). Choose one encoding for each in the list below. The values may differ if you like.
The <dvd> section: Defines the default languages for DVD-Video menu, audio and subtitle language for the DVDPlayer. Choose one for each entry out of the list of ISO-639 language abbreviations. If the DVD-Video you are playing does not support the language that you specified then it will default to English.

What is strings.po

This files contains all strings displayed in the user interface of Kodi.


Layout of the strings.po file

# Kodi Media Center language file
# Addon Name: Skin Widgets
# Addon id: service.skin.widgets
# Addon Provider: Martijn, phil65
msgid ""
msgstr ""
"Project-Id-Version: Kodi Addons\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Kodi 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 "#32001"
msgid "Recommended"
msgstr ""

msgctxt "#32002"
msgid "Random Items"
msgstr ""

# empty string with id 32003

msgctxt "#32004"
msgid "Randomize time (minutes)"
msgstr ""

msgctxt "#32005"
msgid "Use season folders"
msgstr ""

Layout of the language folders

Kodi loads the strings.po file depending on the set interface language. Should it find a matching language it will try to load that strings.po. If not available it will always fall back to English (United Kingdom). For this to work you will need to place the strings.po in the correctly named folder depending on the language. These folders use "language-country" naming scheme.

/resources/language/resource.language.en_gb/strings.po
/resources/language/resource.language.fr_fr/strings.po
/resources/language/resource.language.it_it/strings.po

An extensive example list of used languages can be found here https://github.com/xbmc/xbmc/tree/master/addons/skin.estuary/language

Layout of the old strings.xml file

Stop hand.png Strings.xml support was completely removed from v19 Matrix. Addons should update and comply to the strings.po file from now on.


   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <strings>
       <string id="32001">Recommended</string>
       <string id="32002">Random Items</string>
       <string id="32003">Only unplayed</string>
       <string id="32004">Randomize time (minutes)</string>
       <string id="32005">Use season folders</string>
       <string id="32006">Use timer</string>
       <string id="32007">After database update</string>
       <string id="32008">Update method</string>
       <string id="32009">Recent Items</string>
   </strings>


Each string is enclosed in a <string> tag. It contains a tag named id="32001" with a number Kodi uses to reference a string internally.


Hint: Multi-Line Text-Values
If you want your text-values to span multiple lines, you can insert a new line character [br] in your tag. Although we highly discourage this as it could cause skin problems as not all text boxes have enough room to display these.

For example:

   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <strings>
      <string id="32001"><value>This will be on the first line[br]And this will be on the second line</string>
   </strings>

The encoding attribute of the XML header sets the charset the file is encoded with. See List of charsets of possible values. If you don't know what charset your language uses please follow this link to find out.

String ID range

Follow the specified string ID range

  • strings 30000 thru 30999 reserved for plugins and plugin settings
  • strings 31000 thru 31999 reserved for skins
  • strings 32000 thru 32999 reserved for scripts
  • strings 33000 thru 33999 reserved for common strings used in add-ons

Adding a new language to Kodi

See: Translation System

Maintaining a language

The English (UK) language file ([1]) is the master for all language files. From time to time the English (UK) language file changes. This will be automatically update from time to time to Transifex translation pages.

How to keep track of changes: Use our Translation System

Related articles in the Kodi online manual


Notes for developers

Kodi uses UTF-8 as internal character encoding. Please make sure if you add new features to Kodi which depend on external data to convert these to UTF-8 if they aren't already. Use the languagefile from branches/linuxport, since we merge that file into trunk.