summaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
authorClement Lefebvre <[email protected]>2019-10-09 15:09:57 +0100
committerClement Lefebvre <[email protected]>2019-10-09 15:21:12 +0100
commit7a4458a5ff3314ddbbb7f58e6cb668039874a450 (patch)
tree30f9f16f43c89d1818ba28444738570f38d2dd99 /applets
parent0df8ecfacc8fb3ebef3d21316a75fe96d5a3e627 (diff)
downloadmate-panel-7a4458a5ff3314ddbbb7f58e6cb668039874a450.tar.bz2
mate-panel-7a4458a5ff3314ddbbb7f58e6cb668039874a450.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')
-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 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);