Example
The messages object after loading the en and it locales.
{
"en": {
"delete": "Delete",
"print": "Print"
},
"it": {
"delete": "Elimina",
"print": "Stampa"
}
}
Replace "Print" with "Print document". Assigning en needs no preload, and every id it does
not name keeps the shipped English.
NutrientViewer.I18n.messages.en = { print: "Print document" };
Edit a locale in place. A locale is only present once it has been loaded, so preload it
first; the ! tells TypeScript the preload put it there.
await NutrientViewer.I18n.preloadLocalizationData("de");
NutrientViewer.I18n.messages.de!.print = "Dokument drucken";
messages
Returns an object containing the translated messages for every locale that has been loaded.
In the messages object each key represents the locale and values are objects containing
messageId-translated message pairs.
Locales are loaded on demand, so this object starts out empty and only gains a locale once
that locale has been used or preloaded via
NutrientViewer.I18n.preloadLocalizationData. Reading a locale that has not been
loaded yet returns undefined, which is why the locale keys are optional.
Assigning en is always safe. Assigning any other locale before it has loaded replaces
that locale's messages rather than layering onto them, and the ids it does not name fall
back to English — preload the locale first when you mean to override only part of it.
The messages object can be mutated directly to change translations or add new ones, and a
whole map can be assigned to it, which replaces every locale it does not name. Key an
override by the plain message id (print). The Localization guide lists the SDK's message
ids with their default English text and the UI surface each appears on.
A locale that overrides only some of its ids keeps the shipped English for the rest.
Example
The messages object after loading the en and it locales.
{
"en": {
"delete": "Delete",
"print": "Print"
},
"it": {
"delete": "Elimina",
"print": "Stampa"
}
}
Replace "Print" with "Print document". Assigning en needs no preload, and every id it does
not name keeps the shipped English.
NutrientViewer.I18n.messages.en = { print: "Print document" };
Edit a locale in place. A locale is only present once it has been loaded, so preload it
first; the ! tells TypeScript the preload put it there.
await NutrientViewer.I18n.preloadLocalizationData("de");
NutrientViewer.I18n.messages.de!.print = "Dokument drucken";
Returns an object containing the translated messages for every locale that has been loaded. In the messages object each key represents the locale and values are objects containing
messageId-translated messagepairs.Locales are loaded on demand, so this object starts out empty and only gains a locale once that locale has been used or preloaded via NutrientViewer.I18n.preloadLocalizationData. Reading a locale that has not been loaded yet returns
undefined, which is why the locale keys are optional.Assigning
enis always safe. Assigning any other locale before it has loaded replaces that locale's messages rather than layering onto them, and the ids it does not name fall back to English — preload the locale first when you mean to override only part of it.The messages object can be mutated directly to change translations or add new ones, and a whole map can be assigned to it, which replaces every locale it does not name. Key an override by the plain message id (
print). The Localization guide lists the SDK's message ids with their default English text and the UI surface each appears on.A locale that overrides only some of its ids keeps the shipped English for the rest.