diff mbox series

[v2,06/11] i18n: factorize "--foo requires --bar" and the like

Message ID f83ed5cb7995e2ce3c9aac9eb4971f45bcf94e89.1640647438.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Factorization of messages with similar meaning | expand

Commit Message

Jean-Noël Avila Dec. 27, 2021, 11:23 p.m. UTC
From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
---
 archive.c             | 2 +-
 builtin/add.c         | 4 ++--
 builtin/checkout.c    | 2 +-
 builtin/commit.c      | 2 +-
 builtin/fast-export.c | 2 +-
 builtin/index-pack.c  | 2 +-
 builtin/log.c         | 2 +-
 builtin/reset.c       | 4 ++--
 builtin/rm.c          | 2 +-
 builtin/stash.c       | 2 +-
 builtin/worktree.c    | 2 +-
 fetch-pack.c          | 2 +-
 http-fetch.c          | 4 ++--
 13 files changed, 16 insertions(+), 16 deletions(-)

Comments

Johannes Sixt Dec. 28, 2021, 7:01 a.m. UTC | #1
Am 28.12.21 um 00:23 schrieb Jean-Noël Avila via GitGitGadget:
> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
> 
> Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>

Two questions:

- Is "%s requires %s" already used elsewhere or is it a new translatable
string? The commit message should clarify the choice.

- Do translators know that the two %s will be substituted with options
(mostly)?

> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -297,7 +297,7 @@ static int find_common(struct fetch_negotiator *negotiator,
>  	struct packet_reader reader;
>  
>  	if (args->stateless_rpc && multi_ack == 1)
> -		die(_("--stateless-rpc requires multi_ack_detailed"));
> +		die(_("%s requires %s"), "--stateless-rpc", "multi_ack_detailed");

Here, the second %s is not an option. I hope that does not invalidate
any translation of the string.

-- Hannes
Jean-Noël Avila Dec. 29, 2021, 2:02 p.m. UTC | #2
On Tuesday, 28 December 2021 08:01:30 CET Johannes Sixt wrote:
> Am 28.12.21 um 00:23 schrieb Jean-Noël Avila via GitGitGadget:
> > From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
> > 
> > Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> 
> Two questions:
> 
> - Is "%s requires %s" already used elsewhere or is it a new translatable
> string? The commit message should clarify the choice.

%s requires %s is a new translatable string. Will update.

> 
> - Do translators know that the two %s will be substituted with options
> (mostly)?

Indeed this is not clear. So we should apply the same transformation as for "cannot be used together"

> 
> > --- a/fetch-pack.c
> > +++ b/fetch-pack.c
> > @@ -297,7 +297,7 @@ static int find_common(struct fetch_negotiator *negotiator,
> >  	struct packet_reader reader;
> >  
> >  	if (args->stateless_rpc && multi_ack == 1)
> > -		die(_("--stateless-rpc requires multi_ack_detailed"));
> > +		die(_("%s requires %s"), "--stateless-rpc", "multi_ack_detailed");
> 
> Here, the second %s is not an option. I hope that does not invalidate
> any translation of the string.

True. So let's use "the option '%s' requires '%s'" instead.

> 
> -- Hannes
>
diff mbox series

Patch

diff --git a/archive.c b/archive.c
index 78d35467008..6fd4d951bd9 100644
--- a/archive.c
+++ b/archive.c
@@ -577,7 +577,7 @@  static int parse_archive_args(int argc, const char **argv,
 	if (remote)
 		die(_("Unexpected option --remote"));
 	if (exec)
-		die(_("Option --exec can only be used together with --remote"));
+		die(_("%s requires %s"), "--exec", "--remote");
 	if (output)
 		die(_("Unexpected option --output"));
 	if (is_remote && args->extra_files.nr)
diff --git a/builtin/add.c b/builtin/add.c
index 4b2754345ad..b505eca3d4d 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -541,7 +541,7 @@  int cmd_add(int argc, const char **argv, const char *prefix)
 		die(_("options '%s' and '%s' cannot be used together"), "-A", "-u");
 
 	if (!show_only && ignore_missing)
-		die(_("Option --ignore-missing can only be used together with --dry-run"));
+		die(_("%s requires %s"), "--ignore-missing", "--dry-run");
 
 	if (chmod_arg && ((chmod_arg[0] != '-' && chmod_arg[0] != '+') ||
 			  chmod_arg[1] != 'x' || chmod_arg[2]))
@@ -573,7 +573,7 @@  int cmd_add(int argc, const char **argv, const char *prefix)
 				    PATHSPEC_SYMLINK_LEADING_PATH,
 				    prefix, pathspec_from_file, pathspec_file_nul);
 	} else if (pathspec_file_nul) {
-		die(_("--pathspec-file-nul requires --pathspec-from-file"));
+		die(_("%s requires %s"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
 	if (require_pathspec && pathspec.nr == 0) {
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2d7bfbd0f1a..d005aaad9f2 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1758,7 +1758,7 @@  static int checkout_main(int argc, const char **argv, const char *prefix,
 				    0,
 				    prefix, opts->pathspec_from_file, opts->pathspec_file_nul);
 	} else if (opts->pathspec_file_nul) {
-		die(_("--pathspec-file-nul requires --pathspec-from-file"));
+		die(_("%s requires %s"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
 	opts->pathspec.recursive = 1;
diff --git a/builtin/commit.c b/builtin/commit.c
index 5c1aaa42131..eb803a96ae3 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -367,7 +367,7 @@  static const char *prepare_index(const char **argv, const char *prefix,
 				    PATHSPEC_PREFER_FULL,
 				    prefix, pathspec_from_file, pathspec_file_nul);
 	} else if (pathspec_file_nul) {
-		die(_("--pathspec-file-nul requires --pathspec-from-file"));
+		die(_("%s requires %s"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
 	if (!pathspec.nr && (also || (only && !allow_empty &&
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 1f8fe7b3ac1..a1eba9298a4 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -1254,7 +1254,7 @@  int cmd_fast_export(int argc, const char **argv, const char *prefix)
 		usage_with_options (fast_export_usage, options);
 
 	if (anonymized_seeds.cmpfn && !anonymize)
-		die(_("--anonymize-map without --anonymize does not make sense"));
+		die(_("%s requires %s"), "--anonymize-map", "--anonymize");
 
 	if (refspecs_list.nr) {
 		int i;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 30ce2ac746d..6845bcb41af 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1845,7 +1845,7 @@  int cmd_index_pack(int argc, const char **argv, const char *prefix)
 	if (!pack_name && !from_stdin)
 		usage(index_pack_usage);
 	if (fix_thin_pack && !from_stdin)
-		die(_("--fix-thin cannot be used without --stdin"));
+		die(_("%s requires %s"), "--fix-thin", "--stdin");
 	if (from_stdin && !startup_info->have_repository)
 		die(_("--stdin requires a git repository"));
 	if (from_stdin && hash_algo)
diff --git a/builtin/log.c b/builtin/log.c
index 705d58110b0..8fe51bc8afb 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -2112,7 +2112,7 @@  int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	if (creation_factor < 0)
 		creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
 	else if (!rdiff_prev)
-		die(_("--creation-factor requires --range-diff"));
+		die(_("%s requires %s"), "--creation-factor", "--range-diff");
 
 	if (rdiff_prev) {
 		if (!cover_letter && total != 1)
diff --git a/builtin/reset.c b/builtin/reset.c
index 248998fd6fa..25f52ea99f6 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -432,7 +432,7 @@  int cmd_reset(int argc, const char **argv, const char *prefix)
 				    PATHSPEC_PREFER_FULL,
 				    prefix, pathspec_from_file, pathspec_file_nul);
 	} else if (pathspec_file_nul) {
-		die(_("--pathspec-file-nul requires --pathspec-from-file"));
+		die(_("%s requires %s"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
 	unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid);
@@ -490,7 +490,7 @@  int cmd_reset(int argc, const char **argv, const char *prefix)
 		    _(reset_type_names[reset_type]));
 
 	if (intent_to_add && reset_type != MIXED)
-		die(_("-N can only be used with --mixed"));
+		die(_("%s requires %s"), "-N", "--mixed");
 
 	prepare_repo_settings(the_repository);
 	the_repository->settings.command_requires_full_index = 0;
diff --git a/builtin/rm.c b/builtin/rm.c
index 3d0967cdc11..38ac3c71252 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -278,7 +278,7 @@  int cmd_rm(int argc, const char **argv, const char *prefix)
 				    PATHSPEC_PREFER_CWD,
 				    prefix, pathspec_from_file, pathspec_file_nul);
 	} else if (pathspec_file_nul) {
-		die(_("--pathspec-file-nul requires --pathspec-from-file"));
+		die(_("%s requires %s"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
 	if (!pathspec.nr)
diff --git a/builtin/stash.c b/builtin/stash.c
index 4d793bd0b52..7ad2f9aca87 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1712,7 +1712,7 @@  static int push_stash(int argc, const char **argv, const char *prefix,
 				    PATHSPEC_PREFER_FULL | PATHSPEC_PREFIX_ORIGIN,
 				    prefix, pathspec_from_file, pathspec_file_nul);
 	} else if (pathspec_file_nul) {
-		die(_("--pathspec-file-nul requires --pathspec-from-file"));
+		die(_("%s requires %s"), "--pathspec-file-nul", "--pathspec-from-file");
 	}
 
 	return do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode,
diff --git a/builtin/worktree.c b/builtin/worktree.c
index b5ef19b2dda..bce01c8a671 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -505,7 +505,7 @@  static int add(int ac, const char **av, const char *prefix)
 	if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
 		die(_("options '%s', '%s' and '%s' cannot be used together"), "-b", "-B", "--detach");
 	if (lock_reason && !keep_locked)
-		die(_("--reason requires --lock"));
+		die(_("%s requires %s"), "--reason", "--lock");
 	if (lock_reason)
 		opts.keep_locked = lock_reason;
 	else if (keep_locked)
diff --git a/fetch-pack.c b/fetch-pack.c
index 34987a2c30d..0a5dfea9377 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -297,7 +297,7 @@  static int find_common(struct fetch_negotiator *negotiator,
 	struct packet_reader reader;
 
 	if (args->stateless_rpc && multi_ack == 1)
-		die(_("--stateless-rpc requires multi_ack_detailed"));
+		die(_("%s requires %s"), "--stateless-rpc", "multi_ack_detailed");
 
 	packet_reader_init(&reader, fd[0], NULL, 0,
 			   PACKET_READ_CHOMP_NEWLINE |
diff --git a/http-fetch.c b/http-fetch.c
index c7c7d391ac5..eab45d2cc07 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -141,7 +141,7 @@  int cmd_main(int argc, const char **argv)
 
 	if (packfile) {
 		if (!index_pack_args.nr)
-			die(_("--packfile requires --index-pack-args"));
+			die(_("%s requires %s"), "--packfile", "--index-pack-args");
 
 		fetch_single_packfile(&packfile_hash, argv[arg],
 				      index_pack_args.v);
@@ -150,7 +150,7 @@  int cmd_main(int argc, const char **argv)
 	}
 
 	if (index_pack_args.nr)
-		die(_("--index-pack-args can only be used with --packfile"));
+		die(_("%s requires %s"), "--index-pack-args", "--packfile");
 
 	if (commits_on_stdin) {
 		commits = walker_targets_stdin(&commit_id, &write_ref);