i18n
How to use i18n
to localization NodeJS and Java strings.
How to add supported Languages?
To add a new language to APITable, follow these steps:
Determine the code of the language to be added, for example
uk-UA
.Add new language files in the
packages/l10n/base/
directory. For example, create a file namedstrings.uk-UA.json
.List the value keys for translation in the new language file, following the format of strings.en-US.json.
Add the language item in
packages/l10n/base/language.manifest.json
.{ "en-US": "English", "uk-UA": "українська", "zh-CN": "简体中文" }
Once the translation is complete, execute the command:
make settings
.
How to contribute translation?
You can modify the markdown files in source code and create a Pull Request directly
Also, for the text of the UI, you can find the specified key in the string
file and modify it, the string
files are located at(Different languages correspond to different language files):
1. packages/l10n/base/strings.zh-HK.json
2. packages/l10n/base/strings.ja-JP.json
3. ...
For example, if your language setting is “English“ and you saw the word "text" from the UI that was not translated appropriately.
You can locate its string key in the file packages/l10n/base/strings.en-US.json
.
It looks like this:
{
...,
"title": "text"
...
}
You can modify its value to "text1":
{
...,
"title": "text1",
...
}
Then create a Pull Request.
NodeJS & React
import { t, Strings } from '../../exports/i18n';
const displayText = t(Strings.xxx);