Merge branch 'as/long-option-help-i18n'

Tweak the help text used for the option value placeholders by
parse-options API so that translations can customize the "<>"
placeholder signal (e.g. "--option=<value>").

* as/long-option-help-i18n:
  parse-options: localize mark-up of placeholder text in the short help
This commit is contained in:
Junio C Hamano
2025-01-16 16:35:13 -08:00

View File

@ -1076,11 +1076,48 @@ 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>]";
/*
* TRANSLATORS: The "<%s>" part of this string
* stands for an optional value given to a command
* line option in the long form, and "<>" is there
* as a convention to signal that it is a
* placeholder (i.e. the user should substitute it
* with the real value). If your language uses a
* different convention, you can change "<%s>" part
* to match yours, e.g. it might use "|%s|" instead,
* or if the alphabet is different enough it may use
* "%s" without any placeholder signal. Most
* translations leave this message as is.
*/
s = literal ? "[=%s]" : _("[=<%s>]");
else
s = literal ? "[%s]" : "[<%s>]";
/*
* TRANSLATORS: The "<%s>" part of this string
* stands for an optional value given to a command
* line option in the short form, and "<>" is there
* as a convention to signal that it is a
* placeholder (i.e. the user should substitute it
* with the real value). If your language uses a
* different convention, you can change "<%s>" part
* to match yours, e.g. it might use "|%s|" instead,
* or if the alphabet is different enough it may use
* "%s" without any placeholder signal. Most
* translations leave this message as is.
*/
s = literal ? "[%s]" : _("[<%s>]");
else
s = literal ? " %s" : " <%s>";
/*
* TRANSLATORS: The "<%s>" part of this string stands for a
* value given to a command line option, and "<>" is there
* as a convention to signal that it is a placeholder
* (i.e. the user should substitute it with the real value).
* If your language uses a different convention, you can
* change "<%s>" part to match yours, e.g. it might use
* "|%s|" instead, or if the alphabet is different enough it
* may use "%s" without any placeholder signal. Most
* translations leave this message as is.
*/
s = literal ? " %s" : _(" <%s>");
return utf8_fprintf(outfile, s, opts->argh ? _(opts->argh) : _("..."));
}