Closed Bug 1106563 Opened 10 years ago Closed 10 years ago

getPreferedLocales returns [ "en-us", "chrome://global/locale/intl.properties" ]

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1114712

People

(Reporter: xefbfbd, Unassigned)

Details

Attachments

(2 files)

7.29 KB, application/octet-stream
Details
13.16 KB, application/x-xpinstall
Details
Steps to reproduce: cfx run Actual results: ================================ >> prefs.isSet(intl.accept_languages): false >> prefs.get(intl.accept_languages): chrome://global/locale/intl.properties >> prefs.getLocalized(intl.accept_languages): en-US, en >> getPreferedLocales(): Array ["en-us","chrome://global/locale/intl.properties"] -------------------------------- after prefs.set(intl.accept_languages, "fr,jp") >> prefs.isSet(intl.accept_languages): true >> prefs.get(intl.accept_languages): fr,jp >> prefs.getLocalized(intl.accept_languages): fr,jp >> getPreferedLocales(): Array ["en-us","fr","jp"] -------------------------------- after prefs.reset(intl.accept_languages) >> prefs.isSet(intl.accept_languages): false >> prefs.get(intl.accept_languages): chrome://global/locale/intl.properties >> prefs.getLocalized(intl.accept_languages): en-US, en >> getPreferedLocales(): Array ["en-us","chrome://global/locale/intl.properties"] ================================ Expected results: ================================ >> prefs.isSet(intl.accept_languages): false >> prefs.get(intl.accept_languages): chrome://global/locale/intl.properties >> prefs.getLocalized(intl.accept_languages): en-US, en >> getPreferedLocales(): Array ["en-us","en-US","en"] -------------------------------- after prefs.set(intl.accept_languages, "fr,jp") >> prefs.isSet(intl.accept_languages): true >> prefs.get(intl.accept_languages): fr,jp >> prefs.getLocalized(intl.accept_languages): fr,jp >> getPreferedLocales(): Array ["en-us","fr","jp"] -------------------------------- after prefs.reset(intl.accept_languages) >> prefs.isSet(intl.accept_languages): false >> prefs.get(intl.accept_languages): chrome://global/locale/intl.properties >> prefs.getLocalized(intl.accept_languages): en-US, en >> getPreferedLocales(): Array ["en-us","en-US","en"] ================================
Attached file testcase
generated xpi by cfx
The default value of "intl.accept_languages" is "chrome://global/locale/intl.properties" So we should use nsIPrefLocalizedString to read its localized value, like these: http://mxr.mozilla.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1564 > locale = gPrefService.getComplexValue("intl.accept_languages", > Ci.nsIPrefLocalizedString).data; http://mxr.mozilla.org/mozilla-central/source/dom/base/Navigator.cpp#381 > const nsAdoptingString& acceptLang = > Preferences::GetLocalizedString("intl.accept_languages"); http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#1870 > let defaultAccept = defaultBranch.getComplexValue("intl.accept_languages", > Ci.nsIPrefLocalizedString).data; But getPreferedLocales is using prefs.get(PREF_ACCEPT_LANGUAGES, "") now https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/l10n/locale.js#L53 change this to prefs.getLocalized(PREF_ACCEPT_LANGUAGES, "") should fix it
Sorry, I made a mistake The expected results should be: ================================ >> prefs.isSet(intl.accept_languages): false >> prefs.get(intl.accept_languages): chrome://global/locale/intl.properties >> prefs.getLocalized(intl.accept_languages): en-US, en >> getPreferedLocales(): Array ["en-us","en"] -------------------------------- after prefs.set(intl.accept_languages, "fr,jp") >> prefs.isSet(intl.accept_languages): true >> prefs.get(intl.accept_languages): fr,jp >> prefs.getLocalized(intl.accept_languages): fr,jp >> getPreferedLocales(): Array ["en-us","fr","jp"] -------------------------------- after prefs.reset(intl.accept_languages) >> prefs.isSet(intl.accept_languages): false >> prefs.get(intl.accept_languages): chrome://global/locale/intl.properties >> prefs.getLocalized(intl.accept_languages): en-US, en >> getPreferedLocales(): Array ["en-us","en"] ================================ Also, you might need to create/set "extensions.sdk.console.logLevel" = "info" in about:config in order to see logged messages in browser console after install that generated xpi
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: