X
Tap here to go to the mobile version of the site.

Support Forum

How can I make general.useragent.locale variable

Posted

In our domain we have different user languages. Windows adapts it's gui depending on the username they login with. We have configured Firefox settings through GPO's and build a pakcage with the FF GPO add-in included, with also the 5 different language packs included we use in our domain. We can switch manually the GUI language, but we are looking for a way to automate this, depending on the profile language. I know we can change the user.js file, but I was wondering if there is a way to automate this through GPO's. Something like a variable we can place in the general.useragent.locale that looks for the sytem language? Or another way to automate this?

In our domain we have different user languages. Windows adapts it's gui depending on the username they login with. We have configured Firefox settings through GPO's and build a pakcage with the FF GPO add-in included, with also the 5 different language packs included we use in our domain. We can switch manually the GUI language, but we are looking for a way to automate this, depending on the profile language. I know we can change the user.js file, but I was wondering if there is a way to automate this through GPO's. Something like a variable we can place in the general.useragent.locale that looks for the sytem language? Or another way to automate this?

Additional System Details

Installed Plug-ins

  • Shockwave Flash 11.9 r900
  • Next Generation Java Plug-in 1.6.0_45 for Mozilla browsers
  • NPRuntime Script Plug-in Library for Java(TM) Deploy
  • The plugin allows you to have a better experience with Microsoft Lync
  • Adobe PDF Plug-In For Firefox and Netscape 11.0.05
  • 5.1.20913.0
  • The plug-in allows you to open and edit files using Microsoft Office applications
  • Office Authorization plug-in for NPAPI browsers

Application

  • User Agent: Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0

More Information

configuration:
1 dc Windows 2008R2 with firefox.adm imported in GP manager
multiple clients computers Windows XP
multiple profiles with language linked to it

cor-el
  • Top 10 Contributor
  • Moderator
17415 solutions 157329 answers

You should be able to do this via a mozilla.cfg autoconfig file.

This file is run as JavaScript with full chrome privileges and can contain more advanced code, so you should be able to check the system language and set general.useragent.locale accordingly.

I don't know how to get the system language setting, but you should be able to read registry keys and environment variables if necessary.

You should be able to do this via a mozilla.cfg autoconfig file. This file is run as JavaScript with full chrome privileges and can contain more advanced code, so you should be able to check the system language and set general.useragent.locale accordingly. *http://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/ *http://mike.kaply.com/2012/03/22/customizing-firefox-advanced-autoconfig-files/ I don't know how to get the system language setting, but you should be able to read registry keys and environment variables if necessary.

Question owner

Thanks for your quick response I configured the mozilla.cfg file, although wasn't able to set the variable here.

I tried adding but this did not work: var languagesetting = window.navigator.language; lockPref("general.useragent.locale", languagesetting);

Seems like the command 'window.navigator.language' is not recognised, nor is window.navigator.userLanguage

Do you have any idea how I can set this?

Thanks for your quick response I configured the mozilla.cfg file, although wasn't able to set the variable here. I tried adding but this did not work: var languagesetting = window.navigator.language; lockPref("general.useragent.locale", languagesetting); Seems like the command 'window.navigator.language' is not recognised, nor is window.navigator.userLanguage Do you have any idea how I can set this?
cor-el
  • Top 10 Contributor
  • Moderator
17415 solutions 157329 answers

There is no window defined when Firefox is running the code in mozilla.cfg and anyway you would have to use other code to reference to a browser window.

You can try this code:

locale = Cc["@mozilla.org/chrome/chrome-registry;1"] .getService(Components.interfaces.nsIXULChromeRegistry).getSelectedLocale("global");

lockPref("general.useragent.locale", locale);
There is no window defined when Firefox is running the code in mozilla.cfg and anyway you would have to use other code to reference to a browser window. You can try this code: <pre><nowiki>locale = Cc["@mozilla.org/chrome/chrome-registry;1"] .getService(Components.interfaces.nsIXULChromeRegistry).getSelectedLocale("global"); lockPref("general.useragent.locale", locale); </nowiki></pre> *http://mxr.mozilla.org/mozilla-central/source/uriloader/exthandler/nsHandlerService.js#152

Modified by cor-el