diff --git a/autogen.sh b/autogen.sh index 3650700..581479f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,7 +4,7 @@ autoreconf echo bootstrapping translation files ... cd po -intltool-update --pot +XGETTEXT='xgettext -kP_:1,2' intltool-update --pot ## Translations are managed at https://www.transifex.com/telegram-purple-developers/telegram-purple/ ## To update the .po files, download it from there, since intltool, msginit, and transifex produce slightly different files, and I'd like to avoid gigantic git diffs that only change indentation or similar things. #for lang in $(cat LINGUAS); do diff --git a/telegram-purple.h b/telegram-purple.h index f9c8e18..84d046a 100644 --- a/telegram-purple.h +++ b/telegram-purple.h @@ -28,8 +28,10 @@ // libintl.h. If this is not the case a dummy macro is defined to bypass the translation functions #ifdef ENABLE_NLS # include +# define P_(Singular,Plural,N) ((char *) g_dngettext (GETTEXT_PACKAGE, Singular, Plural, N)) #else # define _(String) String +# define P_(Singular,Plural,N) Plural #endif #include diff --git a/tgp-msg.c b/tgp-msg.c index 2198000..e3d82e1 100644 --- a/tgp-msg.c +++ b/tgp-msg.c @@ -128,16 +128,29 @@ static char *format_service_msg (struct tgl_state *TLS, struct tgl_message *M) { break; } case tgl_message_action_set_message_ttl: - txt = g_strdup_printf (_("%2$s set self destruction timer to %1$d seconds."), M->action.ttl, txt_user); + + txt = g_strdup_printf (P_("%2$s set self destruction timer to %1$d second.", + "%2$s set self destruction timer to %1$d seconds.", + M->action.ttl), + M->action.ttl, txt_user); break; case tgl_message_action_read_messages: - txt = g_strdup_printf (_("%2$s marked %1$d messages read."), M->action.read_cnt, txt_user); + txt = g_strdup_printf (P_("%2$s marked %1$d message read.", + "%2$s marked %1$d messages read.", + M->action.read_cnt), + M->action.read_cnt, txt_user); break; case tgl_message_action_delete_messages: - txt = g_strdup_printf (_("%2$s deleted %1$d messages."), M->action.delete_cnt, txt_user); + txt = g_strdup_printf (P_("%2$s deleted %1$d message.", + "%2$s deleted %1$d messages.", + M->action.delete_cnt), + M->action.delete_cnt, txt_user); break; case tgl_message_action_screenshot_messages: - txt = g_strdup_printf (_("%2$s made a screenshot of %1$d messages."), M->action.screenshot_cnt, txt_user); + txt = g_strdup_printf (P_("%2$s made a screenshot of %1$d message.", + "%2$s made a screenshot of %1$d messages.", + M->action.screenshot_cnt), + M->action.screenshot_cnt, txt_user); break; default: break; diff --git a/tgp-utils.c b/tgp-utils.c index 7160a09..c7a6a1f 100644 --- a/tgp-utils.c +++ b/tgp-utils.c @@ -21,6 +21,7 @@ #include "telegram-purple.h" const char *format_time (time_t date) { + /* TODO: Inline this function for better readability? */ struct tm *datetime = localtime(&date); /* This should be the language's timestamp format. This is preceded by a colon. */ return purple_utf8_strftime (_("%d.%m.%Y %H:%M"), datetime); @@ -40,19 +41,19 @@ char *tgp_format_user_status (struct tgl_user_status *status) { char *when; switch (status->online) { case -1: - when = g_strdup_printf("%s", format_time (status->when)); + when = g_strdup_printf ("%s", format_time (status->when)); break; case -2: /* This is preceded by a colon. */ - when = g_strdup_printf (_("recently")); + when = g_strdup (_("recently")); break; case -3: /* This is preceded by a colon. */ - when = g_strdup_printf (_("last week")); + when = g_strdup (_("last week")); break; case -4: /* This is preceded by a colon. */ - when = g_strdup_printf (_("last month")); + when = g_strdup (_("last month")); break; default: /* This is preceded by a colon. It refers to a point on time. */