а

Changing locales dynamically


#1

Hello,
I am using the Dhtmlx Pro version of the Scheduler and want to be able to change the locales dynamically.
Eg., User can switch to French and then to Italian or any other language that we allow them to change it to.
What is the best way to approach this? I tried dynamically changing the url in the require statement of my javascript code, but this only works once. Specifically, if I change to Chinese then try to change to French, it works, but then I cannot change it to anything else. The locale only seems to update once and then get stuck.

const dhtmlxLocaleMapping = {
  // Arabic
  ar: "locale_ar.js",
  // Belarusian
  be: "locale_be.js",
...
};

const localeFile = dhtmlxLocaleMapping[locale.slice(0, 2)] || dhtmlxLocaleMapping.en;

    if (localeFile) {
      require(`dhtmlx-pro/codebase/sources/locale/${localeFile}`);
    }

Context:
I am using the Scheduler in a React app. Please help.

Regards,
Vivek Patel


#2

Hello,

Unfortunatley I don’t have a demo for the React. Perhaps the snippet can help you to understnad how it might be implemented.
https://snippet.dhtmlx.com/519dd26c7