diff --git a/src/gui/event-editor/gcal-schedule-section.c b/src/gui/event-editor/gcal-schedule-section.c index 4a20eb2c..7f13d9a7 100644 --- a/src/gui/event-editor/gcal-schedule-section.c +++ b/src/gui/event-editor/gcal-schedule-section.c @@ -235,7 +235,7 @@ format_datetime_for_display (GDateTime *date, { case -7 ... -2: /* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ - formatted_date = g_date_time_format (local_dt, _("Last %A")); + formatted_date = g_date_time_format (local_dt, gcal_util_translate_time_string (_("Last %A"))); break; case -1: @@ -252,7 +252,7 @@ format_datetime_for_display (GDateTime *date, case 2 ... 7: /* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ - formatted_date = g_date_time_format (local_dt, _("This %A")); + formatted_date = g_date_time_format (local_dt, gcal_util_translate_time_string (_("This %A"))); break; default: diff --git a/src/utils/gcal-utils.c b/src/utils/gcal-utils.c index 1b253dcf..044a0158 100644 --- a/src/utils/gcal-utils.c +++ b/src/utils/gcal-utils.c @@ -1325,3 +1325,38 @@ gcal_utils_ask_recurrence_modification_type (GtkWidget *parent, gtk_window_present (GTK_WINDOW (dialog)); } + +/** + * gcal_util_translate_time_string: + * @str: String to translate + * + * Translate @str according to the locale defined by LC_TIME; unlike + * dcgettext(), the translations is still taken from the LC_MESSAGES + * catalogue and not the LC_TIME one. + * + * Returns: the translated string + */ +const gchar * +gcal_util_translate_time_string (const gchar *str) +{ + const gchar *locale = g_getenv ("LC_TIME"); + const gchar *res; + gchar *sep; + locale_t old_loc; + locale_t loc = (locale_t) 0; + + if (locale) + loc = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0); + + old_loc = uselocale (loc); + + sep = strchr (str, '\004'); + res = g_dpgettext (NULL, str, sep ? sep - str + 1 : 0); + + uselocale (old_loc); + + if (loc != (locale_t) 0) + freelocale (loc); + + return res; +} diff --git a/src/utils/gcal-utils.h b/src/utils/gcal-utils.h index 42931afc..11392be1 100644 --- a/src/utils/gcal-utils.h +++ b/src/utils/gcal-utils.h @@ -135,4 +135,6 @@ void gcal_utils_ask_recurrence_modification_type (GtkWidget GcalAskRecurrenceCallback callback, gpointer user_data); +const gchar * gcal_util_translate_time_string (const gchar *str); + #endif /* __GCAL_UTILS_H__ */