Switch Toolbar Language - Internationalization

Requirements
View Demo

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.

1// eslint-disable-next-line no-undef
2const WebViewerConstructor = isWebComponent() ? WebViewer.WebComponent : WebViewer;
3
4WebViewerConstructor(
5 {
6 path: '../../../lib',
7 additionalTranslations: {
8 language: 'en',
9 translations: { 'option.toolbarGroup.toolbarGroup-View': 'Edited View Label' },
10 },
11 initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
12 },
13 document.getElementById('viewer')
14).then(instance => {
15 samplesSetup(instance);
16
17 const currentLanguage = instance.UI.getCurrentLanguage();
18 const radioButton = document.querySelector(`form > #${currentLanguage}`);
19 if (radioButton) {
20 radioButton.checked = true;
21 }
22
23 document.getElementById('form').onchange = e => {
24 // Set language
25 instance.UI.setLanguage(e.target.id);
26 };
27});

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales