1. Home
  2. Foxit PDF SDK for Web
  3. How to Add Another Language to Foxit PDF SDK for Web

How to Add Another Language to Foxit PDF SDK for Web

Foxit PDF SDK for Web enables you to update all of the strings used by the PDF viewer so you can change it to your language. You can easily create a new folder for your own language at the ‘locales’ folder and translate the string content on ‘ui.json’ and ‘viewer.json’ for all objects. By directing your viewer to this JSON file, it will use the new strings in your language. This can work for almost any language provided you go through the strings and translate them to your language. Please follow the steps below to do this.

Assumption

Please ensure you have an assets/in your website root directory, where you will configure the language resources. Let’s call this path websiteRoot/assets/.

Configuration

1) Copy lib/locales inside the SDK to websiteRoot/assets/.

2) Set up the I18N path for loading resources.

new UIExtension.PDFUI({
    i18n: {
        absolutePath: 'websiteRoot/assets/locals'
    },
    // the other options...
});

3) Add more localization languages
Create a new folder in
websiteRoot/assets/locals. The folder name should follow the language codes standard, such as zh-CN for Chinese. And then new a file and name it ui_.json.

4) Set up a default language

new UIExtension.PDFUI({
    i18n: {
        absolutePath: `websiteRoot/assets/locals`,
        lng: 'zh-CN'
},
    // the other options
})

Verify the configuration in a developer environment

1) Clear your browser cache to ensure the latest I18N resources will be loaded.

2) Refresh your browser, open the Network panel in DevTools, and check if the ui_.json request URL points to your custom language path. If yes, then you’re fully set up!

Updated on July 27, 2020

Was this article helpful?

Related Articles