bash localization won't work with multilines strings (with strong syntax or through `eval`)

后端 未结 4 1937
日久生厌
日久生厌 2021-01-02 02:15

There is a nice feature in bash, about localization (language translation):

TEXTDOMAIN=coreutils
LANG=fr_CH.utf8
echo $\"system boot\"
démarrage système
         


        
4条回答
  •  执笔经年
    2021-01-02 02:27

    OK I think finally got it right.

    iprintf() {
        msg="$2"
        domain="$1"
        shift
        shift
        imsg=$(gettext -ed "$domain" "$msg" ; echo EOF)
        imsg="${imsg%EOF}"
        printf "$imsg" "$@"
    }
    

    Usage example:

    LANG=fr_CH.utf8 iprintf coreutils "If FILE is not specified, use %s.  %s as FILE is common.\n\n" foo bar
    

提交回复
热议问题