diff mbox series

[01/10] i18n: refactor "foo and bar are mutually exclusive"

Message ID 476eb77aff6fbea926eaec55c9b4febb74282ab4.1638514910.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Factorization of messages with similar meaning | expand

Commit Message

Jean-Noël AVILA Dec. 3, 2021, 7:01 a.m. UTC
From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>

Use static strings for constant parts of the sentences.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
---
 builtin/checkout.c          | 2 +-
 builtin/diff-tree.c         | 2 +-
 builtin/fetch.c             | 2 +-
 builtin/init-db.c           | 2 +-
 builtin/log.c               | 4 ++--
 builtin/submodule--helper.c | 4 ++--
 builtin/worktree.c          | 2 +-
 range-diff.c                | 2 +-
 8 files changed, 10 insertions(+), 10 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Dec. 7, 2021, 6:07 p.m. UTC | #1
On Fri, Dec 03 2021, Jean-Noël Avila via GitGitGadget wrote:

> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
>
> Use static strings for constant parts of the sentences.
>
> Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> ---
>  builtin/checkout.c          | 2 +-
>  builtin/diff-tree.c         | 2 +-
>  builtin/fetch.c             | 2 +-
>  builtin/init-db.c           | 2 +-
>  builtin/log.c               | 4 ++--
>  builtin/submodule--helper.c | 4 ++--
>  builtin/worktree.c          | 2 +-
>  range-diff.c                | 2 +-
>  8 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index cbf73b8c9f6..4bd8a57f190 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1621,7 +1621,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
>  				cb_option, toupper(cb_option));
>  
>  	if (opts->overlay_mode == 1 && opts->patch_mode)
> -		die(_("-p and --overlay are mutually exclusive"));
> +		die(_("%s and %s are mutually exclusive"), "-p", "--overlay");

It's good to do all of these, but I think we should really quote the
'%s' while at it. It also helps translators, who without that won't know
(without jumping to the source) if %s and %s are "walking" and "chewing
gum" or something like a CLI option that's quoted :)
Jean-Noël AVILA Dec. 8, 2021, 6:13 p.m. UTC | #2
On Tuesday, 7 December 2021 19:07:41 CET Ævar Arnfjörð Bjarmason wrote:
> 
> On Fri, Dec 03 2021, Jean-Noël Avila via GitGitGadget wrote:
> 
> > From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
> >
> > Use static strings for constant parts of the sentences.
> >
> > Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> > ---
> >  builtin/checkout.c          | 2 +-
> >  builtin/diff-tree.c         | 2 +-
> >  builtin/fetch.c             | 2 +-
> >  builtin/init-db.c           | 2 +-
> >  builtin/log.c               | 4 ++--
> >  builtin/submodule--helper.c | 4 ++--
> >  builtin/worktree.c          | 2 +-
> >  range-diff.c                | 2 +-
> >  8 files changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/builtin/checkout.c b/builtin/checkout.c
> > index cbf73b8c9f6..4bd8a57f190 100644
> > --- a/builtin/checkout.c
> > +++ b/builtin/checkout.c
> > @@ -1621,7 +1621,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
> >  				cb_option, toupper(cb_option));
> >  
> >  	if (opts->overlay_mode == 1 && opts->patch_mode)
> > -		die(_("-p and --overlay are mutually exclusive"));
> > +		die(_("%s and %s are mutually exclusive"), "-p", "--overlay");
> 
> It's good to do all of these, but I think we should really quote the
> '%s' while at it. It also helps translators, who without that won't know
> (without jumping to the source) if %s and %s are "walking" and "chewing
> gum" or something like a CLI option that's quoted :)
> 

With other comments included,  the proposition for this factorization would be:

"the options '%s' and '%s' cannot be used together"
diff mbox series

Patch

diff --git a/builtin/checkout.c b/builtin/checkout.c
index cbf73b8c9f6..4bd8a57f190 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1621,7 +1621,7 @@  static int checkout_main(int argc, const char **argv, const char *prefix,
 				cb_option, toupper(cb_option));
 
 	if (opts->overlay_mode == 1 && opts->patch_mode)
