From fcaed04df693685dfece4a48cc8780c9a5adde0b Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Thu, 17 Apr 2014 13:37:17 +0800 Subject: [PATCH 1/4] i18n: fix uncatchable comments for translators in date.c Comment for l10n translators can not be extracted by xgettext if it is not right above the l10n tag. Moving the comment right before the l10n tag will fix this issue. Reported-by: Brian Gesiak Signed-off-by: Jiang Xin Signed-off-by: Junio C Hamano --- date.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/date.c b/date.c index e1a2cee568..782de95d90 100644 --- a/date.c +++ b/date.c @@ -144,8 +144,8 @@ void show_date_relative(unsigned long time, int tz, if (months) { struct strbuf sb = STRBUF_INIT; strbuf_addf(&sb, Q_("%lu year", "%lu years", years), years); - /* TRANSLATORS: "%s" is " years" */ strbuf_addf(timebuf, + /* TRANSLATORS: "%s" is " years" */ Q_("%s, %lu month ago", "%s, %lu months ago", months), sb.buf, months); strbuf_release(&sb); From d1d96a82bbe302f552364d1629958b7d7247fd8f Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Thu, 17 Apr 2014 13:37:19 +0800 Subject: [PATCH 2/4] i18n: remove obsolete comments for translators in diffstat generation Since we do not translate diffstat any more, remove the obsolete comments. Signed-off-by: Jiang Xin Signed-off-by: Junio C Hamano --- diff.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/diff.c b/diff.c index 539997fc6a..54d5308268 100644 --- a/diff.c +++ b/diff.c @@ -1461,20 +1461,12 @@ int print_stat_summary(FILE *fp, int files, int insertions, int deletions) * but nothing about added/removed lines? Is this a bug in Git?"). */ if (insertions || deletions == 0) { - /* - * TRANSLATORS: "+" in (+) is a line addition marker; - * do not translate it. - */ strbuf_addf(&sb, (insertions == 1) ? ", %d insertion(+)" : ", %d insertions(+)", insertions); } if (deletions || insertions == 0) { - /* - * TRANSLATORS: "-" in (-) is a line removal marker; - * do not translate it. - */ strbuf_addf(&sb, (deletions == 1) ? ", %d deletion(-)" : ", %d deletions(-)", deletions); From 47fbfded53d46ef73c5f5c150d6e6e7602a7f66f Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Thu, 17 Apr 2014 13:37:18 +0800 Subject: [PATCH 3/4] i18n: only extract comments marked with "TRANSLATORS:" When extract l10n messages, we use "--add-comments" option to keep comments right above the l10n messages for references. But sometimes irrelevant comments are also extracted. For example in the following code block, the comment in line 2 will be extracted as comment for the l10n message in line 3, but obviously it's wrong. { OPTION_CALLBACK, 0, "ignore-removal", &addremove_explicit, NULL /* takes no arguments */, N_("ignore paths removed in the working tree (same as --no-all)"), PARSE_OPT_NOARG, ignore_removal_cb }, Since almost all comments for l10n translators are marked with the same prefix (tag): "TRANSLATORS:", it's safe to only extract comments with this special tag. I.E. it's better to call xgettext as: xgettext --add-comments=TRANSLATORS: ... Also tweaks the multi-line comment in "init-db.c", to make it start with the proper tag, not "* TRANSLATORS:" (which has a star before the tag). Signed-off-by: Jiang Xin Signed-off-by: Junio C Hamano --- Makefile | 2 +- builtin/init-db.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2128ce3ea2..a53f3a8326 100644 --- a/Makefile +++ b/Makefile @@ -2102,7 +2102,7 @@ pdf: XGETTEXT_FLAGS = \ --force-po \ - --add-comments \ + --add-comments=TRANSLATORS: \ --msgid-bugs-address="Git Mailing List " \ --from-code=UTF-8 XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \ diff --git a/builtin/init-db.c b/builtin/init-db.c index c7c76bbf21..56f85e239a 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -412,11 +412,9 @@ int init_db(const char *template_dir, unsigned int flags) if (!(flags & INIT_DB_QUIET)) { int len = strlen(git_dir); - /* - * TRANSLATORS: The first '%s' is either "Reinitialized - * existing" or "Initialized empty", the second " shared" or - * "", and the last '%s%s' is the verbatim directory name. - */ + /* TRANSLATORS: The first '%s' is either "Reinitialized + existing" or "Initialized empty", the second " shared" or + "", and the last '%s%s' is the verbatim directory name. */ printf(_("%s%s Git repository in %s%s\n"), reinit ? _("Reinitialized existing") : _("Initialized empty"), shared_repository ? _(" shared") : "", From cbcfd4e3ea9db3125619591b942f56d0a8f3ef48 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 18 Apr 2014 10:48:08 -0700 Subject: [PATCH 4/4] i18n: mention "TRANSLATORS:" marker in Documentation/CodingGuidelines These comments have to have "TRANSLATORS: " at the very beginning and have to deviate from the usual multi-line comment formatting convention. Signed-off-by: Junio C Hamano --- Documentation/CodingGuidelines | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index dab5c61bfe..f424dbd75c 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -164,6 +164,16 @@ For C programs: * multi-line comment. */ + Note however that a comment that explains a translatable string to + translators uses a convention of starting with a magic token + "TRANSLATORS: " immediately after the opening delimiter, even when + it spans multiple lines. We do not add an asterisk at the beginning + of each line, either. E.g. + + /* TRANSLATORS: here is a comment that explains the string + to be translated, that follows immediately after it */ + _("Here is a translatable string explained by the above."); + - Double negation is often harder to understand than no negation at all.