Custom Translations are not working in @pdftron/webviewer -11.8

WebViewer Version:
11.8
Do you have an issue with a specific file(s)?
Not with particular file but with the setLanguage functionality.

Can you reproduce using one of our samples or online demos?
Yes, i can able reproduce with your react example

Are you using the WebViewer server?
No

Does the issue only happen on certain browsers?
No

Is your issue related to a front-end framework?
No

Is your issue related to annotations?
No

Please give a brief summary of your issue:

  1. We are having custom translations for the Webviewer like Danish support also en_US regional language support.

  2. We have followed this guide and implemented similar way Change Localization in JavaScript PDF Viewer | Apryse documentation

  3. So we added these custom translation file under webviewer/ui/i18n/translation-da.json

  4. When user change language we call the setLanguage and it used to pull the correct translation till version 11.7.1

  5. But from the 11.8 this stopped work and found that if the language not available from language constant you are preventing the custom language getting fetched and getting the warning in the console.

Please describe your issue and provide steps to reproduce it:

  1. Clone the repo GitHub - JegathiswaranThirumalai/webviewer-react-custom-language
  2. npm i && npm start (updated the copy node script to copy dummy Danish file to the webviewer/ui/i18n/translation-da.json)
  3. Click the Change language to Danish button. It should change the language but its not working. If you downgrade to the 11.7.1 or previous this is working.

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems you’re experiencing issues with custom language translations in WebViewer version 11.8. The setLanguage function appears to not work as expected when using custom translations, particularly for languages not included in the default set.

Some things you can try:

  • Ensure that your custom translation files are correctly formatted and placed in the appropriate directory (webviewer/ui/i18n/).

  • Check if the language code you are using is correctly mapped in your implementation.

  • Verify if there are any console warnings or errors that might provide more context on why the language is not loading.

  • Consider downgrading to a previous version (11.7.1) where the functionality was working, as a temporary workaround.

  • Ensure that your implementation follows the updated guidelines for custom translations, as there might have been changes in the API behavior.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

Hi there,

This is a known issue and is being worked on by the development team.
We will let you know when have more information.

One workaround you could use is to use one of the supported languages in the list, i.e. translation-es.json file and replace all of that with the Danish translations.
Then you can use the setLanguage API and use the ‘es’ value instead:
await instance.UI.setLanguage("es");

Best regards,
Kevin

2 Likes

Hi @kkim
Thanks for the quick support :slightly_smiling_face: . For now we’ve reverted back to the previous version and don’t want to use the workaround for now.

I also noticed that based on the language settings, dayjs localization is automatically loaded. I’m curious about how this will work for custom languages as well. Looking at thesetLanguage.js

code, I can see it tries to import dayjs locale files and falls back to English if not found.

For custom languages, how should we handle dayjs localization? Should we:

  1. Map custom languages to existing dayjs locales via languageRules?
  2. Is there documentation on how to properly configure this?
  3. Will custom languages always fall back to English dayjs locale?

Please point me to documentation or the recommended approach for handling dayjs localization with custom languages.

1 Like

Hi there,

We don’t have a guide on this beyond the creation of the translation files:

From the UI code, as you mentioned, it will default to English if a matching locale file is not found:

You should be able to handle the dayjs localization via updating the existing languageRules.
You may also need to change the active locale based on their documentation here:

Best regards,
Kevin

2 Likes