how can I control which language the WebApp will be?

9529
17
Jump to solution
05-03-2015 12:58 AM
SPNIOrganization
Occasional Contributor

In the Supported languages section it says : "The language used by the app is determined by your browser's language setting."

Is there a way to control this?

I built the App in Hebrew and I want all the users to see it in Hebrew, no matter what their browser's setting is.

Is that possible?

Deshe.

Tags (1)
1 Solution

Accepted Solutions
SPNIOrganization
Occasional Contributor

well,

No one answered my question but I found the answer so I will share it with you:

In order to control the language you need to use the webappbuilder from your one server and add this code inside the file init.js  : (after or instead of the original code. )

    //override language and orientation

//*********************************************

dojoConfig.locale = "he";

window._setRTL(dojoConfig.locale);

//*********************************************

View solution in original post

17 Replies
AsmaaMohamed
New Contributor II

in file (init.js) find this line

dojoConfig.locale = navigator.language ? navigator.language : navigator.userLanguage;

and replace with this line :

dojoConfig.locale = "he" example -> dojoConfig.locale = "ar" this is Arabic app

SPNIOrganization
Occasional Contributor

well,

No one answered my question but I found the answer so I will share it with you:

In order to control the language you need to use the webappbuilder from your one server and add this code inside the file init.js  : (after or instead of the original code. )

    //override language and orientation

//*********************************************

dojoConfig.locale = "he";

window._setRTL(dojoConfig.locale);

//*********************************************

TimWitt2
MVP Regular Contributor

Hey Deshe Organization

I tried adding this line but it won't work for me. The Webappbuilder loader just keeps loading. When I replace the "he" with "en" it works.

Any idea what I could be doing wrong?

Here is my code:

  if(allCookies.esri_auth){
      /*jshint -W061 */
      var userObj = eval('(' + unescape(allCookies.esri_auth)+ ')');
      if(userObj.culture){
        dojoConfig.locale = userObj.culture;
      }
    }
    if (allCookies.arcgisLocale) {
      dojoConfig.locale = allCookies.arcgisLocale.toLowerCase();
    }
    if (allCookies.wab_locale) {
      dojoConfig.locale = allCookies.wab_locale.toLowerCase();
    }
    if(!dojoConfig.locale){
      dojoConfig.locale = navigator.language ? navigator.language : navigator.userLanguage;
    }
    dojoConfig.locale = dojoConfig.locale.toLowerCase();
  dojoConfig.locale = "de";
    window._setRTL(dojoConfig.locale);


    var resources = [
      window.apiUrl + 'dojo/resources/dojo.css',
      window.apiUrl + 'dijit/themes/claro/claro.css',
      window.apiUrl + 'dojox/editor/plugins/resources/css/TextColor.css',
      window.apiUrl + 'dojox/editor/plugins/resources/editorPlugins.css',
      window.apiUrl + 'dojox/editor/plugins/resources/css/PasteFromWord.css',
      window.apiUrl + 'esri/css/esri.css',
      window.path + 'stemapp/jimu.js/css/jimu.css',
      window.path + 'builder/css/builder.css',
      window.path + 'builder/libs/ace/ace.js',
      window.path + 'builder/libs/thenBy.js'
    ];

Thanks,

Tim

0 Kudos
SPNIOrganization
Occasional Contributor

Hi Tim,

This is my code. I think the difference starts in line 17 in your code.

try to replace lines 17-18-19 with the part in Bold:

if(allCookies.esri_auth){

      /*jshint -W061 */

      var userObj = eval('(' + unescape(allCookies.esri_auth)+ ')');

      if(userObj.culture){

        dojoConfig.locale = userObj.culture;

      }

    }

    if(window.queryObject.mode){

      if(allCookies.wab_locale){

        dojoConfig.locale = allCookies.wab_locale;

      }

    }else{

      if(allCookies.wab_app_locale){

        dojoConfig.locale = allCookies.wab_app_locale;

      }

    }

    if(!dojoConfig.locale){

      dojoConfig.locale = navigator.language ? navigator.language : navigator.userLanguage;

    }

    dojoConfig.locale = dojoConfig.locale.toLowerCase();

    window._setRTL(dojoConfig.locale);

    //override language and orientation

    //*********************************************

    dojoConfig.locale = "he";

    window._setRTL(dojoConfig.locale);

    //*********************************************

    resources = resources.concat([

      window.apiUrl + 'dojo/resources/dojo.css',

      window.apiUrl + 'dijit/themes/claro/claro.css',

      window.apiUrl + 'esri/css/esri.css',

      window.apiUrl + 'dojox/layout/resources/ResizeHandle.css',

      window.path + 'jimu.js/css/jimu.css'

    ]);

0 Kudos
TimWitt2
MVP Regular Contributor

Deshe Organization

I tried this and changed it in the inis.js located at client\stemapp and client\builder

but the webappbuilder just keeps loading

Tim

0 Kudos
MajdiTurkman1
New Contributor III

Tim Witt wrote:

Deshe Organization

I tried this and changed it in the inis.js located at client\stemapp and client\builder

but the webappbuilder just keeps loading

Tim

I have the same problem. page keeps loading.

Did you get any solution? Tim Witt

0 Kudos
TimWitt2
MVP Regular Contributor

Majdi Turkman

I was never able to resolve it. Let me know if you should find a solution.

Tim

0 Kudos
Luiz_PauloLima
New Contributor

any solution tim ?

ty

0 Kudos
MajdiTurkman1
New Contributor III

I have followed the same solution but I'm getting the same result. The page keeps loading!

I'm trying to set the language to Arabic.

Any suggestions?

0 Kudos