Trouble using firefox.cfg with JS in ubuntu18
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 👍 1Tất cả các câu trả lời (6)
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
Trying that I get not defined.
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.
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.
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?
I can't believe I missed that. Thanks so much I must have glazed over the quotation marks.