Subject: Re: [PATCH 2/3] i18n: Only extract comments marked by special tag

From: Junio C Hamano <[email-masked]>
Date: Fri, 18 Apr 2014 09:52:06 -0700

Jiang Xin <[email-masked]> writes:

>> I am not very happy with this change, as it would force us to
>> special case "Translators" comment to follow a non-standard
>> multi-line comment formatting convention.  Is there a way to tell
>> xgettext to accept both of these forms?
>>
>>         /* TRANSLATORS: this is a short comment to help you */
>>         _("foo bar");
>>
>>         /*
>>          * TRANSLATORS: this comment is to help you, but it is
>>          * a lot longer to fit on just a single line.
>>          */
>>         _("bar baz");
>>
>
> We can not provide multiple `--add-comments=TAG` options to xgettext,
> because xgettext holds the tag in one string, not in a list:
>
>         /* Tag used in comment of prevailing domain.  */
>         static char *comment_tag;
>
> So if we won't change our multi-line comments for translators, must
> hack gettext in some ways.
>
> There maybe 3 ways to hack gettext:
> ...
> I CC this mail to the gettext mailing list. Full thread see:
>
>  * http://thread.gmane.org/gmane.comp.version-control.git/246390/focus=246431

This is one of these times when I find myself very fortunate for
being surrounded by competent contributors with good tastes, which I
may not deserve ;-)

Thanks for being thorough.

Having said that, it is only just a single comment, and it is too
much hassle to even think about what to do in the meantime while we
wait until such a change happens and an updated version of gettext
reaches everybody.  Let's take 2/3 as-is.

Documentation/CodingGuidelines may want to have a sentence of two to
explain this, though.

 Documentation/CodingGuidelines | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index dab5c61..b367a85 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -159,10 +159,19 @@ For C programs:
  - Multi-line comments include their delimiters on separate lines from
    the text.  E.g.
 
 	/*
 	 * A very long
 	 * multi-line comment.
 	 */
 
+   Note however that a multi-line comment that explains a translatable
+   string to translators uses a different convention of starting with a
+   magic token "TRANSLATORS: " immediately after the opening delimiter,
+   and without an asterisk at the beginning of each line.  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.