summaryrefslogtreecommitdiff
path: root/applets/clock
diff options
context:
space:
mode:
authorClement Lefebvre <[email protected]>2019-10-09 15:09:57 +0100
committerClement Lefebvre <[email protected]>2019-10-09 15:17:56 +0100
commit4d20a0003798eea253fed6ea8f02cec5da6ffb2d (patch)
tree7532fd34c1368129eb52fa7ac00216f8a1a7c926 /applets/clock
parentc50e4bd3aaf65a27a57df75d3141428ac6f686ec (diff)
downloadmate-panel-4d20a0003798eea253fed6ea8f02cec5da6ffb2d.tar.bz2
mate-panel-4d20a0003798eea253fed6ea8f02cec5da6ffb2d.tar.xz
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.
Diffstat (limited to 'applets/clock')
-rw-r--r--applets/clock/clock.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 7a4ba290..4ff19b55 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);