javanoob
javanoob

Reputation: 6412

How to change language settings of firefox using JavaScript?

How can i change the language settings of FireFox using JavaScript?

I want to set the "intl.accept_languages" to "fr".

It would be very nice if some one can post the code..

Upvotes: 0

Views: 1037

Answers (1)

Neil
Neil

Reputation: 55432

In Firefox 4 you can do this:

Components.untils.import("resource://gre/modules/Services.jsm");
Services.prefs.setCharPref("intl.accept_languages", "fr");

Note: this only works for ASCII preferences. See nsIPrefBranch for more details.

In previous versions of firefox you need to obtain the preference service manually, like this:

var rootPrefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
rootPrefs.setCharPref("intl.accept_languages", "fr");

Alternatively if you're writing an extension then you can include a default preference file which will override the installation default, although it won't override a user set preference.

Upvotes: 1

Related Questions