From e3b69538bacd14283374f5e7619db610cafd81d6 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 12 Apr 2017 22:42:23 +0200 Subject: [PATCH] gettext improvements (more strings, times, plural, de lang) --- libdino/src/dino_i18n.h | 3 +- libdino/src/util.vala | 3 + main/po/POTFILES.in | 1 + main/po/de.po | 79 ++++++++++++++++-- main/po/dino.pot | 81 +++++++++++++++++-- .../conversation_row.vala | 15 ++-- .../ui/conversation_summary/message_item.vala | 19 +++-- main/src/ui/util.vala | 7 ++ 8 files changed, 186 insertions(+), 22 deletions(-) diff --git a/libdino/src/dino_i18n.h b/libdino/src/dino_i18n.h index e1a65f41..bf6e1347 100644 --- a/libdino/src/dino_i18n.h +++ b/libdino/src/dino_i18n.h @@ -3,6 +3,7 @@ #include -#define dino_gettext(String) ((char *) dgettext (GETTEXT_PACKAGE, String)) +#define dino_gettext(MsgId) ((char *) dgettext (GETTEXT_PACKAGE, MsgId)) +#define dino_ngettext(MsgId, MsgIdPlural, Int) ((char *) dngettext (GETTEXT_PACKAGE, MsgId, MsgIdPlural, Int)) #endif \ No newline at end of file diff --git a/libdino/src/util.vala b/libdino/src/util.vala index 29186aa0..03d6ee26 100644 --- a/libdino/src/util.vala +++ b/libdino/src/util.vala @@ -23,6 +23,9 @@ public class SearchPathGenerator { [CCode (cname = "dino_gettext", cheader_filename = "dino_i18n.h")] public static extern unowned string _(string s); +[CCode (cname = "dino_ngettext", cheader_filename = "dino_i18n.h")] +public static extern unowned string n(string msgid, string plural, ulong number); + [CCode (cname = "bindtextdomain", cheader_filename = "libintl.h")] private static extern unowned string? bindtextdomain(string domainname, string? dirname); diff --git a/main/po/POTFILES.in b/main/po/POTFILES.in index cf47561b..d3009749 100644 --- a/main/po/POTFILES.in +++ b/main/po/POTFILES.in @@ -11,6 +11,7 @@ data/menu_encryption.ui data/settings_dialog.ui src/ui/add_conversation/conference/add_groupchat_dialog.vala src/ui/add_conversation/conference/dialog.vala +src/ui/conversation_selector/conversation_row.vala src/ui/conversation_summary/message_item.vala src/ui/conversation_summary/view.vala src/ui/manage_accounts/add_account_dialog.vala diff --git a/main/po/de.po b/main/po/de.po index 61690d2a..3b708ef9 100644 --- a/main/po/de.po +++ b/main/po/de.po @@ -2,11 +2,12 @@ msgid "" msgstr "" "Project-Id-Version: dino-0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-10 15:10+0200\n" +"POT-Creation-Date: 2017-04-13 13:48+0200\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1\n" #: data/add_conversation/add_contact_dialog.ui:11 #: data/add_conversation/add_groupchat_dialog.ui:11 @@ -118,10 +119,78 @@ msgstr "Weiter" msgid "Join" msgstr "Beitreten" -#: src/ui/conversation_summary/message_item.vala:107 +#. Day and month +#: src/ui/conversation_selector/conversation_row.vala:175 +#, no-c-format +msgid "%b %d" +msgstr "%d. %b" + +#: src/ui/conversation_selector/conversation_row.vala:179 +msgid "Yesterday" +msgstr "Gestern" + +#. Time in 24h format (w/o seconds) +#: src/ui/conversation_selector/conversation_row.vala:182 +#: src/ui/conversation_summary/message_item.vala:110 +#, no-c-format +msgid "%H∶%M" +msgstr "%H∶%M" + +#. Time in 12h format (w/o seconds) +#: src/ui/conversation_selector/conversation_row.vala:183 +#: src/ui/conversation_summary/message_item.vala:111 +#, no-c-format +msgid "%l∶%M %p" +msgstr "%l∶%M %p" + +#: src/ui/conversation_selector/conversation_row.vala:186 +#: src/ui/conversation_summary/message_item.vala:114 +#, c-format +msgid "%i min ago" +msgid_plural "%i mins ago" +msgstr[0] "vor %i min" +msgstr[1] "vor %i mins" + +#: src/ui/conversation_selector/conversation_row.vala:188 +#: src/ui/conversation_summary/message_item.vala:116 msgid "Just now" msgstr "Gerade eben" +#. Date + time in 24h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:98 +#, no-c-format +msgid "%x, %H∶%M" +msgstr "%x, %H∶%M" + +#. Date + time in 12h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:99 +#, no-c-format +msgid "%x, %l∶%M %p" +msgstr "%x, %l∶%M %p" + +#. Month, day and time in 24h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:102 +#, no-c-format +msgid "%b %d, %H∶%M" +msgstr "%d. %b, %H∶%M" + +#. Month, day and time in 12h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:103 +#, no-c-format +msgid "%b %d, %l∶%M %p" +msgstr "%d. %b, %l∶%M %p" + +#. Day of week and time in 12h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:106 +#, no-c-format +msgid "%a, %H∶%M" +msgstr "%a, %H∶%M" + +#: src/ui/conversation_summary/message_item.vala:107 +#, no-c-format +msgid "%a, %l∶%M %p" +msgstr "%a, %l∶%M %p" + #: src/ui/conversation_summary/view.vala:120 msgid "is typing..." msgstr "tippt gerade..." @@ -167,15 +236,15 @@ msgstr "Fehler" msgid "Start private conversation" msgstr "Private Konversation beginnen" -#: src/ui/notifications.vala:59 +#: src/ui/notifications.vala:64 msgid "Subscription request" msgstr "Kontaktanfrage" -#: src/ui/notifications.vala:61 +#: src/ui/notifications.vala:66 msgid "Accept" msgstr "Annehmen" -#: src/ui/notifications.vala:74 +#: src/ui/notifications.vala:79 msgid "Deny" msgstr "Ablehnen" diff --git a/main/po/dino.pot b/main/po/dino.pot index 620ffeb3..cb9d03b2 100644 --- a/main/po/dino.pot +++ b/main/po/dino.pot @@ -8,14 +8,15 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-10 15:10+0200\n" +"POT-Creation-Date: 2017-04-13 13:48+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" #: data/add_conversation/add_contact_dialog.ui:11 #: data/add_conversation/add_groupchat_dialog.ui:11 @@ -127,10 +128,78 @@ msgstr "" msgid "Join" msgstr "" -#: src/ui/conversation_summary/message_item.vala:107 +#. Day and month +#: src/ui/conversation_selector/conversation_row.vala:175 +#, no-c-format +msgid "%b %d" +msgstr "" + +#: src/ui/conversation_selector/conversation_row.vala:179 +msgid "Yesterday" +msgstr "" + +#. Time in 24h format (w/o seconds) +#: src/ui/conversation_selector/conversation_row.vala:182 +#: src/ui/conversation_summary/message_item.vala:110 +#, no-c-format +msgid "%H∶%M" +msgstr "" + +#. Time in 12h format (w/o seconds) +#: src/ui/conversation_selector/conversation_row.vala:183 +#: src/ui/conversation_summary/message_item.vala:111 +#, no-c-format +msgid "%l∶%M %p" +msgstr "" + +#: src/ui/conversation_selector/conversation_row.vala:186 +#: src/ui/conversation_summary/message_item.vala:114 +#, c-format +msgid "%i min ago" +msgid_plural "%i mins ago" +msgstr[0] "" +msgstr[1] "" + +#: src/ui/conversation_selector/conversation_row.vala:188 +#: src/ui/conversation_summary/message_item.vala:116 msgid "Just now" msgstr "" +#. Date + time in 24h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:98 +#, no-c-format +msgid "%x, %H∶%M" +msgstr "" + +#. Date + time in 12h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:99 +#, no-c-format +msgid "%x, %l∶%M %p" +msgstr "" + +#. Month, day and time in 24h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:102 +#, no-c-format +msgid "%b %d, %H∶%M" +msgstr "" + +#. Month, day and time in 12h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:103 +#, no-c-format +msgid "%b %d, %l∶%M %p" +msgstr "" + +#. Day of week and time in 12h format (w/o seconds) +#: src/ui/conversation_summary/message_item.vala:106 +#, no-c-format +msgid "%a, %H∶%M" +msgstr "" + +#: src/ui/conversation_summary/message_item.vala:107 +#, no-c-format +msgid "%a, %l∶%M %p" +msgstr "" + #: src/ui/conversation_summary/view.vala:120 msgid "is typing..." msgstr "" @@ -176,15 +245,15 @@ msgstr "" msgid "Start private conversation" msgstr "" -#: src/ui/notifications.vala:59 +#: src/ui/notifications.vala:64 msgid "Subscription request" msgstr "" -#: src/ui/notifications.vala:61 +#: src/ui/notifications.vala:66 msgid "Accept" msgstr "" -#: src/ui/notifications.vala:74 +#: src/ui/notifications.vala:79 msgid "Deny" msgstr "" diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala index d05973db..2e7e321a 100644 --- a/main/src/ui/conversation_selector/conversation_row.vala +++ b/main/src/ui/conversation_selector/conversation_row.vala @@ -170,17 +170,22 @@ public abstract class ConversationRow : ListBoxRow { if (timespan > 365 * TimeSpan.DAY) { return datetime.get_year().to_string(); } else if (timespan > 7 * TimeSpan.DAY) { - return datetime.format("%d.%m"); + // Day and month + // xgettext:no-c-format + return datetime.format(_("%b %d")); } else if (timespan > 2 * TimeSpan.DAY) { return datetime.format("%a"); } else if (timespan > 1 * TimeSpan.DAY) { - return "Yesterday"; + return _("Yesterday"); } else if (timespan > 9 * TimeSpan.MINUTE) { - return datetime.format("%H:%M"); + return datetime.format(Util.is_24h_format() ? + /* xgettext:no-c-format */ /* Time in 24h format (w/o seconds) */ _("%H\u2236%M") : + /* xgettext:no-c-format */ /* Time in 12h format (w/o seconds) */ _("%l\u2236%M %p")); } else if (timespan > 1 * TimeSpan.MINUTE) { - return (timespan / TimeSpan.MINUTE).to_string() + " min ago"; + ulong mins = (ulong) (timespan.abs() / TimeSpan.MINUTE); + return n("%i min ago", "%i mins ago", mins).printf(mins); } else { - return "Just now"; + return _("Just now"); } } } diff --git a/main/src/ui/conversation_summary/message_item.vala b/main/src/ui/conversation_summary/message_item.vala index 4b26a289..74d46805 100644 --- a/main/src/ui/conversation_summary/message_item.vala +++ b/main/src/ui/conversation_summary/message_item.vala @@ -94,15 +94,24 @@ public class MessageItem : Grid, ConversationItem { DateTime now = new DateTime.now_local(); TimeSpan timespan = now.difference(datetime); if (timespan > 365 * TimeSpan.DAY) { - return datetime.format("%d.%m.%Y %H:%M"); + return datetime.format(Util.is_24h_format() ? + /* xgettext:no-c-format */ /* Date + time in 24h format (w/o seconds) */ _("%x, %H\u2236%M") : + /* xgettext:no-c-format */ /* Date + time in 12h format (w/o seconds)*/ _("%x, %l\u2236%M %p")); } else if (timespan > 7 * TimeSpan.DAY) { - return datetime.format("%d.%m %H:%M"); + return datetime.format(Util.is_24h_format() ? + /* xgettext:no-c-format */ /* Month, day and time in 24h format (w/o seconds) */ _("%b %d, %H\u2236%M") : + /* xgettext:no-c-format */ /* Month, day and time in 12h format (w/o seconds) */ _("%b %d, %l\u2236%M %p")); } else if (timespan > 1 * TimeSpan.DAY) { - return datetime.format("%a, %H:%M"); + return datetime.format(Util.is_24h_format() ? + /* xgettext:no-c-format */ /* Day of week and time in 12h format (w/o seconds) */ _("%a, %H\u2236%M") : + /* xgettext:no-c-format */ _("%a, %l\u2236%M %p")); } else if (timespan > 9 * TimeSpan.MINUTE) { - return datetime.format("%H:%M"); + return datetime.format(Util.is_24h_format() ? + /* xgettext:no-c-format */ /* Time in 24h format (w/o seconds) */ _("%H\u2236%M") : + /* xgettext:no-c-format */ /* Time in 12h format (w/o seconds) */ _("%l\u2236%M %p")); } else if (timespan > TimeSpan.MINUTE) { - return (timespan / TimeSpan.MINUTE).to_string() + " min ago"; + ulong mins = (ulong) (timespan.abs() / TimeSpan.MINUTE); + return n("%i min ago", "%i mins ago", mins).printf(mins); } else { return _("Just now"); } diff --git a/main/src/ui/util.vala b/main/src/ui/util.vala index 4df785c0..696ce2d1 100644 --- a/main/src/ui/util.vala +++ b/main/src/ui/util.vala @@ -112,6 +112,13 @@ public class Util : Object { Gdk.RGBA bg = widget.get_style_context().get_background_color(StateFlags.NORMAL); return (bg.red < 0.5 && bg.green < 0.5 && bg.blue < 0.5); } + + public static bool is_24h_format() { + GLib.Settings settings = new GLib.Settings("org.gnome.desktop.interface"); + string settings_format = settings.get_string("clock-format"); + string p_format = (new DateTime.now_local()).format("%p"); + return settings_format == "24h" || p_format == " "; + } } } \ No newline at end of file