Translations (i18n)
Translation namespaces
Default namespace is called common
and contains translations used on all pages (Layout, Nav, etc) and is stored at frontend/public/locales/{locale}/common.json
Namespaces (scopes, domains) are stored in separate json files at frontend/public/locales/{locale}/{namespace}.json
One namespace can combine the translations keys from several pages with common reusable strings ex. auth
scope collects keys for login
and register
pages.
Translation keys
It is preferred to use kebab-case for translation keys and extract another level of nesting when the common prefix of the keys is above 3 or makes sense to be separated as new keys might be added in the future.
Namespace is separated with
:
Translation nesting levels are separated with
.
Words in a translation key are separated with
-
domain:pages.nested-level.another-nested-level.translation-key
Usage in React
Usage of translation hook useTranslation
is preferred over usage of <Trans />
component, whenever possible.
Usage in components
SSR preloading i18n in pages
Last updated