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

后端 未结 4 1935
日久生厌
日久生厌 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:47

    I've played a little bit with this feature and this is what I came up with: you can include the newline verbatim as:

    $ echo $"Written by %s.
    > "
    Écrit par %s.
    $ 
    

    In a script:

    #!/bin/bash
    
    message=$"Written by %s.
    "
    
    printf "$message" Gniourf
    

    This script will output:

    Écrit par Gniourf.
    

    Ok, this is not really an answer, but it might help a little bit (at least, we're not using the evil eval).

    Personal remark: I find this feature really clunky!

提交回复
热议问题