Skip to content
ComPDF
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Localization

The WebViewer UI is internationalized with i18next. Six languages ship out of the box; you can switch at runtime and add your own.

Supported languages

Translation files live in packages/webview/public/locales/ (copied to dist/locales/ on build), named translation-<lng>.json to match the i18next-http-backend load path ./locales/-.json.

CodeLanguage
enEnglish (fallback)
zh-CNSimplified Chinese
zh-TWTraditional Chinese
jaJapanese
frFrench
thThai

Default/fallback: en. The selected language is persisted in localStorage under the language key.

UI APIs

UI.setLanguage(language)

Switch the UI language at runtime. Async.

javascript
/**
 * @method UI.setLanguage
 * @param {string} language Default supported: en, zh-CN, zh-TW, fr, th, ja.
 */
await UI.setLanguage('zh-CN');

Internally: await i18next.changeLanguage(language), then store.setLanguage(language), then persists to localStorage['language']. Components consume translations via useTranslation() from i18next-vue.

UI.addLanguage(language)

Add a language resource to the available set.

javascript
UI.addLanguage({ /* language resource object */ });

UI.removeLanguage(language)

Remove a language from the available set.

javascript
UI.removeLanguage('fr');

UI.setLanguages(languages)

Replace the entire set of available languages.

javascript
UI.setLanguages([ /* array or object */ ]);

How i18n is initialized

The active initializer is packages/webview/src/i18n.js:

  • Uses i18next + i18next-http-backend + i18next-vue.
  • Language selection: localStorage['language'] || localStorage['currentLanguage'] || 'en'.
  • Init options: load: 'currentOnly', returnObjects: true, fallbackLng: 'en', namespace translation.
  • Backend: loads ./locales/-.json via a custom XHR requester that tolerates Android-webview status 0 for file:// loads.
  • Exposes window.i18next = i18next globally and exports i18nextPromise (awaited in App/index.vue before the app renders).

packages/webview/src/i18nNext.js is a minimal legacy variant (no HTTP backend, no localStorage) and is not imported by main.js. It is superseded by i18n.js.

packages/webview/src/helpers/setupI18n.js declares a Languages[] catalog of 25 [code, displayName] pairs and languageRules mapping internal codes to i18next/dayjs locale codes — useful as a reference for the broader language catalog the SDK can be extended to support.

Examples

Switch to Japanese

javascript
await UI.setLanguage('ja');

Add a custom language (sketch)

javascript
UI.addLanguage({
  code: 'ko',
  translations: {
    'header.tools.annotate': '주석',
    /* …full translation map… */
  },
});
await UI.setLanguage('ko');

The exact shape of the resource object follows the i18next resource structure; see translation-en.json for the full set of keys.