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

Re: [PATCH v4 2/7] i18n: unpack-trees: mark strings for translation

From
Junio C Hamano <gitster@pobox.com>
Date
May 12, 2016, 22:50 UTC
Message-ID
<xmqqy47ec2n2.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1463083168-29213-3-git-send-email-vascomalmeida@sapo.pt>

I think this patch is better than what is already in 'next', so let me see if I can make it into an incremental update.

We'd need your sign-off, of course.
-- >8 --
Subject: i18n: unpack-trees: avoid substituting only a verb in sentences

Instead of reusing the same set of message templates for checkout and other actions and substituting the verb with "%s", prepare separate message templates for each known action. That would make it easier for translation into languages where the same verb may conjugate differently depending on the message we are giving.

---
diff --git a/unpack-trees.c b/unpack-trees.c
index 4bc6b4f..edb1ee5 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -58,27 +58,61 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
 	int i;
 	const char **msgs = opts->msgs;
 	const char *msg;
-	const char *cmd2 = strcmp(cmd, "checkout") ? cmd : "switch branches";
 
-	if (advice_commit_before_merge)
-		msg = _("Your local changes to the following files would be overwritten by %s:\n%%s"
-			"Please, commit your changes or stash them before you can %s.");
+	if (!strcmp(cmd, "checkout"))
+		msg = advice_commit_before_merge
+		      ? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
+			  "Please, commit your changes or stash them before you can switch branches.")
+		      : _("Your local changes to the following files would be overwritten by checkout:\n%%s");
+	else if (!strcmp(cmd, "merge"))
+		msg = advice_commit_before_merge
+		      ? _("Your local changes to the following files would be overwritten by merge:\n%%s"
+			  "Please, commit your changes or stash them before you can merge.")
+		      : _("Your local changes to the following files would be overwritten by merge:\n%%s");
 	else
-		msg = _("Your local changes to the following files would be overwritten by %s:\n%%s");
+		msg = advice_commit_before_merge
+		      ? _("Your local changes to the following files would be overwritten by %s:\n%%s"
+			  "Please, commit your changes or stash them before you can %s.")
+		      : _("Your local changes to the following files would be overwritten by %s:\n%%s");
 	msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] =
-		xstrfmt(msg, cmd, cmd2);
+		xstrfmt(msg, cmd, cmd);
 
 	msgs[ERROR_NOT_UPTODATE_DIR] =
 		_("Updating the following directories would lose untracked files in it:\n%s");
 
-	if (advice_commit_before_merge)
-		msg = _("The following untracked working tree files would be %s by %s:\n%%s"
-			"Please move or remove them before you can %s.");
+	if (!strcmp(cmd, "checkout"))
+		msg = advice_commit_before_merge
+		      ? _("The following untracked working tree files would be removed by checkout:\n%%s"
+			  "Please move or remove them before you can switch branches.")
+		      : _("The following untracked working tree files would be removed by checkout:\n%%s");
+	else if (!strcmp(cmd, "merge"))
+		msg = advice_commit_before_merge
+		      ? _("The following untracked working tree files would be removed by merge:\n%%s"
+			  "Please move or remove them before you can merge.")
+		      : _("The following untracked working tree files would be removed by merge:\n%%s");
 	else
-		msg = _("The following untracked working tree files would be %s by %s:\n%%s");
-
-	msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = xstrfmt(msg, "removed", cmd, cmd2);
-	msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = xstrfmt(msg, "overwritten", cmd, cmd2);
+		msg = advice_commit_before_merge
+		      ? _("The following untracked working tree files would be removed by %s:\n%%s"
+			  "Please move or remove them before you can %s.")
+		      : _("The following untracked working tree files would be removed by %s:\n%%s");
+	msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = xstrfmt(msg, cmd, cmd);
+
+	if (!strcmp(cmd, "checkout"))
+		msg = advice_commit_before_merge
+		      ? _("The following untracked working tree files would be overwritten by checkout:\n%%s"
+			  "Please move or remove them before you can switch branches.")
+		      : _("The following untracked working tree files would be overwritten by checkout:\n%%s");
+	else if (!strcmp(cmd, "merge"))
+		msg = advice_commit_before_merge
+		      ? _("The following untracked working tree files would be overwritten by merge:\n%%s"
+			  "Please move or remove them before you can merge.")
+		      : _("The following untracked working tree files would be overwritten by merge:\n%%s");
+	else
+		msg = advice_commit_before_merge
+		      ? _("The following untracked working tree files would be overwritten by %s:\n%%s"
+			  "Please move or remove them before you can %s.")
+		      : _("The following untracked working tree files would be overwritten by %s:\n%%s");
+	msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = xstrfmt(msg, cmd, cmd);
 
 	/*
 	 * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we
Previous: Vasco AlmeidaNext: Vasco Almeida
Message 13 of 23 in “i18n: index-pack: use plural string instead of normal one”
  1. 1/7 i18n: index-pack: use plural string instead of normal oneVasco Almeida, Apr 19, 2016
  2. 2/7 i18n: unpack-trees: mark strings for translationVasco Almeida, Apr 19, 2016
  3. 3/7 i18n: git-parse-remote.sh: mark strings for translationVasco Almeida, Apr 19, 2016
  4. 4/7 i18n: builtin/pull.c: mark placeholders for translationVasco Almeida, Apr 19, 2016
  5. 5/7 i18n: builtin/pull.c: split strings marked for translationVasco Almeida, Apr 19, 2016
  6. 6/7 i18n: builtin/rm.c: remove a comma ',' from stringVasco Almeida, Apr 19, 2016
  7. 7/7 i18n: builtin/branch.c: mark option for translationVasco Almeida, Apr 19, 2016
  8. Junio C HamanoApr 19, 2016
  9. Junio C HamanoApr 19, 2016
  10. 0/7 i18n miscellaneous updatesVasco Almeida, May 12, 2016
  11. 1/7 i18n: index-pack: use plural string instead of normal oneVasco Almeida, May 12, 2016
  12. 2/7 i18n: unpack-trees: mark strings for translationVasco Almeida, May 12, 2016
  13. Junio C HamanoMay 12, 2016
  14. i18n: unpack-trees: avoid substituting only a verb in sentencesVasco Almeida, May 12, 2016
  15. Junio C HamanoMay 12, 2016
  16. Junio C HamanoMay 12, 2016
  17. 3/7 i18n: git-parse-remote.sh: mark strings for translationVasco Almeida, May 12, 2016
  18. 4/7 i18n: builtin/pull.c: mark placeholders for translationVasco Almeida, May 12, 2016
  19. 5/7 i18n: builtin/pull.c: split strings marked for translationVasco Almeida, May 12, 2016
  20. 6/7 i18n: builtin/rm.c: remove a comma ',' from stringVasco Almeida, May 12, 2016
  21. Junio C HamanoMay 12, 2016
  22. 7/7 i18n: builtin/branch.c: mark option for translationVasco Almeida, May 12, 2016
  23. Junio C HamanoMay 12, 2016

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.