From e0cf91771a5ff16979ea71171f2c3d0960657bb6 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 2 Dec 2010 16:24:42 +0100 Subject: Localize few strings with ngettext Per request of bug #635414 --- e-util/e-datetime-format.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index f5155be612..39f0e36e0f 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -212,8 +212,10 @@ format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, cons res = g_strdup (_("Yesterday")); } else { if (future) { - /* Translators: %a is a strftime modifier, the abbreviated week day name, for example "Next Tue" */ - res = g_strdup (_("Next %a")); + /* Translators: %a is a strftime modifier, the abbreviated week day name, for example "Next Tue". + ngettext is used to be able to define different translations for different days of week, where + necessary. Index is between 1 and 7 inclusive, meaning 1 .. Monday, 2 .. Tuesday, ..., 7 .. Sunday */ + res = g_strdup (ngettext ("Next %a", "Next %a", g_date_get_weekday (&val))); } else { res = g_strdup ("%a"); } -- cgit v1.2.3 From a3ba231fcc2746e664a67c85d88eb49a64813989 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 9 Nov 2010 08:48:33 -0500 Subject: Drop backward-compatibility cruft. --- e-util/e-datetime-format.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 39f0e36e0f..471ca29700 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -25,9 +25,6 @@ #include "e-datetime-format.h" #include "e-util.h" -/* backward-compatibility cruft */ -#include "e-util/gtk-compat.h" - #define KEYS_FILENAME "datetime-formats.ini" #define KEYS_GROUPNAME "formats" @@ -497,6 +494,7 @@ unref_setup_keyfile (gpointer ptr) void e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar *component, const gchar *part, DTFormatKind kind, const gchar *caption) { + GtkListStore *store; GtkWidget *label, *combo, *preview, *align; gchar *key; @@ -508,23 +506,15 @@ e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar *com key = gen_key (component, part, kind); label = gtk_label_new_with_mnemonic (caption ? caption : _("Format:")); -#if GTK_CHECK_VERSION(2,23,0) - /* FIXME Rewrite this when removing the version check. */ - { - GtkListStore *store; - - store = gtk_list_store_new (1, G_TYPE_STRING); - combo = g_object_new ( - GTK_TYPE_COMBO_BOX_TEXT, - "model", store, - "has-entry", TRUE, - "entry-text-column", 0, - NULL); - g_object_unref (store); - } -#else - combo = gtk_combo_box_entry_new_text (); -#endif + + store = gtk_list_store_new (1, G_TYPE_STRING); + combo = g_object_new ( + GTK_TYPE_COMBO_BOX_TEXT, + "model", store, + "has-entry", TRUE, + "entry-text-column", 0, + NULL); + g_object_unref (store); fill_combo_formats (combo, key, kind); gtk_label_set_mnemonic_widget ((GtkLabel *)label, combo); -- cgit v1.2.3 From 095a0e5d65a7029cc8abc9ba8c7ca01de3836556 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 28 Feb 2011 12:29:47 +0100 Subject: Fix incorrect use of ngettext from a patch for bug #635414 --- e-util/e-datetime-format.c | 51 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 471ca29700..df6ee06ea0 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -209,10 +209,53 @@ format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, cons res = g_strdup (_("Yesterday")); } else { if (future) { - /* Translators: %a is a strftime modifier, the abbreviated week day name, for example "Next Tue". - ngettext is used to be able to define different translations for different days of week, where - necessary. Index is between 1 and 7 inclusive, meaning 1 .. Monday, 2 .. Tuesday, ..., 7 .. Sunday */ - res = g_strdup (ngettext ("Next %a", "Next %a", g_date_get_weekday (&val))); + switch (g_date_get_weekday (&val)) { + case 1: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Mon")); + break; + case 2: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Tue")); + break; + case 3: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Wed")); + break; + case 4: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Thu")); + break; + case 5: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Fri")); + break; + case 6: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Sat")); + break; + case 7: + /* Translators: This is used for abbreviated days in the future. + You can use strftime modifiers here too, like "Next %a", to avoid + repeated translation of the abbreviated day name. */ + res = g_strdup (C_ ("DateFmt", "Next Sun")); + break; + default: + g_return_val_if_reached (NULL); + break; + } } else { res = g_strdup ("%a"); } -- cgit v1.2.3 From 54da4fc09cf226fdb59b9f0c70555e2e57dc1f91 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- e-util/e-datetime-format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index df6ee06ea0..3748a470e0 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -560,7 +560,7 @@ e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar *com g_object_unref (store); fill_combo_formats (combo, key, kind); - gtk_label_set_mnemonic_widget ((GtkLabel *)label, combo); + gtk_label_set_mnemonic_widget ((GtkLabel *) label, combo); align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); gtk_container_add (GTK_CONTAINER (align), combo); -- cgit v1.2.3 From c24038c4f62f37b89d1bda9542ca5ccc843d4ea0 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 27 May 2011 15:23:07 +0200 Subject: Bug #646109 - Fix use of include to make sure translations work --- e-util/e-datetime-format.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 3748a470e0..8b354cf997 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -18,6 +18,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include -- cgit v1.2.3 From 7132d0f0c2b8494b3962792cd77ce3fcb5313687 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 28 May 2011 10:18:56 -0400 Subject: Including directly is rarely needed. --- e-util/e-datetime-format.c | 1 - 1 file changed, 1 deletion(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 8b354cf997..53a0439068 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -22,7 +22,6 @@ #include #endif -#include #include #include -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- e-util/e-datetime-format.c | 78 ++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 26 deletions(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 53a0439068..c21d025794 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -101,7 +101,8 @@ ensure_loaded (void) } static const gchar * -get_default_format (DTFormatKind kind, const gchar *key) +get_default_format (DTFormatKind kind, + const gchar *key) { const gchar *res = NULL; @@ -139,7 +140,8 @@ get_default_format (DTFormatKind kind, const gchar *key) } static const gchar * -get_format_internal (const gchar *key, DTFormatKind kind) +get_format_internal (const gchar *key, + DTFormatKind kind) { const gchar *res; @@ -156,7 +158,9 @@ get_format_internal (const gchar *key, DTFormatKind kind) } static void -set_format_internal (const gchar *key, const gchar *fmt, GKeyFile *keyfile) +set_format_internal (const gchar *key, + const gchar *fmt, + GKeyFile *keyfile) { ensure_loaded (); @@ -174,7 +178,10 @@ set_format_internal (const gchar *key, const gchar *fmt, GKeyFile *keyfile) } static gchar * -format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, const struct tm *today) +format_relative_date (time_t tvalue, + time_t ttoday, + const struct tm *value, + const struct tm *today) { gchar *res = g_strdup (get_default_format (DTFormatKindDate, NULL)); GDate now, val; @@ -215,44 +222,44 @@ format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, cons switch (g_date_get_weekday (&val)) { case 1: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Mon")); break; case 2: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Tue")); break; case 3: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Wed")); break; case 4: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Thu")); break; case 5: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Fri")); break; case 6: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Sat")); break; case 7: /* Translators: This is used for abbreviated days in the future. - You can use strftime modifiers here too, like "Next %a", to avoid - repeated translation of the abbreviated day name. */ + * You can use strftime modifiers here too, like "Next %a", to avoid + * repeated translation of the abbreviated day name. */ res = g_strdup (C_ ("DateFmt", "Next Sun")); break; default: @@ -269,7 +276,10 @@ format_relative_date (time_t tvalue, time_t ttoday, const struct tm *value, cons } static gchar * -format_internal (const gchar *key, DTFormatKind kind, time_t tvalue, struct tm *tm_value) +format_internal (const gchar *key, + DTFormatKind kind, + time_t tvalue, + struct tm *tm_value) { const gchar *fmt; gchar buff[129]; @@ -332,7 +342,9 @@ format_internal (const gchar *key, DTFormatKind kind, time_t tvalue, struct tm * } static void -fill_combo_formats (GtkWidget *combo, const gchar *key, DTFormatKind kind) +fill_combo_formats (GtkWidget *combo, + const gchar *key, + DTFormatKind kind) { const gchar *date_items[] = { N_ ("Use locale default"), @@ -449,7 +461,8 @@ update_preview_widget (GtkWidget *combo) } static void -format_combo_changed_cb (GtkWidget *combo, gpointer user_data) +format_combo_changed_cb (GtkWidget *combo, + gpointer user_data) { const gchar *key; DTFormatKind kind; @@ -478,12 +491,14 @@ format_combo_changed_cb (GtkWidget *combo, gpointer user_data) update_preview_widget (combo); /* save on every change only because 'unref_setup_keyfile' is never called :( - how about in kill-bonobo? */ + * how about in kill - bonobo? */ save_keyfile (keyfile); } static gchar * -gen_key (const gchar *component, const gchar *part, DTFormatKind kind) +gen_key (const gchar *component, + const gchar *part, + DTFormatKind kind) { const gchar *kind_str = NULL; @@ -538,7 +553,12 @@ unref_setup_keyfile (gpointer ptr) * on user's changes. **/ void -e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar *component, const gchar *part, DTFormatKind kind, const gchar *caption) +e_datetime_format_add_setup_widget (GtkWidget *table, + gint row, + const gchar *component, + const gchar *part, + DTFormatKind kind, + const gchar *caption) { GtkListStore *store; GtkWidget *label, *combo, *preview, *align; @@ -601,7 +621,10 @@ e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar *com } gchar * -e_datetime_format_format (const gchar *component, const gchar *part, DTFormatKind kind, time_t value) +e_datetime_format_format (const gchar *component, + const gchar *part, + DTFormatKind kind, + time_t value) { gchar *key, *res; @@ -619,7 +642,10 @@ e_datetime_format_format (const gchar *component, const gchar *part, DTFormatKin } gchar * -e_datetime_format_format_tm (const gchar *component, const gchar *part, DTFormatKind kind, struct tm *tm_time) +e_datetime_format_format_tm (const gchar *component, + const gchar *part, + DTFormatKind kind, + struct tm *tm_time) { gchar *key, *res; -- cgit v1.2.3 From e64d6fe05c30c2cc1d7625a202afba3ba2da07cd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 22 Nov 2011 18:22:14 -0500 Subject: Miscellaneous cleanups. --- e-util/e-datetime-format.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'e-util/e-datetime-format.c') diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c index 877b170218..a1fb490fdd 100644 --- a/e-util/e-datetime-format.c +++ b/e-util/e-datetime-format.c @@ -664,7 +664,9 @@ e_datetime_format_format_tm (const gchar *component, } gboolean -e_datetime_format_includes_day_name (const gchar *component, const gchar *part, DTFormatKind kind) +e_datetime_format_includes_day_name (const gchar *component, + const gchar *part, + DTFormatKind kind) { gchar *key; const gchar *fmt; -- cgit v1.2.3