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

Re: [PATCH v2 1/6] i18n: factorize generic failure messages

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 3, 2022, 14:47 UTC
Message-ID
<220403.86k0c6kyi5.gmgdl@evledraar.gmail.com>
In-Reply-To
<4bba3e1f6cb9cdc35b0dc8da440e38de256b4d2b.1648915853.git.gitgitgadget@gmail.com>
On Sat, Apr 02 2022, Jean-Noël Avila via GitGitGadget wrote:
Show 37 quoted lines
> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
> [...]
> diff --git a/add-patch.c b/add-patch.c
> index 55d719f7845..8c9e81ec78e 100644
> --- a/add-patch.c
> +++ b/add-patch.c
> @@ -1181,7 +1181,7 @@ static int run_apply_check(struct add_p_state *s,
>  			    "apply", "--check", NULL);
>  	strvec_pushv(&cp.args, s->mode->apply_check_args);
>  	if (pipe_command(&cp, s->buf.buf, s->buf.len, NULL, 0, NULL, 0))
> -		return error(_("'git apply --cached' failed"));
> +		return error(_("the command '%s' failed"), "git apply --cached");
>  
>  	return 0;
>  }
> @@ -1683,7 +1683,7 @@ soft_increment:
>  			strvec_pushv(&cp.args, s->mode->apply_args);
>  			if (pipe_command(&cp, s->buf.buf, s->buf.len,
>  					 NULL, 0, NULL, 0))
> -				error(_("'git apply' failed"));
> +				error(_("the command '%s' failed"), "git apply");
>  		}
>  		if (repo_read_index(s->s.r) >= 0)
>  			repo_refresh_and_write_index(s->s.r, REFRESH_QUIET, 0,
> diff --git a/builtin/am.c b/builtin/am.c
> index 0f4111bafa0..a0a57049510 100644
> --- a/builtin/am.c
> +++ b/builtin/am.c
> @@ -586,7 +586,7 @@ static int is_mail(FILE *fp)
>  	int ret = 1;
>  
>  	if (fseek(fp, 0L, SEEK_SET))
> -		die_errno(_("fseek failed"));
> +		die_errno(_("the function '%s' failed"), "fseek");
>  
>  	if (regcomp(&regex, header_regex, REG_NOSUB | REG_EXTENDED))
>  		die("invalid pattern: %s", header_regex);

I don't think this needs to happen now, but I wonder if it would be worth it as a follow-up to e.g. create a gettext-common.h or something, with macros like:

	#define I18N_COMMAND_FAILED N_("the command '%s' failed")
	#define I18N_FUNCTION_FAILED_ERRNO N_("the library function '%s' failed")
Then:
	error(_(I18N_FUNCTION_FAILED_ERRNO), "git apply");
	die_errno(_(I18N_FUNCTION_FAILED_ERRNO), "fseek");

But OTOH all the gettext tooling already takes care of that, so maybe it's not worth it. I.e. "jump to definition" would jump to the wrapper header, as opposed to the actual code involved.

So having written that, probably not. Maybe the only worthwhile thing would be some Levenshtein distance check in CI or something to see if we're adding strings that are too similar to existing ones...

Previous: Ævar Arnfjörð BjarmasonNext: Jean-Noël Avila via GitGitGadget
Message 19 of 28 in “More i18n fixes”
  1. 0/7 More i18n fixesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  2. 1/7 i18n: factorize generic failure messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  3. 2/7 sequencer: factor GIT_AUTHOR_* from message stringsBagas Sanjaya via GitGitGadget, Mar 20, 2022
  4. Bagas SanjayaMar 21, 2022
  5. 3/7 i18n: factorize "bad argument" messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  6. 4/7 i18n: factorize "Server does not support foo" messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  7. 5/7 i18n: factorize "foo does not take arguments" messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  8. 7/7 i18n: factorize unrecognized options arguments messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  9. 6/7 i18n: factorize read-cache error messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  10. Johannes SixtMar 21, 2022
  11. Ævar Arnfjörð BjarmasonMar 21, 2022
  12. Junio C HamanoMar 21, 2022
  13. Jean-Noël AVILAMar 21, 2022
  14. Jean-Noël AVILAMar 21, 2022
  15. 0/6 More i18n fixesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  16. 1/6 i18n: factorize generic failure messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  17. Bagas SanjayaApr 3, 2022
  18. Ævar Arnfjörð BjarmasonApr 3, 2022
  19. Ævar Arnfjörð BjarmasonApr 3, 2022
  20. 3/6 i18n: factorize server support messages in fetch-packJean-Noël Avila via GitGitGadget, Apr 2, 2022
  21. 2/6 sequencer: factor GIT_AUTHOR_* from message stringsBagas Sanjaya via GitGitGadget, Apr 2, 2022
  22. 5/6 i18n: factorize read-cache error messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  23. Junio C HamanoApr 3, 2022
  24. 4/6 i18n: factorize "foo does not take arguments" messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  25. Ævar Arnfjörð BjarmasonApr 3, 2022
  26. Junio C HamanoApr 3, 2022
  27. 6/6 i18n: factorize "bad argument" messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  28. Ævar Arnfjörð BjarmasonApr 3, 2022

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.