PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
The WebViewer UI is internationalized with i18next. Six languages ship out of the box; you can switch at runtime, change translations and add your own languages. Each WebViewer instance has its own i18next instance.
Translation files are in webviewer/locales/, named translation-<lng>.json. They are loaded from {uiPath}locales/ when a language is used.
| Code | Language |
|---|---|
en | English (fallback) |
zh-CN | Simplified Chinese |
zh-TW | Traditional Chinese |
ja | Japanese |
fr | French |
th | Thai |
Default/fallback: en. The initial language is the defaultLanguage option. The selected language is saved for the instance and restored next time.
UI.setLanguage(language) Switch the UI language at runtime. Returns a Promise that resolves when the language is ready.
/**
* @method UI.setLanguage
* @param {string} language Default supported: en, zh-CN, zh-TW, fr, th, ja.
* @returns {Promise<void>}
*/
await UI.setLanguage('zh-CN');UI.Events.LANGUAGE_CHANGED fires with (previousLanguage, newLanguage). UI.getCurrentLanguage() returns the current language, and UI.getAvailableLanguages() returns the language codes that can be used.
UI.setTranslations(language, translations) Add or override translations of a language. The keys are the keys of translation-<lng>.json.
UI.setTranslations('en', {
toolbar: { toolbarGroup: { annotations: 'Markup' } },
});UI.getLocalizedText(key) returns the translation of a key in the current language.
UI.addLanguage(language) Add a language to the language list in the settings dialog.
UI.addLanguage({ code: 'ko', name: '한국어' });UI.removeLanguage(language) Remove a language from the language list.
UI.removeLanguage('fr');UI.setLanguages(languages) Replace the language list.
UI.setLanguages([
{ code: 'en', name: 'English' },
{ code: 'zh-CN', name: '简体中文' },
]);defaultLanguage option, then en.{uiPath}locales/translation-<lng>.json is loaded when a language is first used. Translations added with setTranslations are merged with the loaded file.await UI.setLanguage('ja');UI.addLanguage({ code: 'ko', name: '한국어' });
UI.setTranslations('ko', {
toolbar: { toolbarGroup: { annotations: '주석' } },
/* …full translation map… */
});
await UI.setLanguage('ko');The structure follows the i18next resource structure; see
webviewer/locales/translation-en.jsonfor the full set of keys. Keys without a translation fall back to English.