The Vendure Admin UI is fully localizable, allowing you to:
The Admin UI uses the Messageformat specification to convert i18n tokens to localized strings in the browser. Each language should have a corresponding JSON file containing the translations for that language.
Here is an excerpt from the en.json file that ships with the Admin UI:
The translation tokens are grouped into a single-level deep nested structure. In the Angular code, these are referenced like this:
That is, the { ... } represent variables that are passed from the application code and interpolated into the final localized string.
The Admin UI ships with built-in support for many languages, but allows you to add support for any other language without the need to modify the package internals.
Create your translation file
Start by copying the contents of the English language file into a new file, <languageCode>.json, where languageCode is the 2-character ISO 639-1 code for the language. Replace the strings with the translation for the new language.
Install @vendure/ui-devkit
If not already installed, install the @vendure/ui-devkit package, which allows you to create custom builds of the Admin UI.
Register the translation file
Here's a minimal directory structure and sample code to add your new translation:
And the config code to register the translation file:
You can also create translations for your own UI extensions, in much the same way as outlined above in "Adding a new language". Your translations can be split over several files, since the translations config object can take a glob, e.g.:
This allows you, if you wish, to co-locate your translation files with your components.
Care should be taken to uniquely namespace your translation tokens, as conflicts with the base translation file will cause your translations to overwrite the defaults. This can be solved by using a unique section name, e.g.: