system/region: Preview measurement format in current locale

The Formats preview tries to find the measurement format of the locale
to preview, and then displays it. However, it displays the text in the
default locale, instead of in the real current locale, as newlocale ()
with base = (locale_t) 0 will use the default locale.

This is fixed by switching back to the real locale before setting the
label text.

Fixes #2458

Part-of: <https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2051>
This commit is contained in:
velsinki 2023-11-21 20:36:21 +01:00 committed by Marge Bot
parent 018a56aa83
commit 7f79356ded

View file

@ -133,16 +133,18 @@ update_format_examples (CcFormatPreview *self)
old_locale = uselocale (locale);
fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
if (fmt && *fmt == 2)
gtk_label_set_text (GTK_LABEL (self->measurement_format_label), C_("measurement format", "Imperial"));
else
gtk_label_set_text (GTK_LABEL (self->measurement_format_label), C_("measurement format", "Metric"));
if (locale != (locale_t) 0)
{
uselocale (old_locale);
freelocale (locale);
}
if (fmt && *fmt == 2)
gtk_label_set_text (GTK_LABEL (self->measurement_format_label), C_("measurement format", "Imperial"));
else
gtk_label_set_text (GTK_LABEL (self->measurement_format_label), C_("measurement format", "Metric"));
#endif
#ifdef LC_PAPER