[PATCH v3 1/7] i18n: index-pack: use plural string instead of normal one

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[PATCH] i18n: unpack-trees: avoid substituting only a verb in sentences

Vasco Almeida
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.

See gettext documentation for details:
http://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html

Helped-by: Junio C Hamano <[hidden email]>
Signed-off-by: Vasco Almeida <[hidden email]>
---

I removed "Please," in favor of "Please" as Junio C Hamano sugested.

 unpack-trees.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 47 insertions(+), 13 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 630a8cf..6bc9512 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
--
2.7.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] i18n: unpack-trees: avoid substituting only a verb in sentences

Junio C Hamano
Vasco Almeida <[hidden email]> writes:

> 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.
>
> See gettext documentation for details:
> http://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html
>
> Helped-by: Junio C Hamano <[hidden email]>
> Signed-off-by: Vasco Almeida <[hidden email]>
> ---
>
> I removed "Please," in favor of "Please" as Junio C Hamano sugested.

Thanks.  I think we should squash the following in, as all these
messages are now i18ned and without being marked with test_i18ncmp,
GETTEXT_POISON build would fail to pass these tests.

 t/t7609-merge-co-error-msgs.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/t/t7609-merge-co-error-msgs.sh b/t/t7609-merge-co-error-msgs.sh
index 0e4a682..6729cb3 100755
--- a/t/t7609-merge-co-error-msgs.sh
+++ b/t/t7609-merge-co-error-msgs.sh
@@ -37,14 +37,14 @@ EOF
 
 test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
  test_must_fail git merge branch 2>out &&
- test_cmp out expect &&
+ test_i18ncmp out expect &&
  git commit --allow-empty -m empty &&
  (
  GIT_MERGE_VERBOSITY=0 &&
  export GIT_MERGE_VERBOSITY &&
  test_must_fail git merge branch 2>out2
  ) &&
- test_cmp out2 expect &&
+ test_i18ncmp out2 expect &&
  git reset --hard HEAD^
 '
 
@@ -53,7 +53,7 @@ error: Your local changes to the following files would be overwritten by merge:
  four
  three
  two
-Please, commit your changes or stash them before you can merge.
+Please commit your changes or stash them before you can merge.
 error: The following untracked working tree files would be overwritten by merge:
  five
 Please move or remove them before you can merge.
@@ -65,14 +65,14 @@ test_expect_success 'untracked files or local changes ovewritten by merge' '
  git add three &&
  git add four &&
  test_must_fail git merge branch 2>out &&
- test_cmp out expect
+ test_i18ncmp out expect
 '
 
 cat >expect <<\EOF
 error: Your local changes to the following files would be overwritten by checkout:
  rep/one
  rep/two
-Please, commit your changes or stash them before you can switch branches.
+Please commit your changes or stash them before you can switch branches.
 Aborting
 EOF
 
@@ -87,21 +87,21 @@ test_expect_success 'cannot switch branches because of local changes' '
  echo uno >rep/one &&
  echo dos >rep/two &&
  test_must_fail git checkout branch 2>out &&
- test_cmp out expect
+ test_i18ncmp out expect
 '
 
 cat >expect <<\EOF
 error: Your local changes to the following files would be overwritten by checkout:
  rep/one
  rep/two
-Please, commit your changes or stash them before you can switch branches.
+Please commit your changes or stash them before you can switch branches.
 Aborting
 EOF
 
 test_expect_success 'not uptodate file porcelain checkout error' '
  git add rep/one rep/two &&
  test_must_fail git checkout branch 2>out &&
- test_cmp out expect
+ test_i18ncmp out expect
 '
 
 cat >expect <<\EOF
@@ -132,7 +132,7 @@ test_expect_success 'not_uptodate_dir porcelain checkout error' '
  >rep/untracked-file &&
  >rep2/untracked-file &&
  test_must_fail git checkout branch 2>out &&
- test_cmp out ../expect
+ test_i18ncmp out ../expect
 '
 
 test_done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] i18n: unpack-trees: avoid substituting only a verb in sentences

Junio C Hamano
Junio C Hamano <[hidden email]> writes:

> Thanks.  I think we should squash the following in, as all these
> messages are now i18ned and without being marked with test_i18ncmp,
> GETTEXT_POISON build would fail to pass these tests.

... this was not a request for you to re-send your patch with the
update to the test.  I'll just squash it in.

Thanks for the i18n updates.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
12