diff mbox series

[05/10] i18n: tag.c factorize i18n strings

Message ID b67f0e492e0d9a32f0be9ae085ea3d31135567d5.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>

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
---
 builtin/tag.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Dec. 7, 2021, 6:10 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>
>
> Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> ---
>  builtin/tag.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/tag.c b/builtin/tag.c
> index 41941d5129f..6415d6c81a2 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -543,13 +543,13 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
>  		goto cleanup;
>  	}
>  	if (filter.lines != -1)
> -		die(_("-n option is only allowed in list mode"));
> +		die(_("%s option is only allowed in list mode"), "-n");
>  	if (filter.with_commit)
> -		die(_("--contains option is only allowed in list mode"));
> +		die(_("%s option is only allowed in list mode"), "--contains");
>  	if (filter.no_commit)
> -		die(_("--no-contains option is only allowed in list mode"));
> +		die(_("%s option is only allowed in list mode"), "--no-contains");
>  	if (filter.points_at.nr)
> -		die(_("--points-at option is only allowed in list mode"));
> +		die(_("%s option is only allowed in list mode"), "--points-at");
>  	if (filter.reachable_from || filter.unreachable_from)
>  		die(_("--merged and --no-merged options are only allowed in list mode"));
>  	if (cmdmode == 'd') {

Since for all of these we're asking translators to re-do some work
(albeit with translation memory) this could use a bit of grammar
improvement. E.g.:

    _("the '%s' option is only allowed in list mode'")

I.e. "blah option is only" without a "the" is a bit odd.

But also for this & various other boilerplate in this series, I think it
would be much better as say:

    const char *only_in_list = NULL;
    if (...)
        only_in_list = "-n";
    else if (...)
        only_in_list = "--contains";
    [...]
    if (only_in_list)
        die(__("the '%s' option [...]"), only_in_list);

I.e. we're buying ourselves the chance to easily get a rid of a lot of
this repetition, but aren't using it. I think a series like this should
probably resist some big refactorings, but things like that would be
pretty easy & make the code more readable.
diff mbox series

Patch

diff --git a/builtin/tag.c b/builtin/tag.c
index 41941d5129f..6415d6c81a2 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -543,13 +543,13 @@  int cmd_tag(int argc, const char **argv, const char *prefix)
 		goto cleanup;
 	}
 	if (filter.lines != -1)
-		die(_("-n option is only allowed in list mode"));
+		die(_("%s option is only allowed in list mode"), "-n");
 	if (filter.with_commit)
-		die(_("--contains option is only allowed in list mode"));
+		die(_("%s option is only allowed in list mode"), "--contains");
 	if (filter.no_commit)
-		die(_("--no-contains option is only allowed in list mode"));
+		die(_("%s option is only allowed in list mode"), "--no-contains");
 	if (filter.points_at.nr)
-		die(_("--points-at option is only allowed in list mode"));
+		die(_("%s option is only allowed in list mode"), "--points-at");
 	if (filter.reachable_from || filter.unreachable_from)
 		die(_("--merged and --no-merged options are only allowed in list mode"));
 	if (cmdmode == 'd') {