[Top][All Lists]

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

Re: gettext feature request

From: felix
Subject: Re: gettext feature request
Date: Wed, 28 Jul 2021 10:38:32 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Jul 27, 2021 at 10:44:09PM +0200, Jean-Jacques Brucker wrote:
> I like what you wrote 12 years ago (
> https://lists.gnu.org/archive/html/bug-bash/2009-02/msg00258.html ). IMHO,
> it could have change some people's mind about bash, and could have saved
> developer energy.
> > $'...' already exists, so you can't use that for localization.

I've done a little job around *localization*, approx 8 years ago:
  bash localization won't work with multilines strings (with strong
                                                 syntax or through `eval`)

There are some interesting *works around*!

My last function is not perfect, but work on most cases:

 f() {
    local store=false OPTIND OPTARG OPTERR varname
    while getopts 'd:v:' opt ;do
        case $opt in
            d ) local TEXTDOMAIN=$OPTARG ;;
            v ) varname=$OPTARG ;;
    shift $((OPTIND-1))
    eval 'local msg=$"'"${1//[\"\$\`]}"\"
    printf ${varname+-v} $varname "$msg" "$@"
 f -d libc -v string "Permission denied"
 echo $string
 Keine Berechtigung

 f -d coreutils $'Written by %s, %s, %s,\nand %s.\n' Huey Dewey Louie Georges
 Geschrieben von Huey, Dewey, Louie
 und Georges.

 Félix Hauri  -  <felix@f-hauri.ch>  -  http://www.f-hauri.ch

reply via email to

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