UI
Switch Toolbar Language - Internationalization
This JavaScript sample lets you change the language displayed in tooltips when viewing documents in PDF Viewer. Compatible with all browsers (including IE11) and mobile devices without using plug-ins.
Launch the Internationalization Demo to see an example of how you can toggle between English, French and Chinese Simplified in WebViewer.
Learn more about our Web SDK.
// eslint-disable-next-line no-undef
const WebViewerConstructor = isWebComponent() ? WebViewer.WebComponent : WebViewer;
WebViewerConstructor(
{
path: '../../../lib',
additionalTranslations: {
language: 'en',
translations: { 'option.toolbarGroup.toolbarGroup-View': 'Edited View Label' },
},
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
},
document.getElementById('viewer')
).then(instance => {
samplesSetup(instance);
const currentLanguage = instance.UI.getCurrentLanguage();
const radioButton = document.querySelector(`form > #${currentLanguage}`);
if (radioButton) {
radioButton.checked = true;
}
document.getElementById('form').onchange = e => {
// Set language
instance.UI.setLanguage(e.target.id);
};
});