Configuring localization
The front-end of Valtimo supports localization. The front-end libraries include default translations for main application functionality. These translations can be extended and overridden in a variety of ways.
Custom translation resources
Custom JSON translation files can be added to an implementation by adding a reference to the directory in which they are located to the environment file. In the referenced directory, the translation files must have the language for which they contain translations in their file names; i.e. src/assets/i18n/nl.json
, src/assets/i18n/de.json
and src/assets/i18n/en.json
.
The corresponding environment file would then contain the following translationResources
key:
src/environments/environment.ts
src/environments/environment.ts
Multi translation loader
The Valtimo front-end uses @ngx-translate/core'
for its translations. In addition, a custom TranslateLoader
must be provided to it, in order to support translation files from multiple locations. This can be accomplished by providing this custom loader in the app module:
src/app/app.module.ts
src/app/app.module.ts
Admin configurable translations
From Valtimo front-end and back-end libraries version 12.0.0
and up, it is possible for an administrator to configure translations from the user interface.
Custom translation loader
src/app/app.module.ts
src/app/app.module.ts
Add translation management page
After configuring the CustomMultiTranslateHttpLoaderFactory
and importing TranslationManagementModule
, a link to the translation management page must be added to your implementations environment file:
src/environments/environment.ts
src/environments/environment.ts
Admin configuration of translations
After following the above-mentioned steps, an administrator can now navigate to /translation-management
. On this page, custom translation keys can be configured, which will be available directly in any custom component code using the translate
pipe provided by '@ngx-translate/core'
.
In addition, any existing translations can be overridden by supplying its exact key. In this example, the title displayed for Dashboard in the left sidebar is overridden by supplying the translation key it uses, which is Dashboard
. Now, My dashboard
is displayed when the application is set to English.
Any nested translations can also be overridden by using the dot notation. For example, notice account.informationTitle
is defined in the translation files:
This translation is displayed in the right sidebar as "Information":
We can override this text by providing the exact key using the dot notation, and then providing our own translations:
Finally, our custom translation is displayed in the sidebar on reloading the page:
Last updated