Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

Trouble using firefox.cfg with JS in ubuntu18

  • 6 trả lời
  • 1 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi 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!

Giải pháp được chọn

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?

Đọc câu trả lời này trong ngữ cảnh 👍 1

Tất cả các câu trả lời (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

Giải pháp được chọn

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.