multilanguage does not function in widgets, e.g. Demo widget

1082
4
Jump to solution
06-30-2020 09:37 AM
MichaelLev
Occasional Contributor III

I'm new (one month) to esri Web AppBuilder (Developer Edition) for javascript. I made a few custom widgets, but changing Chrome language does not have any effect on displayed messages!...

I'll appreciate if someone will show me what is needed to do, for example, in the Demo widget example.

I'm working in 3d.

I'm astonished to see that in all the widget supplied in the app builder, none is doing what expected, when I change Chrome language...

0 Kudos
1 Solution

Accepted Solutions
MichaelLev
Occasional Contributor III

Dear Robert, Thank you very much! I solved my problem -

1. Adding "&locale=he" to the url works.

2. In order to sense the Chrome language (with no locale parameter in the url), I did 2 code modifications:

2.1 - First modified setLocale() code in init.js to "prefer" navigator.language upon cookies. For applications it's enough, and so for Launch button in WAB, but for WAB window itself, the widget label (for in-panel widget, when I hover on it) remained in english, so I had to do 2nd modification:

2.2 - in jimu.js ConfigLoader.js in function _checkLocale() - when setting appLocale, I moved dojoConfig.locale to the start of the "or" sentence. 

Now the Chrome language is sensed even if no locale parameter in url.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Michael,

 Localizing your widget is cover in this guide page:

Add i18n support—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers 

For testing purposes you can add this parameter to the url to change the apps language:

&locale=zh-cn

MichaelLev
Occasional Contributor III

Dear Robert,

Thank you! "&locale=he" works like magic!

Only I'm astonished why changing Chrome language does not have any effect...

Am I understanding correctly from your answer, that adding parameter to the URL is only a way for testing, and changing the Chrome language is the "MAIN" way? if this is what you meant, than what am I missing since it does not work...

I'll appreciate your help.

Michael

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Michael,

   A far as I know Dojo gets the locale from the OS, not the browser. So if you have Windows installed with en-US then it will use English by default.

MichaelLev
Occasional Contributor III

Dear Robert, Thank you very much! I solved my problem -

1. Adding "&locale=he" to the url works.

2. In order to sense the Chrome language (with no locale parameter in the url), I did 2 code modifications:

2.1 - First modified setLocale() code in init.js to "prefer" navigator.language upon cookies. For applications it's enough, and so for Launch button in WAB, but for WAB window itself, the widget label (for in-panel widget, when I hover on it) remained in english, so I had to do 2nd modification:

2.2 - in jimu.js ConfigLoader.js in function _checkLocale() - when setting appLocale, I moved dojoConfig.locale to the start of the "or" sentence. 

Now the Chrome language is sensed even if no locale parameter in url.