-
Notifications
You must be signed in to change notification settings - Fork 75
Translations
CPod is available in a number of languages thanks to contributors.
Translation files are located in the locales
directory.
To start a new translation, create a new file in the locales directory.
The filename must be the language's ISO 639-1 code in lowercase, followed optionally, in cases of regional variants, by an underscore and the country's ISO 3166-1 alpha-2 code in uppercase, with the file extension json
.
Examples:
Locale | Filename |
---|---|
English (generic) | en.json |
Portuguese (generic) | pt.json |
Portuguese (Brazilian) | pt_BR.json |
Chinese (Traditional) | zh_TW.json |
Chinese (Simplified) | zh_CN.json |
Typically a regional sub-code should only be added if the base locale already exists.
Copy the contents of the canonical English locale from en.json
into the new file.
Replace each string with the translated equivalent.
Please ensure that the JSON syntax is correct, otherwise the file will be unreadable by CPod.
If you have CPod set up locally, you can simply create an empty file with the correct filename, then run gulp i18n
. This will populate the new file with the keys and empty strings. You can then use the bin/i18n-progress.js
script, passing in the locale name (filename, minus the .json
), to see translation progress and a list of untranslated keys.
In some cases it is desirable to create an empty locale which simply points to another locale. For example, the zh_HK
(Chinese (Hong Kong)) locale points to zh_TW
(Chinese (Traditional)).
This type of locale does not appear in CPod's languages list, but is called upon internally when CPod performs automatic locale detection to resolve ambiguity when more than one fallback locale is available. It should only be created in cases where:
- a region doesn't have a dedicated CPod locale
- more than one locale exists for the language spoken in that region
- users in that region are expected to strongly prefer one variant of the language over another
To create such a locale alias, create a new file with a filename as described above. The file contents are as follows (zh_HK.json
shown as an example):
{
"__redirect__": "zh_TW"
}