You are not logged in.
I have some colors defined out of the function and also a function where I want to use these colors and localize the string where I use them:
. gettext.sh
(...)
CC="\033[1;36m"
WC="\033[1;97m"
NC="\033[0m"
(...)
init() {
pkg="$1"
echo -e "Package ${WC}${pkg}${NC} ${CC}not found${NC}."
}
(...)
I have refactorized the function init to:
init() {
eval_gettext "Package \${WC}\${pkg}\${NC} \${CC}not found\${NC}."; echo -e
}
When I try to get the msgids I can see the following:
#, sh-format
msgid "Package ${WC}${pkg}${NC} ${CC}not found${NC}."
msgstr ""
But when I execute the script, then I see this message:
/usr/bin/gettext.sh: line 88: export: `WC
pkg
NC
CC
NC': not a valid identifier
Package not found.
In fact, shellcheck is advising that the color variables are not being used...
How could I refactorize it to work?
Edit:
This code works:
printf "$(gettext "Package %b%s %bnot found%b.\n")" "$WC" "$pkg" "$CC" "$NC"
But It has the problem that a command would not be executed in the fist param of the printf
Last edited by karlospv94 (2017-04-23 17:16:59)
Offline
Web oriented programmer
Offline
Sorry, I don't see the difference
Offline