Localize DevExtreme widget

713 Views Asked by At

In my application it is possible to change the language without reloading the page.

So, when the user change the language, I need to update the locale of the DevExtreme widgets (for example the months label in the calendar widget).

In the documentation I found methods like the following:

Globalize.locale(navigator.language || navigator.browserLanguage);


DevExpress.localization.locale(navigator.language || navigator.browserLanguage);

But I can't import Globalize nor DexExpress in my component.

Is there an other way?

Thanks a lot

1

There are 1 best solutions below

0
On

Here is what I did to localize my devextreme components: In app.module right in the import statements:

import {locale} from 'devextreme/localization';

And then before declaring the module, setting the locale like this:

locale(navigator.language);

You could try to call this at runtime, but I have doubts that it will update the locale in the components automatically.