Re: [PATCH 07/10] i18n: apply: mark strings for translation

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 07/10] i18n: apply: mark strings for translation

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:40

Nguyễn Thái Ngọc Duy  [off-list ref] writes:
quoted hunk
@@ -886,17 +886,17 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
...
 		if (!another || memcmp(another, name, len + 1))
-			die("git apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
+			die(_("git apply: bad git-diff - inconsistent %s filename on line %d"), oldnew, linenr);
 		free(another);
 		return orig_name;
 	}
In this function, the parameter oldnew has "old" or "new" and the
callers (gitdiff_oldname() and gitdiff_newname()) do not have it marked
for translation.  Even if they did, it would result in a lego
composition, so you may have to switch between two translatable messages
here.

[PATCH] apply: remove lego in i18n string in gitdiff_verify_name

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:53:45

Currently it marks the string "...inconsistent %s filename..." where
%s is either "old" or "new" from caller. Make it two strings
"...inconsistent new filename..." and "...inconsistent old filename..."

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 On Thu, Apr 26, 2012 at 5:50 AM, Junio C Hamano [off-list ref] wrote:
 > In this function, the parameter oldnew has "old" or "new" and the
 > callers (gitdiff_oldname() and gitdiff_newname()) do not have it marked
 > for translation.  Even if they did, it would result in a lego
 > composition, so you may have to switch between two translatable messages
 > here.

 Makes sense.

 builtin/apply.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index 725712d..1edd3f7 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -919,7 +919,7 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
  * their names against any previous information, just
  * to make sure..
  */
-static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew)
+static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, int new)
 {
 	if (!orig_name && !isnull)
 		return find_name(line, NULL, p_value, TERM_TAB);
@@ -934,7 +934,9 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
 			die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), name, linenr);
 		another = find_name(line, NULL, p_value, TERM_TAB);
 		if (!another || memcmp(another, name, len + 1))
-			die(_("git apply: bad git-diff - inconsistent %s filename on line %d"), oldnew, linenr);
+			die(new ?
+			    _("git apply: bad git-diff - inconsistent new filename on line %d") :
+			    _("git apply: bad git-diff - inconsistent old filename on line %d"), linenr);
 		free(another);
 		return orig_name;
 	}
@@ -949,7 +951,7 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
 static int gitdiff_oldname(const char *line, struct patch *patch)
 {
 	char *orig = patch->old_name;
-	patch->old_name = gitdiff_verify_name(line, patch->is_new, patch->old_name, "old");
+	patch->old_name = gitdiff_verify_name(line, patch->is_new, patch->old_name, 0);
 	if (orig != patch->old_name)
 		free(orig);
 	return 0;
@@ -958,7 +960,7 @@ static int gitdiff_oldname(const char *line, struct patch *patch)
 static int gitdiff_newname(const char *line, struct patch *patch)
 {
 	char *orig = patch->new_name;
-	patch->new_name = gitdiff_verify_name(line, patch->is_delete, patch->new_name, "new");
+	patch->new_name = gitdiff_verify_name(line, patch->is_delete, patch->new_name, 1);
 	if (orig != patch->new_name)
 		free(orig);
 	return 0;
-- 
1.7.8.36.g69ee2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help