Weather suggestions should respect regional locale preferences for C/F
Categories
(Firefox :: Address Bar, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox110 | --- | verified |
People
(Reporter: adw, Assigned: adw)
References
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
There's a checkbox in about:preferences labeled "Use your operating system settings for “{ $localeName }” to format dates, times, numbers, and measurements." (Seems like it might be visible only if some other locale setting doesn't match the system locale, maybe the preferred web page locale settings?)
AFAICT this pref applies to the app chrome and not (only?) web pages, so the weather suggestion UI should respect it and it should override Services.locale.appLocaleAsBCP47
, which is what the weather UI currently uses. The pref is exposed in the locale service API as regionalPrefsLocales.
Assignee | ||
Comment 1•2 years ago
|
||
This replaces Services.locale.appLocaleAsBCP47
with regionalPrefsLocales[0]
when determining the temperature unit to use for weather suggestions.
In summary, that means two things:
- When the language of the OS locale is the same as the language of the app's
locale, weather suggestions will use the OS locale. e.g., if your OS locale is
en-CA but your Firefox is en-US, weather will prefer en-CA since both locales
are English, and so temperatures will be shown in C. This is a change from the
current behavior, where they would be shown in F. - When the user checked the "Use your operating system settings..." checkbox in
about:preferences for unit formatting, weather suggestions will always use the
OS locale, regardless of the app locale.
This is due to how regionalPrefsLocales
works [1].
This revision also makes a couple of changes to code added in D166216:
- Instead of storing both C and F temperatures in the UrlbarResult payload,
store only the user's appropriate temperature. This allows the xcpshell test
(test_weather.js) to test locale behavior instead of having to do it in a
browser test, and there's no reason not to do it anyway. - Replace the hardcoded expected suggestion properties in test_weather.js with
the ones fromWEATHER_SUGGESTION
, as was the case before D166216.
[1] regionalPrefsLocales
is implemented here. If
intl.regional_prefs.use_os_locales
is true, regionalPrefsLocales
returns the
user's OS locales. The checkbox for this pref is visible only when the user's
primary OS locale doesn't match the app's primary locale. The full label for the
checkbox is here. The pref defaults to false.
If intl.regional_prefs.use_os_locales
is false, regionalPrefsLocales
returns
the OS locales only if the OS locale's language is the same as the app locale's
language. Otherwise it returns the app's locales.
In either case, if an error is encountered, the app's locales are returned.
Comment 3•2 years ago
|
||
bugherder |
Assignee | ||
Comment 4•2 years ago
|
||
STR for QA
Background
The temperature unit shown in weather suggestions depends on both the app locale and your OS locale, and en-US is treated differently from all other locales because the suggestions will use F instead of C.
If it's hard to test these combinations or it takes up a lot of your time, let me know and we can try something else or just not worry about it.
How to change the app locale
Please skip this section if you already know how to do this or have a better way.
- Install a lang pack for the desired locale: https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-central-l10n/linux-x86_64/xpi/ (should work on non-Linux systems too)
- Open the browser console and run:
Services.locale.requestedLocales = ["en-GB"]
(replace "en-GB" with the desired locale) - In the browser console run the following to verify the app locale has been changed:
Services.locale.appLocaleAsBCP47
How to enable weather suggestions
- Set
browser.urlbar.weather.featureGate
to true - Clicking in the urlbar should now show a weather suggestion as the first row
- If it doesn't appear, give Firefox a few seconds to fetch it, close the urlbar panel, and open it again
STR: OS = en-US, app = en-US
- Set your OS locale to en-US
- Set Firefox locale to en-US (Nightly is en-US by default I think)
- Trigger a weather suggestion and verify temperature is F
STR: OS = en-GB, app = en-US
- Set your OS locale to en-GB
- Set Firefox locale to en-US
- Trigger a weather suggestion and verify temperature is C (C should be used because the suggestion will prefer your en-GB OS locale in this case)
STR: OS = en-GB, app = en-GB
- Set your OS locale to en-GB
- Set Firefox locale to en-GB
- Trigger a weather suggestion and verify temperature is C
STR: OS = ro, app = en-US
- Set your OS locale to ro (or any other non-English locale)
- Set Firefox locale to en-US
- Trigger a weather suggestion and verify temperature is C
STR: OS = ro, app = ro
- Set your OS locale to ro (or any other non-English locale)
- Set Firefox locale to ro
- Trigger a weather suggestion and verify temperature is C
Comment 5•2 years ago
|
||
I have verified the scenarios from comment 4 on the latest Firefox Nightly 110.0a1 (Build ID: 20230116095316) on Windows 10 x64, macOS 12.4, and Ubuntu 20.04 x64.
- The temperature of the Weather result is displayed as F only if the user has the OS and locale set to en-US.
- The temperature of the Weather result is displayed as C if the user has the OS set to en-GB and locale set to en-US.
- The temperature of the Weather result is displayed as C if the user has the OS and locale set to en-GB.
- The temperature of the Weather result is displayed as F if the user has the OS set to es-ES* and locale set to en-US and the
intl.regional_prefs.use_os_locales
pref has its default value offalse
. In order to have the result displayed in C, we manually set the pref totrue
. - The temperature of the Weather result is displayed as C if the user has the OS and locale set to es-ES*.
*we used the es-ES region because there are no weather results displayed when using the Ro region.
Updated•1 year ago
|
Description
•