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


Deprecation notice: PSPDFKit.I18n#localeData is deprecated since version 2019.6, which adopted React Intl version 3.x.x changes. This version dropped support for providing custom localization data in favour of using the standard Intl browser API for pluralization and other localization rules, which means that you no longer need to provide these rules if you want to support additional locales.

On the other hand, you will no longer be able to provide localization rules for locales not supported by the browser either, but considering the large number of locales supported by modern browsers, this should not pose a problem.

Browsers that do not support the Intl API (like IE11 and Safari 13-) will include a polyfill for Intl.PluralRules, as well as an individual polyfill for each of the supported locales. If you want to keep supporting these browsers when providing additional locales, you can do so by including the corresponding locale polyfill:

// Add the locale to the locales list (Wolof language)
// Is this browser using the `Intl.PluralRules` polyfill?
if (Intl.PluralRules.polyfilled) {
  // Then include the plural rules locale data polyfill
  await import('@formatjs/intl-pluralrules/dist/locale-data/wo')
// Add Wolof translations for messages
PSPDFKit.I18n.messages['wo'] = wolofMessages
// Change current language to Wolof

Install the locale data polyfills:


yarn add @formatjs/intl-pluralrules
npm i @formatjs/intl-pluralrules


(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 translated messages.


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.

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.