gettext improvements (more strings, times, plural, de lang)

This commit is contained in:
fiaxh 2017-04-12 22:42:23 +02:00
parent a37b5ac823
commit e3b69538ba
8 changed files with 186 additions and 22 deletions

View file

@ -3,6 +3,7 @@
#include<libintl.h>
#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

View file

@ -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);

View file

@ -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

View file

@ -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"

View file

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

View file

@ -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");
}
}
}

View file

@ -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");
}

View file

@ -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 == " ";
}
}
}