From: Junio C Hamano <gitster@pobox.com>
To: Alexander Shopov <ash@kambanaria.org>
Cc: git@vger.kernel.org, worldhello.net@gmail.com
Subject: Re: [PATCH 2 1/1] parse-options: allow localized substitution hints in macros
Date: Mon, 27 May 2024 11:14:55 -0700 [thread overview]
Message-ID: <xmqqttij86lc.fsf@gitster.g> (raw)
In-Reply-To: <20240525122514.2608-2-ash@kambanaria.org> (Alexander Shopov's message of "Sat, 25 May 2024 14:24:38 +0200")
Alexander Shopov <ash@kambanaria.org> writes:
> Subject: Re: [PATCH 2 1/1] parse-options: allow localized substitution hints in macros
These are not "macros", though. Perhaps
parse-options: localize marking-up of placeholder text in the short help
or something? As to the body of the proposed log message, I've
covered it in my respoinse of the cover letter.
> diff --git a/parse-options.c b/parse-options.c
> index 30b9e68f8a..06d962b00e 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -1070,11 +1070,17 @@ static int usage_argh(const struct option *opts, FILE *outfile)
> !opts->argh || !!strpbrk(opts->argh, "()<>[]|");
> if (opts->flags & PARSE_OPT_OPTARG)
> if (opts->long_name)
> - s = literal ? "[=%s]" : "[=<%s>]";
> + s = literal ? "[=%s]" :
> + /* TRANSLATORS: change `<>' to other characters or leave as is */
> + _("[=<%s>]");
> else
> - s = literal ? "[%s]" : "[<%s>]";
> + s = literal ? "[%s]" :
> + /* TRANSLATORS: change `<>' to other characters or leave as is */
> + _("[<%s>]");
> else
> - s = literal ? " %s" : " <%s>";
> + s = literal ? " %s" :
> + /* TRANSLATORS: change `<>' to other characters or leave as is */
> + _(" <%s>");
> return utf8_fprintf(outfile, s, opts->argh ? _(opts->argh) : _("..."));
> }
Just like user's language may use a convention different from
enclosing it in a pair of <angle brackets> to mark a placeholder
text, the use of [square brackets] to mark an optional part may
have different per-language counterpart, no?
The above change, on the side that handles PARSE_OPT_OPTARG case,
already allows "[=<%s>]" to be translated, but the translator hints
can and should clarify that possibility as well, no?
/* TRANSLATORS: change [] and <> mark-up, if necessary */
The SP that appears before <%s> on the mandatory argument side MUST
NOT be translated. To go back to the "--author <author>" example I
gave in my response for the cover letter, when the program says:
OPT_STRING(0, "author", &au, N_("author"), N_("override author")),
in the output of "git commit -h", we give
--[no-]author <AUTHOR> OVERRIDE AUTHOR
where I used uppercase letters for the translated string. The SP
before <%s> in " <%s>" is what we see after "--[no-]author" in the
output.
So, if we were to allow localizing this truly, probably the "else"
clause needs a bit more work, e.g.
if (opts->flags & PARSE_OPT_OPTARG) {
...
} else {
s = literal
? "%s"
: _("<%s>");
fputc(' ', outfile);
}
The "=" that appears before %s should NOT be translated for exactly
the same reason. If --author were an option that took an optional
argument, "git commit -h" would have given
--[no-]author[=<AUTHOR>] OVERRIDE AUTHOR
No matter what language the user writes, the user MUST write '='
after "--author" if he or she wants to give an optional argument to
the option. So some care must be taken to make sure they keep '='
even if they were to translate _("[=<%s>]"). The easiest way to do
so may be to punt and *tell* them (without us having a way to make
sure that they followed what we told them to), e.g.
s = literal
? "[=%s]"
/*
* TRANSLATORS: change [] that signals optional-ness, and
* <> that signal placeholder-ness, of what is enclosed
* as necessary to match your locale's convention. Do not
* move or change '='; no matter what your language is, the
* equal sign MUST be the first character in the optional
* string.
*/
: _("[=<%s>]");
Other than the above two points on the " " and "=" that must not be
changed, the intent of this change looks very good to me.
Thanks.
next prev parent reply other threads:[~2024-05-27 18:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-21 19:14 [[PATCH] [RESUBMIT 2nd] Consistency for substitution hints (i18n) 0/1] Alexander Shopov
2024-04-21 19:14 ` [[PATCH] [RESUBMIT 2nd] Consistency for substitution hints (i18n) 1/1] parse-options: use localized substitution hints Alexander Shopov
2024-04-21 19:33 ` Junio C Hamano
2024-05-25 12:24 ` [PATCH 2 0/1] Allowing localized substitution hints in parse-options Alexander Shopov
2024-05-27 18:14 ` Junio C Hamano
2024-05-28 0:47 ` Jiang Xin
2024-05-25 12:24 ` [PATCH 2 1/1] parse-options: allow localized substitution hints in macros Alexander Shopov
2024-05-27 18:14 ` Junio C Hamano [this message]
2024-07-07 15:35 ` [PATCH 3 0/1] parse-options: localize mark-up of placeholder text in the short help Alexander Shopov
2024-07-07 15:35 ` [PATCH 3 1/1] " Alexander Shopov
2024-07-14 20:41 ` Alexander Shopov
2024-07-15 15:39 ` Junio C Hamano
2024-12-28 11:42 ` [PATCH 4 0/1] Localize " Alexander Shopov
2024-12-28 11:42 ` [PATCH 4 1/1] parse-options: localize " Alexander Shopov
2024-12-28 16:55 ` Junio C Hamano
[not found] ` <CAP6f5MkYL8PgRyf_paCYxL-LE5nUa2U1GQMsu2scLzJPSS=9Ag@mail.gmail.com>
2024-12-30 3:02 ` Jiang Xin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqttij86lc.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ash@kambanaria.org \
--cc=git@vger.kernel.org \
--cc=worldhello.net@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).