Skip to content

Commit 47fbfde

Browse files
jiangxingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1d96a8 commit 47fbfde

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ pdf:
21022102

21032103
XGETTEXT_FLAGS = \
21042104
--force-po \
2105-
--add-comments \
2105+
--add-comments=TRANSLATORS: \
21062106
--msgid-bugs-address="Git Mailing List <[email protected]>" \
21072107
--from-code=UTF-8
21082108
XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \

builtin/init-db.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,9 @@ int init_db(const char *template_dir, unsigned int flags)
412412
if (!(flags & INIT_DB_QUIET)) {
413413
int len = strlen(git_dir);
414414

415-
/*
416-
* TRANSLATORS: The first '%s' is either "Reinitialized
417-
* existing" or "Initialized empty", the second " shared" or
418-
* "", and the last '%s%s' is the verbatim directory name.
419-
*/
415+
/* TRANSLATORS: The first '%s' is either "Reinitialized
416+
existing" or "Initialized empty", the second " shared" or
417+
"", and the last '%s%s' is the verbatim directory name. */
420418
printf(_("%s%s Git repository in %s%s\n"),
421419
reinit ? _("Reinitialized existing") : _("Initialized empty"),
422420
shared_repository ? _(" shared") : "",

0 commit comments

Comments
 (0)