After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695873 - Get the default temperature unit from the locale
Get the default temperature unit from the locale
Status: RESOLVED FIXED
Product: libgweather
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: future
Assigned To: libgweather-maint
libgweather-maint
: 696957 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-14 18:16 UTC by Bastien Nocera
Modified: 2013-09-22 10:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Get the default temperature unit from the locale (2.76 KB, patch)
2013-03-14 18:16 UTC, Bastien Nocera
needs-work Details | Review
GWeatherInfo: don't use LC_MESSAGES for default measure units (11.08 KB, patch)
2013-03-26 15:44 UTC, Giovanni Campagna
committed Details | Review

Description Bastien Nocera 2013-03-14 18:16:45 UTC
LC_ALL=en_GB.UTF-8 gnome-weather
shows the temperatures in centigrade
LC_ALL=en_US.UTF-8 gnome-weather
shows the temperature in Fahrenheit

If the locale is unknown, centigrade is the new default.
Comment 1 Bastien Nocera 2013-03-14 18:16:47 UTC
Created attachment 238919 [details] [review]
Get the default temperature unit from the locale

Instead of defaulting to Fahrenheit which is barely used across the
world (Americans and old Brits, really...).
Comment 2 Giovanni Campagna 2013-03-14 18:19:26 UTC
Review of attachment 238919 [details] [review]:

No. The default should be handled by GSettings already.
Comment 3 Bastien Nocera 2013-03-14 18:28:55 UTC
The problem is that if the locale isn't translated, they'll end up with fahrenheit, which is completely useless as it's only used in a few places (from http://en.wikipedia.org/wiki/Fahrenheit#Usage):
"Fahrenheit is used in the United States, Belize, Palau and the United States territories of Puerto Rico, Guam and the U.S. Virgin Islands[6] for everyday applications."

Changing the default to automatically use the locale data (while keeping it translatable) means that we can override the locale's preferred unit (metric system but fahrenheit used, we can support that!), and we still fall back on the locale data, and if the locale doesn't include that data, fall back on celsius which is the most likely to be right.
Comment 4 Giovanni Campagna 2013-03-15 21:52:02 UTC
There is one problem with this patch: it creates an inconsistency wrt LC_MESSAGES vs LC_TIME/NUMERIC/FORMAT, as GSettings uses messages, but nl_langinfo uses the right locale category.
Now, ideally we would tell GSettings to do the right thing, but that's not possible with the current gettext infrastructure: autopoint and intltoolize are hardwired to generate LC_MESSAGES po files.
Alternatively, we can remove the GSettings translation and use nl_langinfo consistently. The downside is that for example for wind speed and pressure it is not a metric vs imperial dichotomy.

In either case, this needs to be applied consistently to all units: temperature, speed, distance and pressure.
Comment 5 Giovanni Campagna 2013-03-26 15:44:59 UTC
Created attachment 239874 [details] [review]
GWeatherInfo: don't use LC_MESSAGES for default measure units

GSettings translation uses gettext, which uses LC_MESSAGES, instead of
the appropriate LC_MEASUREMENT category.
To get that, we need to use nl_langinfo. The downside is that it only
offers metric or imperial, rather than having more finegrained defaults
for different countries.
The choices implemented are Farenheit / miles / knots / inchHg for imperial,
and Celsius / meters / km/h / mmHg for metric.

For the sake of discussion, this is how it would look like to use
nl_langinfo exclusively.
Comment 6 Bastien Nocera 2013-03-26 16:10:45 UTC
Review of attachment 239874 [details] [review]:

Yep, that's much better than what we had before in my opinion.
Comment 7 Giovanni Campagna 2013-04-02 14:22:11 UTC
Attachment 239874 [details] pushed as c9383cd - GWeatherInfo: don't use LC_MESSAGES for default measure units
Comment 8 Giovanni Campagna 2013-04-02 14:24:20 UTC
*** Bug 696957 has been marked as a duplicate of this bug. ***