git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 17, 2014, 18:08 UTC
Message-ID
<xmqqk3anesml.fsf@gitster.dls.corp.google.com>
In-Reply-To
<2ce9ec406501d112e032c8208417f8100bed04c6.1397712142.git.worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 20 quoted lines
> 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).
Hmph.

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");
Show 39 quoted lines
>
> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
> ---
>  Makefile          | 2 +-
>  builtin/init-db.c | 8 +++-----
>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 2128ce3..a53f3a8 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 <git@vger.kernel.org>" \
>  	--from-code=UTF-8
>  XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
> diff --git a/builtin/init-db.c b/builtin/init-db.c
> index c7c76bb..56f85e2 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") : "",
Previous: Jiang XinNext: Jiang Xin
Message 6 of 13 in “[l10n] date: Note for translators not included in .po files”
  1. Brian GesiakApr 16, 2014
  2. Jiang XinApr 17, 2014
  3. 0/3 extract proper comments for l10n translatorsJiang Xin, Apr 17, 2014
  4. 1/3 i18n: Fixes uncatchable comments for translatorsJiang Xin, Apr 17, 2014
  5. 2/3 i18n: Only extract comments marked by special tagJiang Xin, Apr 17, 2014
  6. Junio C HamanoApr 17, 2014
  7. Jiang XinApr 18, 2014
  8. Junio C HamanoApr 18, 2014
  9. Junio C HamanoApr 18, 2014
  10. 3/3 i18n: Remove obsolete comments for translatorsJiang Xin, Apr 17, 2014
  11. Jiang XinApr 17, 2014
  12. Junio C HamanoApr 17, 2014
  13. Jiang XinApr 17, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.