From 7a4458a5ff3314ddbbb7f58e6cb668039874a450 Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Wed, 9 Oct 2019 15:09:57 +0100 Subject: Fetch clock formats using LC_TIME (as opposed to LANGUAGE) This is a port of https://github.com/linuxmint/cinnamon-desktop/commit/7cd7c008e05acf36efd87446256d28a8b89d187a Which fixed https://github.com/linuxmint/cinnamon-desktop/pull/132 This commit fixes the same issue in the MATE clock applet. --- applets/clock/clock.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/applets/clock/clock.c b/applets/clock/clock.c index b752099a..3d462a9a 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -426,6 +426,18 @@ get_updated_timeformat (ClockData *cd) const char *time_format; const char *date_format; char *clock_format; + const gchar *env_language; + const gchar *env_lc_time; + + /* Override LANGUAGE with the LC_TIME environment variable + * This is needed for gettext to fetch our clock format + * according to LC_TIME, and not according to the DE LANGUAGE. + */ + env_language = g_getenv("LANGUAGE"); + env_lc_time = g_getenv("LC_TIME"); + if (env_language != NULL && env_lc_time != NULL && env_language != env_lc_time) { + g_setenv("LANGUAGE", env_lc_time, TRUE); + } if (cd->format == CLOCK_FORMAT_12) /* Translators: This is a strftime format string. @@ -467,6 +479,11 @@ get_updated_timeformat (ClockData *cd) time_format); } + /* Set back LANGUAGE the way it was before */ + if (env_language != NULL && env_lc_time != NULL && env_language != env_lc_time) { + g_setenv("LANGUAGE", env_language, TRUE); + } + result = g_locale_from_utf8 (clock_format, -1, NULL, NULL, NULL); g_free (clock_format); -- cgit v1.2.1