为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

How do I install a language XPI globally and make it the default language?

  • 4 个回答
  • 12 人有此问题
  • 1 次查看
  • 最后回复者为 cor-el

more options

I am using Firefox on unices and various Linux distributions (the less common ones). Installing Firefox is easy, but it is always in English. I get most of my interfaces (gnome, libreoffice, gimp, etc) in my preferred translation simply by setting the proper locale (export LANG=xy_XY.UTF-8) before starting Xorg. I found and downloaded my preferred language pack for firefox, which comes in an XPI archive. Opening that XPI file in Firefox (via an URL of file:///path/to/file/langpack.xpi) works smoothly, the translation gets installed under the user's own profile and it shows up in the add-ons (under the new category: Languages). Unfortunately, I still see no way in Firefox preferences to set this added translation as the default. Firefox still starts with the English interface. On SeaMonkey, there is a combobox on the Appearance panel that allows me to select the language of the interface from the list of installed/available languages. I cannot find such option on the panels of Firefox. So far, I had to install a language-changer add-on to be able to set the interface to my native locale. Even though my users never need to switch to any other locales. Q1., Once a language xpi is installed, how do I set the interface to use that language? Q2., How do I install the language xpi and make it the system-wide default, so that all my users see Firefox starting with the native (non-English) interface? I found a handful of description for Q2, but they appear to be outdated and do not work. These include the -install-global-extension argument to Firefox, placing the xpi file as it was downloaded into the "extensions" folder, placing the xpi file renamed to the extension ID into the "extensions" folder, unzipping the contents of the xpi into a subfolder of the "extensions" folder named as the extension ID. Please note, these attempts might have failed because I placed the extension NOT where it was supposed to go. The instructions refer to the global extension folder as <installation folder>/extensions, but on my system no such folder exists. Firefox seems to get installed into /usr/local/lib/firefox and there is no "extensions" subfolder there in. However, there is a "browser/extensions" subfolder, but placing my XPI there did not trigger any effect. Also, I manually created the "extensions" subfolder in /usr/local/lib/firefox and moved the xpi there (on various names, unzipped and in a whole) without the expected result. Any suggestion is very much appreciated! My goal is to install the firefox package, then run something from the command line resulting the non-English translation in the downloaded XPI becoming the system-wide default for all users. A step forward would be to know for certain where that "extensions" folder must be on my specific OS. How do I query that?

I am using Firefox on unices and various Linux distributions (the less common ones). Installing Firefox is easy, but it is always in English. I get most of my interfaces (gnome, libreoffice, gimp, etc) in my preferred translation simply by setting the proper locale (export LANG=xy_XY.UTF-8) before starting Xorg. I found and downloaded my preferred language pack for firefox, which comes in an XPI archive. Opening that XPI file in Firefox (via an URL of file:///path/to/file/langpack.xpi) works smoothly, the translation gets installed under the user's own profile and it shows up in the add-ons (under the new category: Languages). Unfortunately, I still see no way in Firefox preferences to set this added translation as the default. Firefox still starts with the English interface. On SeaMonkey, there is a combobox on the Appearance panel that allows me to select the language of the interface from the list of installed/available languages. I cannot find such option on the panels of Firefox. So far, I had to install a language-changer add-on to be able to set the interface to my native locale. Even though my users never need to switch to any other locales. Q1., Once a language xpi is installed, how do I set the interface to use that language? Q2., How do I install the language xpi and make it the system-wide default, so that all my users see Firefox starting with the native (non-English) interface? I found a handful of description for Q2, but they appear to be outdated and do not work. These include the -install-global-extension argument to Firefox, placing the xpi file as it was downloaded into the "extensions" folder, placing the xpi file renamed to the extension ID into the "extensions" folder, unzipping the contents of the xpi into a subfolder of the "extensions" folder named as the extension ID. Please note, these attempts might have failed because I placed the extension NOT where it was supposed to go. The instructions refer to the global extension folder as <installation folder>/extensions, but on my system no such folder exists. Firefox seems to get installed into /usr/local/lib/firefox and there is no "extensions" subfolder there in. However, there is a "browser/extensions" subfolder, but placing my XPI there did not trigger any effect. Also, I manually created the "extensions" subfolder in /usr/local/lib/firefox and moved the xpi there (on various names, unzipped and in a whole) without the expected result. Any suggestion is very much appreciated! My goal is to install the firefox package, then run something from the command line resulting the non-English translation in the downloaded XPI becoming the system-wide default for all users. A step forward would be to know for certain where that "extensions" folder must be on my specific OS. How do I query that?

所有回复 (4)

more options

1. The extension must be renamed to its extension ID. This information is in the install.rdf file, which can be opened with a text editor. Look for the em:id line. For example, the French language pack is originally named fr.xpi but it must be renamed to langpack-fr@firefox.mozilla.org.xpi

2. <installation folder>/browser/extensions is the correct location.

3. Users will have to confirm the add-on installation.

4. You can switch the browser language by changing the general.useragent.locale preference. Lock this preference to switch the language for all users. Note that although language packs are restartless extensions, Firefox will probably have to be restarted once for the UI language change to take full effect.

more options

You can create a /distribution/bundles folder in the Firefox installation folder and install the language pack(s) in that folder.
That way they are available for all profiles that are started via this application.

I'm using this method myself to have some language packs available for testing.

This may only work if you use the en-US Firefox version. You need to create a folder with the GUID of the extension as specified in the install.rdf file and extract the content of the file language XPI file to this folder. You can install the language pack yourself in a profile to get the correct folder name to be used in the /distribution/bundles folder and extract its content to this folder. You need to update the language packs yourself when Firefox updates, as Firefox can't do this.

See also:

  • /questions/979577 I m trying to have language pack enabled by default for any new profile in firefox 25
  • /questions/983367 How can I make general.useragent.locale variable

Extensions installed this way aren't visible in the Add-on manager.

由cor-el于修改

more options

Excellent. These guides got me as far as installing my preferred language pack, which gets added to the add-ons automatically (assuming the user says yes to the appearing question when Firefox is started). However, the GUI does not change unless the user enters "about:config" and changes the locale.

Is there a way to do this from the command line? I mean, changing the locale settings. And preferrably for all users. So even when new users get added and they start Firefox the first time, they see it appearing with the preferred locale and not in English.

more options

You can lock the general.useragent.locale pref to a specific locale if you want to force users the use this locale.

lockPref("general.useragent.locale", "en-US");

The mozilla.cfg file is located in the Firefox program folder and has effect for all users and all Firefox profiles that are started via this Firefox program folder.


Use a mozilla.cfg file in the Firefox program folder to lock prefs or specify new (default) values.

Place a file local-settings.js in the defaults\pref folder where you also find the file channel-prefs.js to specify using mozilla.cfg.

pref("general.config.filename", "mozilla.cfg");

These functions can be used in the mozilla.cfg file:

defaultPref();  // set new default value
pref();         // set pref, but allow changes in current session
lockPref();     // lock pref, disallow changes

See: