Skip to main content

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.

LanguageFileLanguageFile
Afrikaansaf_ZAJapaneseja_JP
Arabicar_SAKoreanko_KR
Bengalibn_BDLatvianlv_LV
Bulgarianbg_BGLithuanianlt_LT
Catalanca_ESMalayms_MY
Chinese (Simplified)zh_CNNorwegianno_NO
Chinese (Traditional)zh_TWPolishpl_PL
Croatianhr_HRPortuguese (Portugal)pt_PT
Czechcs_CZPortuguese (Brazil)pt_BR
Danishda_DKRomanianro_RO
Dutchnl_NLRussianru_RU
Estonianet_EESerbiansr_SP
Finnishfi_FISlovaksk_SK
Frenchfr_FRSloveniansl_SI
Germande_DESpanishes_ES
Greekel_GRSwedishsv_SE
Hebrewhe_ILThaith_TH
Hindihi_INTurkishtr_TR
Hungarianhu_HUUkrainianuk_UA
Indonesianid_IDVietnamesevi_VN
Italianit_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.