Closed Bug 1809201 Opened 1 year ago Closed 1 year ago

Weather suggestions should respect regional locale preferences for C/F

Categories

(Firefox :: Address Bar, defect, P2)

defect

Tracking

()

VERIFIED FIXED
110 Branch
Tracking Status
firefox110 --- verified

People

(Reporter: adw, Assigned: adw)

References

Details

Attachments

(1 file)

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.

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 from WEATHER_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.

Pushed by dwillcoxon@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/27d5e22e52df
Use regionalPrefsLocales for the weather suggestions temperature unit. r=nanj
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch

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.

  1. 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)
  2. Open the browser console and run: Services.locale.requestedLocales = ["en-GB"] (replace "en-GB" with the desired locale)
  3. In the browser console run the following to verify the app locale has been changed: Services.locale.appLocaleAsBCP47

How to enable weather suggestions

  1. Set browser.urlbar.weather.featureGate to true
  2. Clicking in the urlbar should now show a weather suggestion as the first row
  3. 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

  1. Set your OS locale to en-US
  2. Set Firefox locale to en-US (Nightly is en-US by default I think)
  3. Trigger a weather suggestion and verify temperature is F

STR: OS = en-GB, app = en-US

  1. Set your OS locale to en-GB
  2. Set Firefox locale to en-US
  3. 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

  1. Set your OS locale to en-GB
  2. Set Firefox locale to en-GB
  3. Trigger a weather suggestion and verify temperature is C

STR: OS = ro, app = en-US

  1. Set your OS locale to ro (or any other non-English locale)
  2. Set Firefox locale to en-US
  3. Trigger a weather suggestion and verify temperature is C

STR: OS = ro, app = ro

  1. Set your OS locale to ro (or any other non-English locale)
  2. Set Firefox locale to ro
  3. Trigger a weather suggestion and verify temperature is C
Flags: qe-verify+
Flags: in-testsuite+

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 of false. In order to have the result displayed in C, we manually set the pref to true.
  • 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.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Blocks: 1815018
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: