There is a nice feature in bash, about localization (language translation):
TEXTDOMAIN=coreutils
LANG=fr_CH.utf8
echo $\"system boot\"
démarrage système
If using eval is bad with arbitrary variables, there is a way to do this only when called/needed, in running eval only on message part:
function lPrintf() {
local sFormat="$(
eval 'echo $"'"${1}"'"'.
)"
shift
printf "${sFormat%.}" $@
}
lPrintf "system boot"
démarrage système
lPrintf $'Written by %s, %s, %s,\nand %s.\n' techno moi lui-même bibi
Écrit par techno, moi, lui-même,
et bibi.
( The dot at end of translated string ensure that whole string, including leading line-break, where passed to variable sFormat. They will be dropped with ${sFormat%.} )