diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2021-11-12 13:44:51 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2021-11-12 14:06:11 +0000 |
commit | 1c140fc8ce08260d5008847945bf345654ad7fa8 (patch) | |
tree | 14ce7d7538d24758b3894df6b864cc970cb2f4a2 /libgweather | |
parent | 05cb6f606f1c98c47a062cb0b865bae5178365a0 (diff) | |
download | libgweather-1c140fc8ce08260d5008847945bf345654ad7fa8.tar.gz |
Clean up the metric/imperial unit detection
Move the fallback declaration outside the nl_langinfo() query, and use a
more descriptive message in case of localisation error.
Diffstat (limited to 'libgweather')
-rw-r--r-- | libgweather/gweather-weather.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c index 6b2c882..3135866 100644 --- a/libgweather/gweather-weather.c +++ b/libgweather/gweather-weather.c @@ -852,17 +852,8 @@ gweather_info_get_conditions (GWeatherInfo *info) static gboolean is_locale_metric (void) { - /* Translate to the default units to use for presenting - * lengths to the user. Translate to default:inch if you - * want inches, otherwise translate to default:mm. - * Do *not* translate it to "predefinito:mm", if it - * it isn't default:mm or default:inch it will not work - */ - gchar *e = _ ("default:mm"); - #ifdef HAVE__NL_MEASUREMENT_MEASUREMENT - const char *fmt; - fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT); + const char *fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT); if (fmt && *fmt == 2) return FALSE; @@ -870,12 +861,24 @@ is_locale_metric (void) return TRUE; #endif + /* Translate to the default units to use for presenting + * lengths to the user. Translate to default:inch if you + * want inches, otherwise translate to default:mm. + * Do *not* translate it to "predefinito:mm", if it + * it isn't default:mm or default:inch it will not work + */ + const char *e = _ ("default:mm"); + if (strcmp (e, "default:inch") == 0) return FALSE; - else if (strcmp (e, "default:mm")) - g_warning ("Whoever translated default:mm did so wrongly.\n"); - - return TRUE; + else if (strcmp (e, "default:mm") == 1) + return TRUE; + else { + g_warning ("Wrong translation for libgweather; please file " + "file an issue at: https://gitlab.gnome.org/GNOME/libgweather/issues/new " + "and make sure to include your locale and language"); + return TRUE; + } } /** |