Join the Mozilla’s Test Days event from 9–15 Jan to test the new Firefox address bar on Firefox Beta 135 and get a chance to win Mozilla swag vouchers! 🎁

搜索 | 用户支持

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

详细了解

Trouble using firefox.cfg with JS in ubuntu18

  • 6 个回答
  • 1 人有此问题
  • 19 次查看
  • 最后回复者为 ito-matsuda

more options

I'm setting up Firefox 78.6.1esr in an image and want it to start in French or English given the environment variable (lang or language or otherwise) and I'm having trouble doing so.

I installed the correct French Language pack from http://releases.mozilla.org/pub/firefox/releases/78.6.1esr/linux-x86_64/xpi/ and it is now recognized by Firefox as a valid add-on.

I have `autoconfig.js` in the /distribution/extensions/ directory as well as `firefox.cfg` in the base folder. If in the cfg file I just have ``` // IMPORTANT: code begins next line. pref("intl.locale.requested","fr") ```

It works fine but the moment I try and use something like `getenv(LANG)` suddenly the error appears "Failed to read configuration file" pops up when I try to start Firefox. My understanding was that the cfg was treated like a JS file per https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig but I can't seem to get any JS to run nicely.

Something like the following would be nice // next line const langvar = getenv(LANG); pref("intl.locale.requested", langvar);

would be ideal but I'm missing something.

Any help is greatly appreciated!

I'm setting up Firefox 78.6.1esr in an image and want it to start in French or English given the environment variable (lang or language or otherwise) and I'm having trouble doing so. I installed the correct French Language pack from http://releases.mozilla.org/pub/firefox/releases/78.6.1esr/linux-x86_64/xpi/ and it is now recognized by Firefox as a valid add-on. I have `autoconfig.js` in the /distribution/extensions/ directory as well as `firefox.cfg` in the base folder. If in the cfg file I just have ``` // IMPORTANT: code begins next line. pref("intl.locale.requested","fr") ``` It works fine but the moment I try and use something like `getenv(LANG)` suddenly the error appears "Failed to read configuration file" pops up when I try to start Firefox. My understanding was that the cfg was treated like a JS file per https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig but I can't seem to get any JS to run nicely. Something like the following would be nice // next line const langvar = getenv(LANG); pref("intl.locale.requested", langvar); would be ideal but I'm missing something. Any help is greatly appreciated!

被采纳的解决方案

Thanks for the link. I guess it's something special for Autoconfig and not a general Firefox function. I wasn't aware of that.

In the example, the variable name is quoted, so for your script, it would be

const langvar = getenv("LANG");

Does that make any difference?

定位到答案原位置 👍 1

所有回复 (6)

more options

If you enable the Browser Console command line, what does `getenv(LANG)` return there? It's not defined on mine (en-US build, not multilingual in any way).

https://developer.mozilla.org/en-US/docs/Tools/Browser_Console#Browser_Console_command_line

more options

Trying that I get not defined.

more options

I know from the bottom of the Help > Troubleshooting information page that Firefox does gather locale information from the system, but I don't know what function to run to collect that in your script. I think that's the rabbit hole you need to find and head down.

more options

From the functions of "AutoConfig" area in the page, it does say that the functions are available from within an AutoConfig file.

It's weird that the page https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig#firefox-enterprise:linux: even shows usage of `getenv` as well. As an aside, I don't know what kind of JS I was writing but at least I have ``` // extra var user = "fr.randomtext"; pref("intl.locale.requested", user.substring(0,2)); ``` working which for some reason I thought was not working.

Thanks for your help and please do post again if you think of anything else.

more options

选择的解决方案

Thanks for the link. I guess it's something special for Autoconfig and not a general Firefox function. I wasn't aware of that.

In the example, the variable name is quoted, so for your script, it would be

const langvar = getenv("LANG");

Does that make any difference?

more options

I can't believe I missed that. Thanks so much I must have glazed over the quotation marks.