Namespace for the internationalization and localization (i18n) configuration. The current locale can be retrieved via PSPDFKit.Instance#locale, and set with PSPDFKit.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
PSPDFKit.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
{
"en": {
"delete": "Delete",
"openPDF": "Open PDF"
},
"it": {
"delete": "Rimuovi",
"openPDF": "Apri PDF"
}
}
PSPDFKit.I18n.messages.en.openPDF = "Open";
Methods
PSPDFKit for Web comes with a number of predefined locales which are loaded automatically on demand when using the PSPDFKit.Instance#setLocale API or when setting a locale in the main PSPDFKit.Configuration.
The locale information are then exposed to PSPDFKit.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 PSPDFKit for Web 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