Übersetzungen ECUI Client

General

The workflow includes the following steps in a default scenario:

  • Check for a language in the local storage

  • Fetch the supported languages from the backend

  • Fetch the navigator (browser) languages

  • Pick the overlay if any

  • Fallback to "en"

A set of "standard" translations is included to cover the most basic scenarios. They can be extended anytime by using the following pattern:

const defaultTranslationService = app.get<ITranslationService>(ITranslationServiceSymbol); defaultTranslationService.load(...);

The code should run before other actions are triggered. See the ECUI Client Setup for guidance on how to achieve that.

Once the user is logged in the following happens in sequence:

  1. The language is loaded from the user-settings.

  2. The translations for that language are loaded from the backend.

  3. The model is (re)loaded with the selected language. If the language did not change the model is likely to be loaded from the cache.

Adding translations

Translations can be added on the backend via the ITranslationSourceProvider. Simply register a new set of translations by creating a derived ITranslationSource.

application.Configure<ITranslationSourceProvider>(p => p.Register<QuinoModelTranslationSource>())

Translations can also be loaded on the client directly. Simple call the ITranslationService.load(...) to register additional translations.

Existing keys will get overridden!

Consuming translations

To consume the available translations use the ITranslationService. A default call can be as simple as ITranslationService.translate('mykey').

If a string has defined placeholders one can provide a source object which is used as a replacement source in the string. Given the translation Es ist ein unerwarteter Fehler aufgetreten: [{{error}}] the following call:

ITranslationService.translate('key', { error: 'Something went wrong...' });

would result in:

Es ist ein unerwarteter Fehler aufgetreten: [Something went wrong...]

Note: Keys are resolved case-insensitive! In case a key is not found the translation will equal the key provided.