[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettext feature request

From: Eli Schwartz
Subject: Re: gettext feature request
Date: Sat, 14 Aug 2021 22:39:32 -0400

On 8/13/21 2:01 PM, Léa Gris wrote:
> I would have really loved if Bash expanded translations with its
> built-in printf using a `-g` flag for gettext and positional arguments
> support instead of expanding string literal translations.
> It would have allowed something like :
> ```sh
> #!/usr/bine/env bash
> # -g Gettext translation of Hello World into variable my_string
> printf -v my_string -g 'Hello World!'
> # Printout using gettext translated format string
> printf -g 'String %1$q has %2$d characters\n' "$my_string" "${#my_string}"
> ```

What would be the point of adding a -g option to printf, which duplicates:

printf -v my_string $"Hello World!"

printf $"String %1\$q has %2\$d characters\n" "$my_string" "${#my_string}"

And then, since you are relying on a separate feature from translation
altogether, that of re-ordered input parameters to printf, ask for that
to be added, which is currently a fatal error:

bash: printf: `$': invalid format character

and doesn't require adding a new option to printf just for the use of

Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]