diff mbox series

[v2,4/6] i18n: factorize "foo does not take arguments" messages

Message ID 6221c37145c22a79bc1598be1e82be50d61636cc.1648915853.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series More i18n fixes | expand

Commit Message

Jean-Noël Avila April 2, 2022, 4:10 p.m. UTC
From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>

The messages are split into the ones for ref-filter which deal with
atoms and scalar which has an option.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
---
 contrib/scalar/scalar.c | 2 +-
 ref-filter.c            | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Ævar Arnfjörð Bjarmason April 3, 2022, 2:39 p.m. UTC | #1
On Sat, Apr 02 2022, Jean-Noël Avila via GitGitGadget wrote:

> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
>
> The messages are split into the ones for ref-filter which deal with
> atoms and scalar which has an option.

I see the git-for-each-ref manpage doesn't really refer to these
consistently, but I tihnk s/atom/format/g or s/atom/name/g would be lot
more obvious, especially in the context of how these are already
discussed in the manpage.

> @@ -317,7 +317,7 @@ static int objecttype_atom_parser(struct ref_format *format, struct used_atom *a
>  				  const char *arg, struct strbuf *err)
>  {
>  	if (arg)
> -		return strbuf_addf_ret(err, -1, _("%%(objecttype) does not take arguments"));
> +		return strbuf_addf_ret(err, -1, _("the atom '%s' does not take arguments"), "%(objecttype)");
>  	if (*atom->name == '*')
>  		oi_deref.info.typep = &oi_deref.type;
>  	else
Junio C Hamano April 3, 2022, 10:21 p.m. UTC | #2
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> On Sat, Apr 02 2022, Jean-Noël Avila via GitGitGadget wrote:
>
>> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
>>
>> The messages are split into the ones for ref-filter which deal with
>> atoms and scalar which has an option.
>
> I see the git-for-each-ref manpage doesn't really refer to these
> consistently, but I tihnk s/atom/format/g or s/atom/name/g would be lot
> more obvious, especially in the context of how these are already
> discussed in the manpage.

I do not necessarily think so, even though "atom" is a word that
directly faces those who wrote the code in for-each-ref.c that have
been moved to ref-filter.c and not the end users.

These are only parts of a string that is given to --format=..., so
"format" makes it more confusing than even the original.

I can buy

    '%(objectype)' in format does not take arguments

though.  If you did not find a specific word to refer to these
"field names" that the documentation consistently uses, it is a way
to clarify which '%(objecttype)' we are referring to, without having
to commit to a single word.

Or we can call them "field names" like the documentation calls them,
which would make it into

    field name '%(objecttype)' does not take arguments

which is not too bad, but I somehow find the former (i.e. "X in
format string does not take arguments") probably the easiest to
follow, if you want to change the original.

Just my 2 yen.

>> @@ -317,7 +317,7 @@ static int objecttype_atom_parser(struct ref_format *format, struct used_atom *a
>>  				  const char *arg, struct strbuf *err)
>>  {
>>  	if (arg)
>> -		return strbuf_addf_ret(err, -1, _("%%(objecttype) does not take arguments"));
>> +		return strbuf_addf_ret(err, -1, _("the atom '%s' does not take arguments"), "%(objecttype)");
>>  	if (*atom->name == '*')
>>  		oi_deref.info.typep = &oi_deref.type;
>>  	else
diff mbox series

Patch

diff --git a/contrib/scalar/scalar.c b/contrib/scalar/scalar.c
index 7db2a97416e..7ef1f141366 100644
--- a/contrib/scalar/scalar.c
+++ b/contrib/scalar/scalar.c
@@ -502,7 +502,7 @@  cleanup:
 static int cmd_list(int argc, const char **argv)
 {
 	if (argc != 1)
-		die(_("`scalar list` does not take arguments"));
+		die(_("the '%s' command does not take arguments"), "scalar list");
 
 	if (run_git("config", "--global", "--get-all", "scalar.repo", NULL) < 0)
 		return -1;
diff --git a/ref-filter.c b/ref-filter.c
index 7838bd22b8d..8497f9e25d8 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -317,7 +317,7 @@  static int objecttype_atom_parser(struct ref_format *format, struct used_atom *a
 				  const char *arg, struct strbuf *err)
 {
 	if (arg)
-		return strbuf_addf_ret(err, -1, _("%%(objecttype) does not take arguments"));
+		return strbuf_addf_ret(err, -1, _("the atom '%s' does not take arguments"), "%(objecttype)");
 	if (*atom->name == '*')
 		oi_deref.info.typep = &oi_deref.type;
 	else
@@ -349,7 +349,7 @@  static int deltabase_atom_parser(struct ref_format *format, struct used_atom *at
 				 const char *arg, struct strbuf *err)
 {
 	if (arg)
-		return strbuf_addf_ret(err, -1, _("%%(deltabase) does not take arguments"));
+		return strbuf_addf_ret(err, -1, _("the atom '%s' does not take arguments"), "%(deltabase)");
 	if (*atom->name == '*')
 		oi_deref.info.delta_base_oid = &oi_deref.delta_base_oid;
 	else
@@ -361,7 +361,7 @@  static int body_atom_parser(struct ref_format *format, struct used_atom *atom,
 			    const char *arg, struct strbuf *err)
 {
 	if (arg)
-		return strbuf_addf_ret(err, -1, _("%%(body) does not take arguments"));
+		return strbuf_addf_ret(err, -1, _("the atom '%s' does not take arguments"), "%(body)");
 	atom->u.contents.option = C_BODY_DEP;
 	return 0;
 }
@@ -565,7 +565,7 @@  static int rest_atom_parser(struct ref_format *format, struct used_atom *atom,
 			    const char *arg, struct strbuf *err)
 {
 	if (arg)
-		return strbuf_addf_ret(err, -1, _("%%(rest) does not take arguments"));
+		return strbuf_addf_ret(err, -1, _("the atom '%s' does not take arguments"), "%(rest)");
 	format->use_rest = 1;
 	return 0;
 }