Translations
Never hard code text. Put every string your plugin shows in locales/en.json:
{
"tab": { "title": "Hello", "empty": "No notes yet." },
"permissions": {
"use": {
"title": "Use Hello",
"description": "Open the Hello tab and keep notes in it."
}
}
}
Keys in the manifest (titleKey, labelKey and so on) and calls to t() look up this file. Each plugin has its own namespace, so your tab.title never clashes with another plugin's.
const { t } = useTranslation();
return <p>{t("tab.empty")}</p>;
A key you don't define falls back to Termix's shared strings, like common.save.
Outside a component, use app.t("tab.title").
Other languages
Official plugins are translated automatically when they are released. A community plugin ships its own translations, or none at all. Any language or string you don't translate shows in English.
To add a language, copy locales/en.json to locales/translated/<file>.json with the same keys and translate the values. Keep {{placeholders}} as they are.
| Language | File | Language | File |
|---|---|---|---|
| Afrikaans | af_ZA | Japanese | ja_JP |
| Arabic | ar_SA | Korean | ko_KR |
| Bengali | bn_BD | Latvian | lv_LV |
| Bulgarian | bg_BG | Lithuanian | lt_LT |
| Catalan | ca_ES | Malay | ms_MY |
| Chinese (Simplified) | zh_CN | Norwegian | no_NO |
| Chinese (Traditional) | zh_TW | Polish | pl_PL |
| Croatian | hr_HR | Portuguese (Portugal) | pt_PT |
| Czech | cs_CZ | Portuguese (Brazil) | pt_BR |
| Danish | da_DK | Romanian | ro_RO |
| Dutch | nl_NL | Russian | ru_RU |
| Estonian | et_EE | Serbian | sr_SP |
| Finnish | fi_FI | Slovak | sk_SK |
| French | fr_FR | Slovenian | sl_SI |
| German | de_DE | Spanish | es_ES |
| Greek | el_GR | Swedish | sv_SE |
| Hebrew | he_IL | Thai | th_TH |
| Hindi | hi_IN | Turkish | tr_TR |
| Hungarian | hu_HU | Ukrainian | uk_UA |
| Indonesian | id_ID | Vietnamese | vi_VN |
| Italian | it_IT |
Plurals
Pass count and add a key per plural form. English has two:
{ "hosts_one": "{{count}} host", "hosts_other": "{{count}} hosts" }
t("hosts", { count: 3 });
Some languages have more forms. Russian needs _one, _few, _many and _other, and Arabic adds _zero and _two. Use the forms that language uses, not the English ones. See the CLDR plural rules.