Language support: Difference between revisions
mNo edit summary |
|||
(13 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{cleanup}} | {{cleanup}} | ||
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 | 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.<br/> | ||
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.<br/> | |||
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/blob/master/addons/resource.language.en_gb/resources/strings.po here (link)]. | |||
=== Language add-ons === | === 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. | By default Kodi only includes one language which is English (united Kingdom). All other languages have been moved to [https://kodi.wiki/view/Category:Language_add-ons 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 Kodi. Basically it is the default [http://en.wikipedia.org/wiki/Code_page code page] Kodi 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. | ||
==== | The langinfo.xml file is part of a Kodi language add-on and cannot generally be modified directly by end-users. The file describes the presentation formatting for items like dates and times for each of the regional variations within that language. | ||
For example: some regions / cultures may prefer their dates to read '1 December 2002' whereas others may prefer 'December 1, 2002'. These preferences, among others, are defined in this file. | |||
==== langinfo.xml ==== | |||
<syntaxhighlight lang="xml" enclose="div"> | <syntaxhighlight lang="xml" enclose="div"> | ||
< | <language locale="[ISO 639-2 Code | ISO 639-1 Code]"> | ||
< | <regions> | ||
< | <region name="[Descriptive Name]" locale="[ISO-3166-1 Alpha-2 Code]"> | ||
< | <dateshort>[Date Format Codes]</dateshort> | ||
<datelong>[Date Format Codes]</datelong> | |||
<time symbolAM="[Symbol for 'ante meridiem']" symbolPM="[Symbol for 'post meridiem']">[Time Format Codes]</time> | |||
<tempunit>[One of {"f","k","c","re","ra","ro","de","n"}]</tempunit> | |||
< | <speedunit>[One of {"kmh","mpmin","mps","fth","ftm","fts","mph","kts","beaufort","inchs","yards","fpf"}]</speedunit> | ||
< | <timezone>GMT</timezone> | ||
< | <thousandsseparator groupingformat="\3">,</thousandsseparator> | ||
</ | <decimalseparator>.</decimalseparator> | ||
</language> | </region> | ||
</regions> | |||
</language> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
The < | The <language> 'locale' is identified using either the 3-character [https://en.wikipedia.org/wiki/ISO_639-2 ISO 639-2] code or the 2-character [https://en.wikipedia.org/wiki/ISO_639-1 ISO 639-1] code. For example, 'eng' or 'en' for 'English' or 'vie' or 'vi' for 'Vietnamese', or 'fil' for 'Filipino' (Philippines) which lacks an ISO 639-1 code. | ||
< | |||
There can be multiple <region> sections within the <regions> section. | |||
< | In the <region> element, the 'name' attribute is a descriptive name of the region such as 'Australia' or 'Österreich'. It can also contain extra descriptive information regarding additional formatting options such as 'USA (12h)' or 'India (24h)'. | ||
The < | |||
In the <region> element , the 'locale' attribute is the 2-character [https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements ISO-3166-1 Alpha-2] country code for the region being described. | |||
Both <dateshort> and <datelong> elements contain date formatting codes for displaying short and long dates respectively. A short date would be something like '01/12/02' whereas a long date would be something like 'Dimanche, 1 décembre 2002'. | |||
{| class="prettytable" style="width: 35em;" | |||
|+ Valid Date Formatting Codes | |||
| D || Day without zero padding. eg: 1 or 31 | |||
|- | |||
| DD || Day with zero padding. eg: 01 or 31. | |||
|- | |||
| ddd || Language-specific abbreviated day name. eg: 'Wed' or 'Mi'. | |||
|- | |||
| DDDD || Language-specific full day name. eg: 'Wednesday' or 'Mittwoch'. | |||
|- | |||
| M || Month without zero padding. eg: 1 or 12 | |||
|- | |||
| MM || Month with zero padding. eg: 01 or 12 | |||
|- | |||
| mmm || Language-specific abbreviated month name. eg: 'Dec' or 'déc.'. | |||
|- | |||
| MMMM || Language-specific full month name. eg: 'December' or 'décembre'. | |||
|- | |||
| YY || Two-digit year without the century. eg: 02 or 97 | |||
|- | |||
| YYYY || Four-digit year with the century. eg: 2002 or 1997. | |||
|} | |||
For example, 'DD/MM/YY' would produce something like '01/12/02' whereas 'DDDD, D MMMM YYYY' would something like 'Sunday, 1 December 2002'. | |||
Note: When this article was being researched in March 2023 the 'symbolAM' and 'symbolPM' attributes within the <time> element seem to have no direct effect on the format. These values appear to be set using localisation strings 378 and 379 respectively from 'strings.po'. | |||
The <time> element contains time formatting codes for displaying times. | |||
{| class="prettytable" style="width: 30em;" | |||
|+ Valid Time Formatting Codes | |||
| h || Hour without zero padding, 12 hour clock. eg: 1 or 12 | |||
|- | |||
| hh || Hour without zero padding, 12 hour clock. eg: 01 or 12 | |||
|- | |||
| H || Hour without zero padding, 24 hour clock. eg: 1 or 23 | |||
|- | |||
| HH || Hour without zero padding, 24 hour clock. eg: 01 or 23 | |||
|- | |||
| m || Minute without zero padding. eg:1 or 59. | |||
|- | |||
| mm || Minute with zero padding. eg:01 or 59. | |||
|- | |||
| s || Seconds without zero padding. eg:1 or 59. | |||
|- | |||
| ss || Seconds with zero padding. eg:01 or 59. | |||
|- | |||
| xx || Meridiem indicator for 12 hour clock. eg: AM or PM. | |||
|} | |||
For example, 'h:mm xx' would produce something like '2:34 PM' whereas 'HH:mm' would something like '14:34'. | |||
The <tempunit> element determines the unit of measurement to use when describing temperatures. | |||
{| class="prettytable" style="width: 15em;" | |||
|+ Valid Temperature Units | |||
| c | |||
| Celsius | |||
|- | |||
| f | |||
| Fahrenheit | |||
|- | |||
| k | |||
| Kelvin | |||
|- | |||
| re | |||
| Reaumur | |||
|- | |||
| ra | |||
| Rankine | |||
|- | |||
| ro | |||
| Romer | |||
|- | |||
| de | |||
| Delisle | |||
|- | |||
| n | |||
| Newton | |||
|- | |||
|} | |||
The <speedunit> element determines the unit of measurement to use when describing speed. | |||
{| class="prettytable" style="width: 20em;" | |||
|+ Valid Speed Units | |||
| kmh || Kilometres per hour | |||
|- | |||
| mpmin || Metres per minute | |||
|- | |||
| mps || Metres per second | |||
|- | |||
| fth || Feet per hour | |||
|- | |||
| ftm || Feet per minute | |||
|- | |||
| fts || Feet per second | |||
|- | |||
| mph || Miles per hour | |||
|- | |||
| kts || Knots | |||
|- | |||
| beaufort || Beaufort | |||
|- | |||
| inchs || Inch per second | |||
|- | |||
| yards || Yard per second | |||
|- | |||
| fpf || Furlong per fortnight | |||
|} | |||
The <timezone> element is optional but should contain the abbreviated timezone code for the region. For example, 'GMT' or 'CET'. | |||
The <thousandsseparator> element describes the character used as a thousands separator. | |||
The 'groupingformat' attribute is a mystery known only to the grand high guru of grouping formats, however, a value of "\3" appears to be a popular choice. | |||
The <decimalseparator> element describes the character used as a decimal point separator. | |||
==== References: ==== | |||
* [https://github.com/xbmc/xbmc/blob/2aab388778dc4590a13e763dc51a4d90562251bb/xbmc/LangInfo.cpp#L98 LangInfo.cpp ]. | |||
* [https://github.com/xbmc/xbmc/blob/2aab388778dc4590a13e763dc51a4d90562251bb/xbmc/XBDateTime.cpp#L1333 XBDateTime.cpp ]. | |||
=== What is strings.po === | === What is strings.po === | ||
This | This GNU Gettext format file contains all text strings displayed in the user interface of Kodi.<br/> | ||
Using that file the entire application or any add-on can be translated to any language whose graphemes are available within Unicode. | |||
==== Layout of the strings.po file ==== | ==== Layout of the strings.po file ==== | ||
Line 107: | Line 243: | ||
The important thing is that you cannot refer to the label with msgid in the settings.py file, you need to use the ''label_id'' which must be encoded in msgctxt as above. | The important thing is that you cannot refer to the label with msgid in the settings.py file, you need to use the ''label_id'' which must be encoded in msgctxt as above. | ||
You can of course edit .po files in a text editor or with a specialist editor. | You can of course edit .po files in a text editor or with a specialist editor. | ||
==== Layout of the language folders ==== | ==== Layout of the language folders ==== | ||
Line 115: | Line 249: | ||
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). | 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. | 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. | ||
<br/><br/> | |||
Add-ons: | |||
<syntaxhighlight lang="python" enclose="div"> | <syntaxhighlight lang="python" enclose="div"> | ||
/resources/language/resource.language.en_gb/strings.po | /resources/language/resource.language.en_gb/strings.po | ||
Line 120: | Line 256: | ||
/resources/language/resource.language.it_it/strings.po | /resources/language/resource.language.it_it/strings.po | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Skins: | |||
<syntaxhighlight lang="python" enclose="div"> | |||
/language/resource.language.en_gb/strings.po | |||
/language/resource.language.fr_fr/strings.po | |||
/language/resource.language.it_it/strings.po | |||
</syntaxhighlight> | |||
Please use lower case for folder and file names. | |||
<br/><br/> | |||
An extensive example list of used languages can be found here https://github.com/xbmc/xbmc/tree/master/addons/skin.estuary/language | An extensive example list of used languages can be found here https://github.com/xbmc/xbmc/tree/master/addons/skin.estuary/language | ||
== Adding a new language to Kodi == | == Adding a new language to Kodi == | ||
{{see| | {{see|Language portal}} | ||
== Maintaining a language == | == 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 instantly be automatically updated at Weblate translation pages. | 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.<br/> | ||
From time to time the English (UK) language file changes. This will instantly be automatically updated at Weblate translation pages. | |||
== Related articles in the Kodi online manual == | == Related articles in the Kodi online manual == | ||
* [[Translations|Translations in Kodi]] | |||
* [[Translating_add-ons|Translating your add-on]] | |||
* [[List_of_supported_charsets|List of Supported Charsets]] | * [[List_of_supported_charsets|List of Supported Charsets]] | ||
* [[List of language codes (ISO-639:1988)]] | * [[List of language codes (ISO-639:1988)]] | ||
== Notes for developers == | == Notes for developers == |
Latest revision as of 03:48, 31 March 2023
Development Add-on development |
Language support |
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.
The langinfo.xml file is part of a Kodi language add-on and cannot generally be modified directly by end-users. The file describes the presentation formatting for items like dates and times for each of the regional variations within that language.
For example: some regions / cultures may prefer their dates to read '1 December 2002' whereas others may prefer 'December 1, 2002'. These preferences, among others, are defined in this file.
langinfo.xml
<language locale="[ISO 639-2 Code | ISO 639-1 Code]"> <regions> <region name="[Descriptive Name]" locale="[ISO-3166-1 Alpha-2 Code]"> <dateshort>[Date Format Codes]</dateshort> <datelong>[Date Format Codes]</datelong> <time symbolAM="[Symbol for 'ante meridiem']" symbolPM="[Symbol for 'post meridiem']">[Time Format Codes]</time> <tempunit>[One of {"f","k","c","re","ra","ro","de","n"}]</tempunit> <speedunit>[One of {"kmh","mpmin","mps","fth","ftm","fts","mph","kts","beaufort","inchs","yards","fpf"}]</speedunit> <timezone>GMT</timezone> <thousandsseparator groupingformat="\3">,</thousandsseparator> <decimalseparator>.</decimalseparator> </region> </regions> </language>
The <language> 'locale' is identified using either the 3-character ISO 639-2 code or the 2-character ISO 639-1 code. For example, 'eng' or 'en' for 'English' or 'vie' or 'vi' for 'Vietnamese', or 'fil' for 'Filipino' (Philippines) which lacks an ISO 639-1 code.
There can be multiple <region> sections within the <regions> section.
In the <region> element, the 'name' attribute is a descriptive name of the region such as 'Australia' or 'Österreich'. It can also contain extra descriptive information regarding additional formatting options such as 'USA (12h)' or 'India (24h)'.
In the <region> element , the 'locale' attribute is the 2-character ISO-3166-1 Alpha-2 country code for the region being described.
Both <dateshort> and <datelong> elements contain date formatting codes for displaying short and long dates respectively. A short date would be something like '01/12/02' whereas a long date would be something like 'Dimanche, 1 décembre 2002'.
D | Day without zero padding. eg: 1 or 31 |
DD | Day with zero padding. eg: 01 or 31. |
ddd | Language-specific abbreviated day name. eg: 'Wed' or 'Mi'. |
DDDD | Language-specific full day name. eg: 'Wednesday' or 'Mittwoch'. |
M | Month without zero padding. eg: 1 or 12 |
MM | Month with zero padding. eg: 01 or 12 |
mmm | Language-specific abbreviated month name. eg: 'Dec' or 'déc.'. |
MMMM | Language-specific full month name. eg: 'December' or 'décembre'. |
YY | Two-digit year without the century. eg: 02 or 97 |
YYYY | Four-digit year with the century. eg: 2002 or 1997. |
For example, 'DD/MM/YY' would produce something like '01/12/02' whereas 'DDDD, D MMMM YYYY' would something like 'Sunday, 1 December 2002'.
Note: When this article was being researched in March 2023 the 'symbolAM' and 'symbolPM' attributes within the
The
h | Hour without zero padding, 12 hour clock. eg: 1 or 12 |
hh | Hour without zero padding, 12 hour clock. eg: 01 or 12 |
H | Hour without zero padding, 24 hour clock. eg: 1 or 23 |
HH | Hour without zero padding, 24 hour clock. eg: 01 or 23 |
m | Minute without zero padding. eg:1 or 59. |
mm | Minute with zero padding. eg:01 or 59. |
s | Seconds without zero padding. eg:1 or 59. |
ss | Seconds with zero padding. eg:01 or 59. |
xx | Meridiem indicator for 12 hour clock. eg: AM or PM. |
For example, 'h:mm xx' would produce something like '2:34 PM' whereas 'HH:mm' would something like '14:34'.
The <tempunit> element determines the unit of measurement to use when describing temperatures.
c | Celsius |
f | Fahrenheit |
k | Kelvin |
re | Reaumur |
ra | Rankine |
ro | Romer |
de | Delisle |
n | Newton |
The <speedunit> element determines the unit of measurement to use when describing speed.
kmh | Kilometres per hour |
mpmin | Metres per minute |
mps | Metres per second |
fth | Feet per hour |
ftm | Feet per minute |
fts | Feet per second |
mph | Miles per hour |
kts | Knots |
beaufort | Beaufort |
inchs | Inch per second |
yards | Yard per second |
fpf | Furlong per fortnight |
The <timezone> element is optional but should contain the abbreviated timezone code for the region. For example, 'GMT' or 'CET'.
The <thousandsseparator> element describes the character used as a thousands separator.
The 'groupingformat' attribute is a mystery known only to the grand high guru of grouping formats, however, a value of "\3" appears to be a popular choice.
The <decimalseparator> element describes the character used as a decimal point separator.
References:
What is strings.po
This GNU Gettext format file contains all text strings displayed in the user interface of Kodi.
Using that file the entire application or any add-on can be translated to any language whose graphemes are available within Unicode.
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 (https://kodi.weblate.cloud/languages/en_gb/)\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 ""
This is a format defined by GNU gettext but adapted in a very specific way by Kodi. The blocks of 3 settings in the example above are defined by GNU gettext as:
msgctxt context msgid untranslated-string msgstr translated-string
Where the text is defined by untranslated-string and context serves to differentiate identical values.
Take note, in Kodi, these are used as follows:
msgctxt "#label_id" msgid label_text msgstr translation
where label_id is a numeric ID. These IDs are reserved by Kodi:
- 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
and are used in settings.xml to label settings.
label_text defines the English text for the label.
translation is empty for "en_GB" labels, and the translation for other languages with msgid retaining the English text.
The important thing is that you cannot refer to the label with msgid in the settings.py file, you need to use the label_id which must be encoded in msgctxt as above.
You can of course edit .po files in a text editor or with a specialist editor.
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.
Add-ons:
/resources/language/resource.language.en_gb/strings.po /resources/language/resource.language.fr_fr/strings.po /resources/language/resource.language.it_it/strings.po
Skins:
/language/resource.language.en_gb/strings.po /language/resource.language.fr_fr/strings.po /language/resource.language.it_it/strings.po
Please use lower case for folder and file names.
An extensive example list of used languages can be found here https://github.com/xbmc/xbmc/tree/master/addons/skin.estuary/language
Adding a new language to Kodi
- See: Language portal
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 instantly be automatically updated at Weblate translation pages.
Related articles in the Kodi online manual
- Translations in Kodi
- Translating your add-on
- List of Supported Charsets
- List of language codes (ISO-639:1988)
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.