-		die(_("-p and --overlay are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "-p", "--overlay");
 
 	if (opts->checkout_index >= 0 || opts->checkout_worktree >= 0) {
 		if (opts->checkout_index < 0)
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index f33d30d57bf..08d5477486a 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -152,7 +152,7 @@  int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	}
 
 	if (read_stdin && merge_base)
-		die(_("--stdin and --merge-base are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "--stdin", "--merge-base");
 	if (merge_base && opt->pending.nr != 2)
 		die(_("--merge-base only works with two commits"));
 
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f7abbc31ff1..bec3cc7535e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2012,7 +2012,7 @@  int cmd_fetch(int argc, const char **argv, const char *prefix)
 		if (deepen_relative < 0)
 			die(_("Negative depth in --deepen is not supported"));
 		if (depth)
-			die(_("--deepen and --depth are mutually exclusive"));
+			die(_("%s and %s are mutually exclusive"), "--deepen", "--depth");
 		depth = xstrfmt("%d", deepen_relative);
 	}
 	if (unshallow) {
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 2167796ff2a..1439e05c93d 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -557,7 +557,7 @@  int cmd_init_db(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
 
 	if (real_git_dir && is_bare_repository_cfg == 1)
-		die(_("--separate-git-dir and --bare are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "--separate-git-dir", "--bare");
 
 	if (real_git_dir && !is_absolute_path(real_git_dir))
 		real_git_dir = real_pathdup(real_git_dir, 1);
diff --git a/builtin/log.c b/builtin/log.c
index f75d87e8d7f..a2005e3c778 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1928,9 +1928,9 @@  int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		numbered = 0;
 
 	if (numbered && keep_subject)
-		die(_("-n and -k are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "-n", "-k");
 	if (keep_subject && subject_prefix)
-		die(_("--subject-prefix/--rfc and -k are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "--subject-prefix/--rfc", "-k");
 	rev.preserve_subject = keep_subject;
 
 	argc = setup_revisions(argc, argv, &rev, &s_r_opt);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index e630f0c730e..beedd873894 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1313,7 +1313,7 @@  static int module_summary(int argc, const char **argv, const char *prefix)
 
 	if (files) {
 		if (cached)
-			die(_("--cached and --files are mutually exclusive"));
+			die(_("%s and %s are mutually exclusive"), "--cached", "--files");
 		diff_cmd = DIFF_FILES;
 	}
 
@@ -2971,7 +2971,7 @@  static int module_set_branch(int argc, const char **argv, const char *prefix)
 		die(_("--branch or --default required"));
 
 	if (opt_branch && opt_default)
-		die(_("--branch and --default are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "--branch", "--default");
 
 	if (argc != 1 || !(path = argv[0]))
 		usage_with_options(usage, options);
diff --git a/builtin/worktree.c b/builtin/worktree.c
index d22ece93e1a..9287c455594 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -700,7 +700,7 @@  static int list(int ac, const char **av, const char *prefix)
 	if (ac)
 		usage_with_options(worktree_usage, options);
 	else if (verbose && porcelain)
-		die(_("--verbose and --porcelain are mutually exclusive"));
+		die(_("%s and %s are mutually exclusive"), "--verbose", "--porcelain");
 	else {
 		struct worktree **worktrees = get_worktrees();
 		int path_maxlen = 0, abbrev = DEFAULT_ABBREV, i;
diff --git a/range-diff.c b/range-diff.c
index cac89a2f4f2..bd954988e0f 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -556,7 +556,7 @@  int show_range_diff(const char *range1, const char *range2,
 	struct string_list branch2 = STRING_LIST_INIT_DUP;
 
 	if (range_diff_opts->left_only && range_diff_opts->right_only)
-		res = error(_("--left-only and --right-only are mutually exclusive"));
+		res = error(_("%s and %s are mutually exclusive"), "--left-only", "--right-only");
 
 	if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg))
 		res = error(_("could not parse log for '%s'"), range1);