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`) https://stackoverflow.com/a/14147336/1765658 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 ;; esac done shift $((OPTIND-1)) eval 'local msg=$"'"${1//[\"\$\`]}"\" shift 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 - <fe...@f-hauri.ch> - http://www.f-hauri.ch