From 62a5f27626e97c923c815b2dc846bc09a71055d0 Mon Sep 17 00:00:00 2001 From: Theppitak Karoonboonyanan Date: Mon, 21 Apr 2014 18:30:40 +0700 Subject: [PATCH] Distinguish AM/PM hours in fuzzy clock for L10N In some languages such as Thai, AM and PM hours are called differently. So, add context to them for translation. https://bugzilla.xfce.org/show_bug.cgi?id=10311 Signed-off-by: Theppitak Karoonboonyanan --- plugins/clock/clock-fuzzy.c | 50 ++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/plugins/clock/clock-fuzzy.c b/plugins/clock/clock-fuzzy.c index 7b0aa41..d0c2f7a 100644 --- a/plugins/clock/clock-fuzzy.c +++ b/plugins/clock/clock-fuzzy.c @@ -133,20 +133,38 @@ static const gchar *i18n_hour_sectors_one[] = /* xgettext:no-c-format */ NC_("one", "%1 o'clock") }; -static const gchar *i18n_hour_names[] = +static const gchar *i18n_hour_am_names[] = { - N_("one"), - N_("two"), - N_("three"), - N_("four"), - N_("five"), - N_("six"), - N_("seven"), - N_("eight"), - N_("nine"), - N_("ten"), - N_("eleven"), - N_("twelve") + NC_("am", "one"), + NC_("am", "two"), + NC_("am", "three"), + NC_("am", "four"), + NC_("am", "five"), + NC_("am", "six"), + NC_("am", "seven"), + NC_("am", "eight"), + NC_("am", "nine"), + NC_("am", "ten"), + NC_("am", "eleven"), + /* I18N: 12 AM is midnight */ + NC_("am", "twelve") +}; + +static const gchar *i18n_hour_pm_names[] = +{ + NC_("pm", "one"), + NC_("pm", "two"), + NC_("pm", "three"), + NC_("pm", "four"), + NC_("pm", "five"), + NC_("pm", "six"), + NC_("pm", "seven"), + NC_("pm", "eight"), + NC_("pm", "nine"), + NC_("pm", "ten"), + NC_("pm", "eleven"), + /* I18N: 12 PM is noon */ + NC_("pm", "twelve") }; @@ -284,6 +302,7 @@ xfce_clock_fuzzy_update (XfceClockFuzzy *fuzzy, const gchar *time_format; gchar *p; gchar pattern[3]; + gboolean is_pm; panel_return_val_if_fail (XFCE_CLOCK_IS_FUZZY (fuzzy), FALSE); @@ -319,6 +338,7 @@ xfce_clock_fuzzy_update (XfceClockFuzzy *fuzzy, if (G_LIKELY (p != NULL)) hour += g_ascii_digit_value (*(p + 1)); + is_pm = (hour >= 12 && hour != 24); if (hour % 12 > 0) hour = hour % 12 - 1; else @@ -336,7 +356,9 @@ xfce_clock_fuzzy_update (XfceClockFuzzy *fuzzy, /* replace the %? with the hour name */ g_snprintf (pattern, sizeof (pattern), "%%%c", p != NULL ? *(p + 1) : '0'); - string = exo_str_replace (time_format, pattern, _(i18n_hour_names[hour])); + string = exo_str_replace (time_format, pattern, + is_pm ? g_dpgettext2 (NULL, "pm", i18n_hour_pm_names[hour]) + : g_dpgettext2 (NULL, "am", i18n_hour_am_names[hour])); gtk_label_set_text (GTK_LABEL (fuzzy), string); g_free (string); } -- 1.9.2