event-editor/schedule-section: Fix localization mix
The gcal_util_translate_time_string function is a plain copy of gnome-shells shell_util_translate_time_string solving the same problem. Fixes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/581
This commit is contained in:
@@ -235,7 +235,7 @@ format_datetime_for_display (GDateTime *date,
|
|||||||
{
|
{
|
||||||
case -7 ... -2:
|
case -7 ... -2:
|
||||||
/* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */
|
/* 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;
|
break;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
@@ -252,7 +252,7 @@ format_datetime_for_display (GDateTime *date,
|
|||||||
|
|
||||||
case 2 ... 7:
|
case 2 ... 7:
|
||||||
/* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */
|
/* 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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1325,3 +1325,38 @@ gcal_utils_ask_recurrence_modification_type (GtkWidget *parent,
|
|||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (dialog));
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -135,4 +135,6 @@ void gcal_utils_ask_recurrence_modification_type (GtkWidget
|
|||||||
GcalAskRecurrenceCallback callback,
|
GcalAskRecurrenceCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
const gchar * gcal_util_translate_time_string (const gchar *str);
|
||||||
|
|
||||||
#endif /* __GCAL_UTILS_H__ */
|
#endif /* __GCAL_UTILS_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user