Namespace: I18n


Namespace for the internationalization and localization (i18n) configuration. The current locale can be retrieved via PSPDFKit.Instance#locale, and set with PSPDFKit.Instance#setLocale.




(static) localeData

Returns an object containing the locale data for each locale. Locale data provide pluralization rules and relative-time formatting features for each locale. Internally PSPDFKit for Web uses React Intl's locale data modules and includes the necessary information for the built-in, default locales to work.

Usually you need to manipulate this object only when you want to add a new locale that is not supported yet. In order to add locale data for a new language you need to:

  • download or install with npm the react-intl package
  • load the react-intl/locale-data/YourNewLocaleSymbol (locale data) either via script tag or import
  • add the locale data to PSPDFKit.I18n.localeData.

Adding the locale data for French via script tag.

<script src="[email protected]/locale-data/fr.js"></script>
<script> =;</script>

Adding the locale data for French via import.

import fr from "react-intl/locale-data/fr"; = fr;

<small>Note that French is already supported by PSPDFKit for Web.</small>

(static) locales

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 locale data.


Add a new locale.


(static) messages

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.


The messages object

  "en": {
    "delete": "Delete",
    "openPDF": "Open PDF"
  "it": {
    "delete": "Rimuovi",
    "openPDF": "Apri PDF"

Mutate the messages object. Replace "Open PDF" with "Open".

PSPDFKit.I18n.messages.en.openPDF = "Open";


(static) preloadLocalizationData(locale) → {Promise}

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 and PSPDFKit.I18n.localeData which you can modify anytime you want.

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.

Name Type Description
locale string

The locale to load the localization data for.


void Returns a promise that resolves when the locale data have been loaded.