Namespace for the internationalization and localization (i18n) configuration. The current locale can be retrieved via NutrientViewer.Instance#locale, and set with NutrientViewer.Instance#setLocale.
Members
Methods
Members
Returns an array of available locales. Each entry in the array is a string representing the
locale e.g. en
. The array can be mutated directly to add new locales. Note that when adding
new locales you also need to add the corresponding
translated messages.
Example
Add a new locale.
NutrientViewer.I18n.locales.push("fr");
Returns an object containing the translated messages for every locale.
In the messages object each key represents the locale and values are objects containing
messageId
-translated message
pairs.
The messages object can be mutated directly to change translations or add new ones.
Examples
The messages object
{
"en": {
"delete": "Delete",
"openPDF": "Open PDF"
},
"it": {
"delete": "Rimuovi",
"openPDF": "Apri PDF"
}
}
Mutate the messages object. Replace "Open PDF" with "Open".
NutrientViewer.I18n.messages.en.openPDF = "Open";
Methods
Nutrient Web SDK comes with a number of predefined locales which are loaded automatically on demand when using the NutrientViewer.Instance#setLocale API or when setting a locale in the main NutrientViewer.Configuration.
The locale information are then exposed to NutrientViewer.I18n.messages.
You can use this method to preload these information instead of loading them on demand. This would allow you to modify some translations before loading Nutrient Web SDK for example.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
locale |
string | The locale to load the localization data for. |
|||||||||
options |
object |
<optional> |
Properties
|
Returns:
void Returns a promise that resolves when the locale data have been loaded.
- Type
- Promise