i18n: TRANSLATORS commends and LEGO--
cover i18n: TRANSLATORS commends and LEGO--
This series fixes/adds some TRANSLATORS commends and removes lego from some branch/commit messages.
Ævar Arnfjörð Bjarmason (5):
diff: move TRANSLATORS comments so they're picked up
i18n: Add more TRANSLATORS comments
git-branch: remove lego in i18n messages
git-commit: remove lego in i18n messages
git-commit: remove lego in i18n messages
advice.c | 3 +++ builtin/branch.c | 24 ++++++++++++-------- builtin/commit.c | 66 ++++++++++++++++++++++++------------------------------ bundle.c | 5 +++++ commit.c | 4 ++++ connected.c | 3 +++ diff.c | 17 +++++++------- remote.c | 10 +++++++++ sequencer.c | 10 +++++++++ 9 files changed, 88 insertions(+), 54 deletions(-)
Signature · 1 line
1.7.10.546.gbaa1a.dirty
PATCH 1/5 diff: move TRANSLATORS comments so they're picked up
These TRANSLATORS comments weren't actually picked up by xgettext, the comment needs to be right before the Q_() function call, evidently it isn't picked up if that call is wrapped in another function call.
--- diff.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff.c +8 -8
@@ -1413,22 +1413,22 @@ 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, +/* +* TRANSLATORS: "+" in (+) is a line addition marker; +* do not translate it. +*/ Q_ (", %d insertion(+)" ,", %d insertions(+)" , insertions), insertions); }if (deletions || insertions ==0 ) { -/* -* TRANSLATORS: "-" in (-) is a line removal marker; -* do not translate it. -*/ strbuf_addf (&sb, +/* +* TRANSLATORS: "-" in (-) is a line removal marker; +* do not translate it. +*/ Q_ (", %d deletion(-)" ,", %d deletions(-)" , deletions), deletions);
Signature · 1 line
1.7.10.546.gbaa1a.dirty
Re: [PATCH 1/5] diff: move TRANSLATORS comments so they're picked up
Quoted 5 lines · Ævar Arnfjörð Bjarmason
These TRANSLATORS comments weren't actually picked up by xgettext, the comment needs to be right before the
Q_()function call, evidently it isn't picked up if that call is wrapped in another function call.Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>
The patch makes sense as an advice to people who update sources where to place the "TRANSLATORS:" comment, but I am unsure about what this particular one says. Are we assuming that translators do not know what the sentence they are translating refers to?
diff.c int print_stat_summary(FILE *fp, int files, int insertions, int deletions) · line 1422
Quoted 7 lines
diff.c +4
-0strbuf_addf(&sb, + /* + * TRANSLATORS: "+" in (+) is a line addition marker; + * do not translate it. + */ Q_(", %d insertion(+)", ", %d insertions(+)", insertions),
What I am getting at is that this may be simply being unnecessarily noisy by trying to be helpful, and I am not sure if you are drawing the line at the right level. For example, "insertion" has many meanings and in the context of this sentence it means lines added to the old material---should we mention that here, and tell translators to use the word that conveys that particular meaning?
For this particular one, I'd be happier if the TRANSLATORS comment told them to check if "diffstat" (which we borrowed this from) has a l10n of this message for the language they are translating to, and make sure they use the same format here.
Re: [PATCH 1/5] diff: move TRANSLATORS comments so they're picked up
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Ævar Arnfjörð Bjarmason
These TRANSLATORS comments weren't actually picked up by xgettext, the comment needs to be right before the
Q_()function call, evidently it isn't picked up if that call is wrapped in another function call.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>The patch makes sense as an advice to people who update sources where to place the "TRANSLATORS:" comment, but I am unsure about what this particular one says. Are we assuming that translators do not know what the sentence they are translating refers to?
They'd know if they looked at the source, but the reason for moving this is that at the previous location the comment wasn't getting picked up by xgettext.
I.e. before there would be no comment in git.pot and the derived PO file, now there would be, in practice that means that most translators will actually see it.
Quoted 15 lines
Quoted 7 lines
strbuf_addf(&sb,
+ /*
+ * TRANSLATORS: "+" in (+) is a line addition marker;
+ * do not translate it.
+ */
Q_(", %d insertion(+)", ", %d insertions(+)", insertions),What I am getting at is that this may be simply being unnecessarily noisy by trying to be helpful, and I am not sure if you are drawing the line at the right level. For example, "insertion" has many meanings and in the context of this sentence it means lines added to the old material---should we mention that here, and tell translators to use the word that conveys that particular meaning?
Quoted 4 lines
For this particular one, I'd be happier if the TRANSLATORS comment told them to check if "diffstat" (which we borrowed this from) has a l10n of this message for the language they are translating to, and make sure they use the same format here.
That makes sense. But for this patch I just wanted to fix things up so that it was placed in the PO file.
PATCH 2/5 i18n: Add more TRANSLATORS comments
In reply to Ævar Arnfjörð BjarmasonI took a pass through git.pot and added comments to various messages that could use one, comments still need to be added to a lot of other things, but you have to start somewhere.
--- advice.c | 3 +++ bundle.c | 5 +++++ commit.c | 4 ++++ connected.c | 3 +++ diff.c | 1 + remote.c | 10 ++++++++++ sequencer.c | 10 ++++++++++ 7 files changed, 36 insertions(+)
advice.c +3 -0
@@ -37,6 +37,9 @@ void advise(const char *advice, ...)for (cp = buf.buf; *cp; cp = np) { np =strchrnul (cp,'\n' ); +/* TRANSLATORS: This will be used to prefix each line of an +* advice message, with the format string being the line +*/ fprintf (stderr,_ ("hint: %.*s\n" ), (int )(np - cp), cp);if (*np) np++;
bundle.c +5 -0
@@ -86,6 +86,7 @@ int read_bundle_header(const char *path, struct bundle_header *header)int fd =open (path,O_RDONLY );if (fd <0 ) +/* TRANSLATORS: The argument is a path that can't be opened */ return error (_ ("could not open '%s'" ), path);return parse_bundle_header (fd, header, path); }
@@ -137,6 +138,9 @@ int verify_bundle(struct bundle_header *header, int verbose)struct object_array refs;struct commit *commit;int i, ret =0 , req_nr; +/* TRANSLATORS: This is a heading that'll precede a list of commit +* hashes and reference names +*/ const char *message =_ ("Repository lacks these prerequisite commits:" );init_revisions (&revs,NULL );
@@ -412,6 +416,7 @@ int create_bundle(struct bundle_header *header, const char *path,return error (_ ("pack-objects died" ));if (!bundle_to_stdout) {if (commit_lock_file (&lock)) +/* TRANSLATORS: The argument is a path we can't create */ die_errno (_ ("cannot create '%s'" ), path); }return 0 ;
commit.c +4 -0
@@ -45,8 +45,12 @@ struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_n {struct commit *c =lookup_commit_reference (sha1);if (!c) +/* TRANSLATORS: The argument is a reference name */ die (_ ("could not parse %s" ), ref_name);if (hashcmp (sha1, c->object.sha1)) { +/* TRANSLATORS: The first argument is a refname, the second is +* a commit hash +*/ warning (_ ("%s %s is not a commit!" ), ref_name,sha1_to_hex (sha1)); }
connected.c +3 -0
@@ -45,6 +45,9 @@ int check_everything_connected(sha1_iterate_fn fn, int quiet, void *cb_data)memcpy (commit,sha1_to_hex (sha1),40 );if (write_in_full (rev_list.in, commit,41 ) <0 ) {if (errno !=EPIPE && errno !=EINVAL ) +/* TRANSLATORS: The argument is a strerror() +* message +*/ error (_ ("failed write to rev-list: %s" ),strerror (errno)); err =-1 ;
diff.c +1 -0
@@ -3436,6 +3436,7 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params) {struct strbuf errmsg =STRBUF_INIT ;if (parse_dirstat_params (options, params, &errmsg)) +/* TRANSLATORS: The argument is an error message */ die (_ ("Failed to parse --dirstat/-X option parameter:\n%s" ), errmsg.buf);strbuf_release (&errmsg);
remote.c +10 -0
@@ -1604,12 +1604,18 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb) base =shorten_unambiguous_ref (base,0 );if (!num_theirs)strbuf_addf (sb, +/* TRANSLATORS: the first argument is a branch name, the +* second is a count of how many commits we're ahead of it +*/ Q_ ("Your branch is ahead of '%s' by %d commit.\n" ,"Your branch is ahead of '%s' by %d commits.\n" , num_ours), base, num_ours);else if (!num_ours) strbuf_addf(sb, + /* TRANSLATORS: the first argument is a branch name, the + * second is a count of how many commits we're behind it + */ Q_("Your branch is behind '%s' by %d commit, " "and can be fast-forwarded.\n", "Your branch is behind '%s' by %d commits, "
@@ -1618,6 +1624,10 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb) base, num_theirs); else strbuf_addf(sb, + /* TRANSLATORS: the first argument is a branch name, the + * second and third arguments are counts of how many + * commits they've diverged by + */ Q_("Your branch and '%s' have diverged,\n""and have %d and %d different commit each, " "respectively.\n",
sequencer.c +10 -0
@@ -118,8 +118,14 @@ static void write_cherry_pick_head(struct commit *commit, const char *pseudoref) filename =git_path ("%s" , pseudoref); fd =open (filename,O_WRONLY |O_CREAT ,0666 );if (fd <0 ) +/* TRANSLATORS: The argument is a filename that can't be +* opened for writing +*/ die_errno (_ ("Could not open '%s' for writing" ), filename);if (write_in_full (fd, buf.buf, buf.len) != buf.len ||close (fd)) +/* TRANSLATORS: The argument is a filename that can't be +* opened for writing +*/ die_errno (_ ("Could not write to '%s'" ), filename);strbuf_release (&buf); }
@@ -157,6 +163,9 @@ static void write_message(struct strbuf *msgbuf, const char *filename)int msg_fd =hold_lock_file_for_update (&msg_file, filename,LOCK_DIE_ON_ERROR );if (write_in_full (msg_fd, msgbuf->buf, msgbuf->len) <0 ) +/* TRANSLATORS: The argument is a filename that can't be +* written to +*/ die_errno (_ ("Could not write to %s" ), filename);strbuf_release (msgbuf);if (commit_lock_file (&msg_file) <0 )
@@ -365,6 +374,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)struct commit_list *p;if (!opts->mainline) +/* TRANSLATORS: The argument is a commit digest */ return error (_ ("Commit %s is a merge but no -m option was given." ),sha1_to_hex (commit->object.sha1));
Signature · 1 line
1.7.10.546.gbaa1a.dirty
Re: [PATCH 2/5] i18n: Add more TRANSLATORS comments
Quoted 20 lines · Ævar Arnfjörð Bjarmason
I took a pass through git.pot and added comments to various messages that could use one, comments still need to be added to a lot of other things, but you have to start somewhere.
Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- advice.c | 3 +++ bundle.c | 5 +++++ commit.c | 4 ++++ connected.c | 3 +++ diff.c | 1 + remote.c | 10 ++++++++++ sequencer.c | 10 ++++++++++ 7 files changed, 36 insertions(+)advice.c +0
-0
advice.c void advise(const char *advice, ...) · line 42
Quoted 6 lines
advice.c +3
-0@@ -37,6 +37,9 @@ void advise(const char *advice, ...)for (cp = buf.buf; *cp; cp = np) { np =strchrnul (cp,'\n' ); +/* TRANSLATORS: This will be used to prefix each line of an +* advice message, with the format string being the line +*/
/*
* Our multi-line comments are formatted like
* this (many other places in the patch).
*/Also end the sentence with a full-stop, please (many other places in the patch).
It is unclear what "with the format string being the line" means here, at least to me, even though I think I wrote this code.
bundle.c int read_bundle_header(const char *path, struct bundle_header *header) · line 90
Quoted 13 lines
advice.c +0
-0fprintf (stderr,_ ("hint: %.*s\n" ), (int )(np - cp), cp);if (*np) np++;bundle.c +1
-0@@ -86,6 +86,7 @@ int read_bundle_header(const char *path, struct bundle_header *header)int fd =open (path,O_RDONLY );if (fd <0 ) +/* TRANSLATORS: The argument is a path that can't be opened */ return error (_ ("could not open '%s'" ), path);
That does not add much information. "path to the file we tried to read the bundle data from but failed"?
bundle.c int verify_bundle(struct bundle_header *header, int verbose) · line 143
Quoted 7 lines
bundle.c +3
-0@@ -137,6 +138,9 @@ int verify_bundle(struct bundle_header *header, int verbose)struct object_array refs;struct commit *commit;int i, ret =0 , req_nr; +/* TRANSLATORS: This is a heading that'll precede a list of commit +* hashes and reference names +*/
Please say "commit object names" (many other places in the patch).
bundle.c int create_bundle(struct bundle_header *header, const char *path, · line 420
Quoted 9 lines
bundle.c +1
-0const char *message =_ ("Repository lacks these prerequisite commits:" );init_revisions (&revs,NULL );@@ -412,6 +416,7 @@ int create_bundle(struct bundle_header *header, const char *path,return error (_ ("pack-objects died" ));if (!bundle_to_stdout) {if (commit_lock_file (&lock)) +/* TRANSLATORS: The argument is a path we can't create */ die_errno (_ ("cannot create '%s'" ), path);
That does not add much information. "path to the file we tried to write the bundle data to but failed"?
bundle.c static int do_pick_commit(struct commit *commit, struct replay_opts *opts) · line 377
Quoted 5 lines
bundle.c +1
-0@@ -365,6 +374,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)struct commit_list *p;if (!opts->mainline) +/* TRANSLATORS: The argument is a commit digest */
Please consistently say "commit object name".
Quoted 2 lines
bundle.c +0
-0return error (_ ("Commit %s is a merge but no -m option was given." ),sha1_to_hex (commit->object.sha1));
PATCH 3/5 git-branch: remove lego in i18n messages
In reply to Ævar Arnfjörð BjarmasonInstead of making translators translate "remote " and then using "%sbranch" where "%s" is either "remote " or "" just split the two up into separate messages. This makes the translation of this section of git-branch much less confusing.
--- builtin/branch.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
builtin/branch.c +15 -9
@@ -152,21 +152,22 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,struct commit *rev, *head_rev =NULL ;unsigned char sha1[20 ];char *name =NULL ; -const char *fmt, *remote; +const char *fmt;int i;int ret =0 ; +int remote_branch =0 ;struct strbuf bname =STRBUF_INIT ;switch (kinds) {case REF_REMOTE_BRANCH : fmt ="refs/remotes/%s" ; -/* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */ - remote =_ ("remote " ); +/* For subsequent UI messages */ + remote_branch =1 ; + force =1 ;break ;case REF_LOCAL_BRANCH : fmt ="refs/heads/%s" ; - remote ="" ;break ;default :die (_ ("cannot use -a with -d" ));
@@ -190,8 +191,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, name =xstrdup (mkpath (fmt, bname.buf));if (read_ref (name, sha1)) { -error (_ ("%sbranch '%s' not found." ), - remote, bname.buf); +error (remote_branch + ?_ ("remote branch '%s' not found." ) + :_ ("branch '%s' not found." ), bname.buf); ret =1 ;continue ; }
@@ -212,14 +214,18 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, }if (delete_ref (name, sha1,0 )) { -error (_ ("Error deleting %sbranch '%s'" ), remote, +error (remote_branch + ?_ ("Error deleting remote branch '%s'" ) + :_ ("Error deleting branch '%s'" ), bname.buf); ret =1 ; }else {struct strbuf buf =STRBUF_INIT ;if (!quiet) -printf (_ ("Deleted %sbranch %s (was %s).\n" ), - remote, bname.buf, +printf (remote_branch + ?_ ("Deleted remote branch %s (was %s).\n" ) + :_ ("Deleted branch %s (was %s).\n" ), + bname.buf,find_unique_abbrev (sha1,DEFAULT_ABBREV ));strbuf_addf (&buf,"branch.%s" , bname.buf);if (git_config_rename_section (buf.buf,NULL ) <0 )
Signature · 1 line
1.7.10.546.gbaa1a.dirty
Re: [PATCH 3/5] git-branch: remove lego in i18n messages
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Instead of making translators translate "remote " and then using "%sbranch" where "%s" is either "remote " or "" just split the two up into separate messages. This makes the translation of this section of git-branch much less confusing.
Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>---
Looks good.
PATCH 4/5 git-commit: remove lego in i18n messages
In reply to Ævar Arnfjörð BjarmasonRemove the whence_s() function and messages that dependen on it in favor of messages that use either "merge" or "cherry-pick" directly.
--- builtin/commit.c | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-)
builtin/commit.c +23 -29
@@ -194,24 +194,6 @@ static void determine_whence(struct wt_status *s) s->whence = whence; } -static const char *whence_s (void ) -{ -const char *s ="" ; - -switch (whence) { -case FROM_COMMIT : -break ; -case FROM_MERGE : - s =_ ("merge" ); -break ; -case FROM_CHERRY_PICK : - s =_ ("cherry-pick" ); -break ; - } - -return s; -} -static void rollback_index_files (void ) {switch (commit_style) {
@@ -453,8 +435,12 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,*/ commit_style =COMMIT_PARTIAL ; -if (whence !=FROM_COMMIT ) -die (_ ("cannot do a partial commit during a %s." ),whence_s ()); +if (whence !=FROM_COMMIT ) { +if (whence ==FROM_MERGE ) +die (_ ("cannot do a partial commit during a merge." )); +else if (whence ==FROM_CHERRY_PICK ) +die (_ ("cannot do a partial commit during a cherry-pick." )); + }memset (&partial,0 ,sizeof (partial)); partial.strdup_strings =1 ;
@@ -796,13 +782,17 @@ static int prepare_to_commit(const char *index_file, const char *prefix,char *ai_tmp, *ci_tmp;if (whence !=FROM_COMMIT )status_printf_ln (s,GIT_COLOR_NORMAL , -_ ("\n" -"It looks like you may be committing a %s.\n" -"If this is not correct, please remove the file\n" -" %s\n" -"and try again.\n" -"" ), -whence_s (), + whence ==FROM_MERGE + ?_ ("\n" +"It looks like you may be committing a merge.\n" +"If this is not correct, please remove the file\n" +" %s\n" +"and try again.\n" ) + :_ ("\n" +"It looks like you may be committing a cherry-pick.\n" +"If this is not correct, please remove the file\n" +" %s\n" +"and try again.\n" ),git_path (whence ==FROM_MERGE ?"MERGE_HEAD" :"CHERRY_PICK_HEAD" ));
@@ -1072,8 +1062,12 @@ static int parse_and_validate_options(int argc, const char *argv[],/* Sanity check options */ if (amend && !current_head)die (_ ("You have nothing to amend." )); -if (amend && whence !=FROM_COMMIT ) -die (_ ("You are in the middle of a %s -- cannot amend." ),whence_s ()); +if (amend && whence !=FROM_COMMIT ) { +if (whence ==FROM_MERGE ) +die (_ ("You are in the middle of a merge -- cannot amend." )); +else if (whence ==FROM_CHERRY_PICK ) +die (_ ("You are in the middle of a cherry-pick -- cannot amend." )); + }if (fixup_message && squash_message)die (_ ("Options --squash and --fixup cannot be used together" ));if (use_message)
Signature · 1 line
1.7.10.546.gbaa1a.dirty
PATCH 5/5 git-commit: remove lego in i18n messages
In reply to Ævar Arnfjörð BjarmasonChange the "Please enter the commit message for your changes." and the subsequent blurb of text not to be split up. This makes translating it much easier.
--- builtin/commit.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
builtin/commit.c +6 -8
@@ -798,17 +798,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix, : "CHERRY_PICK_HEAD"));fprintf (s->fp,"\n" ); -status_printf (s,GIT_COLOR_NORMAL , -_ ("Please enter the commit message for your changes." ));if (cleanup_mode ==CLEANUP_ALL ) -status_printf_more (s,GIT_COLOR_NORMAL , -_ (" Lines starting\n" -"with '#' will be ignored, and an empty" +status_printf (s,GIT_COLOR_NORMAL , +_ ("Please enter the commit message for your changes." +" Lines starting\nwith '#' will be ignored, and an empty" " message aborts the commit.\n" ));else /* CLEANUP_SPACE, that is. */ -status_printf_more (s,GIT_COLOR_NORMAL , -_ (" Lines starting\n" -"with '#' will be kept; you may remove them" +status_printf (s,GIT_COLOR_NORMAL , +_ ("Please enter the commit message for your changes." +" Lines starting\nwith '#' will be kept; you may remove them" " yourself if you want to.\n" "An empty message aborts the commit.\n" ));if (only_include_assumed)
Signature · 1 line
1.7.10.546.gbaa1a.dirty
Re: [PATCH 5/5] git-commit: remove lego in i18n messages
3, 4 and 5 looked all great. Will queue them.
Quoted 2 lines · Ævar Arnfjörð Bjarmason
This series fixes/adds some TRANSLATORS commends and removes lego from some branch/commit messages.
Oh and of course I forgot this: This is based on next.