[PATCH 3/6] merge-recursive: remove i18n legos in conflict messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 The two sentence strings are broken down to one sentence each. Less work for
 translators when these are marked i18n.

 merge-recursive.c |   60 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 680937c..1f16e04 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1018,9 +1018,28 @@ static void handle_change_delete(struct merge_options *o,
 				 const unsigned char *o_sha, int o_mode,
 				 const unsigned char *a_sha, int a_mode,
 				 const unsigned char *b_sha, int b_mode,
-				 const char *change, const char *change_past)
+				 const char *change)
 {
 	char *renamed = NULL;
+	struct strbuf sb = STRBUF_INIT;
+	int idx;
+
+	const char *msg[] = {
+		"CONFLICT (rename/delete): %s deleted in %s and renamed in %s.",
+		"CONFLICT (modify/delete): %s deleted in %s and modified in %s.",
+	};
+	const char *renamed_msg[] = {
+		"CONFLICT (rename/delete): %s deleted in %s and renamed in %s.",
+		"CONFLICT (modify/delete): %s deleted in %s and modified in %s.",
+	};
+
+	if (!strcmp(change, "rename"))
+		idx = 0;
+	else if (!strcmp(change, "modify"))
+		idx = 1;
+	else
+		die("BUG: unsupport action %s", change);
+
 	if (dir_in_way(path, !o->call_depth)) {
 		renamed = unique_path(o, path, a_sha ? o->branch1 : o->branch2);
 	}
@@ -1034,22 +1053,30 @@ static void handle_change_delete(struct merge_options *o,
 		remove_file_from_cache(path);
 		update_file(o, 0, o_sha, o_mode, renamed ? renamed : path);
 	} else if (!a_sha) {
-		output(o, 1, "CONFLICT (%s/delete): %s deleted in %s "
-		       "and %s in %s. Version %s of %s left in tree%s%s.",
-		       change, path, o->branch1,
-		       change_past, o->branch2, o->branch2, path,
-		       NULL == renamed ? "" : " at ",
-		       NULL == renamed ? "" : renamed);
+		if (renamed) {
+			strbuf_addf(&sb, renamed_msg[idx], path, o->branch1, o->branch2);
+			strbuf_addf(&sb, " Version %s of %s left in tree at %s.",
+				    o->branch2, path, renamed);
+		} else {
+			strbuf_addf(&sb, msg[idx], path, o->branch1, o->branch2);
+			strbuf_addf(&sb, " Version %s of %s left in tree.",
+				    o->branch2, path);
+		}
+		output(o, 1, "%s", sb.buf);
+
 		update_file(o, 0, b_sha, b_mode, renamed ? renamed : path);
 	} else {
-		output(o, 1, "CONFLICT (%s/delete): %s deleted in %s "
-		       "and %s in %s. Version %s of %s left in tree%s%s.",
-		       change, path, o->branch2,
-		       change_past, o->branch1, o->branch1, path,
-		       NULL == renamed ? "" : " at ",
-		       NULL == renamed ? "" : renamed);
-		if (renamed)
+		if (renamed) {
+			strbuf_addf(&sb, renamed_msg[idx], path, o->branch2, o->branch1);
+			strbuf_addf(&sb, " Version %s of %s left in tree at %s.",
+				    o->branch2, path, renamed);
 			update_file(o, 0, a_sha, a_mode, renamed);
+		} else {
+			strbuf_addf(&sb, msg[idx], path, o->branch2, o->branch1);
+			strbuf_addf(&sb, " Version %s of %s left in tree.",
+				    o->branch2, path);
+		}
+		output(o, 1, "%s", sb.buf);
 		/*
 		 * No need to call update_file() on path when !renamed, since
 		 * that would needlessly touch path.  We could call
@@ -1058,6 +1085,7 @@ static void handle_change_delete(struct merge_options *o,
 		 */
 	}
 	free(renamed);
+	strbuf_release(&sb);
 }
 
 static void conflict_rename_delete(struct merge_options *o,
@@ -1085,7 +1113,7 @@ static void conflict_rename_delete(struct merge_options *o,
 			     orig->sha1, orig->mode,
 			     a_sha, a_mode,
 			     b_sha, b_mode,
-			     "rename", "renamed");
+			     "rename");
 
 	if (o->call_depth) {
 		remove_file_from_cache(dest->path);
@@ -1568,7 +1596,7 @@ static void handle_modify_delete(struct merge_options *o,
 			     o_sha, o_mode,
 			     a_sha, a_mode,
 			     b_sha, b_mode,
-			     "modify", "modified");
+			     "modify");
 }
 
 static int merge_content(struct merge_options *o,
-- 
1.7.8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]