_msg: Refactor for localization
This commit is contained in:
parent
571bd29997
commit
cfd37fb499
24
qsgen2
24
qsgen2
@ -75,40 +75,40 @@ function _msg() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
# Check if argument is a key in the localization array
|
# Check if argument is a key in the localization array
|
||||||
if [[ -n "${localization[$arg]}" ]]; then
|
if [[ -n "${localization[$arg]}" ]]; then
|
||||||
# Append the localized message to full_msg
|
# Append the localized message to full_msg, ensuring safe expansion
|
||||||
full_msg+="${localization[$arg]}"
|
full_msg+="${(q)localization[$arg]}"
|
||||||
else
|
else
|
||||||
# Argument not a key, treat as a literal string and append
|
# Argument not a key, treat as a literal string and append, ensuring safe expansion
|
||||||
full_msg+="$arg"
|
full_msg+="${(q)arg}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Apply color formatting based on type and use printf for safe output
|
# Apply color formatting based on type and use printf for safe output
|
||||||
case $type in
|
case $type in
|
||||||
std)
|
std)
|
||||||
printf "${green}%s${end}\n" "$full_msg"
|
printf "${green}%s${end}\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
info)
|
info)
|
||||||
printf "${yellow}%s${end}\n" "$full_msg"
|
printf "${yellow}%s${end}\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
debug)
|
debug)
|
||||||
printf "${red}%s${end}\n" "$full_msg"
|
printf "${red}%s${end}\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
other)
|
other)
|
||||||
printf "${bold_yellow}%s${end}\n" "$full_msg"
|
printf "${bold_yellow}%s${end}\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
sub)
|
sub)
|
||||||
printf "${magenta}%s${end}\n" "$full_msg"
|
printf "${magenta}%s${end}\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
main)
|
main)
|
||||||
printf "${white}${green_bg} %s ${end}\n" "$full_msg"
|
printf "${white}${green_bg} %s ${end}\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%s\n" "$full_msg"
|
printf "%s\n" "${full_msg}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "Debugging full_msg: $full_msg"
|
echo "Debugging full_msg: ${full_msg}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _version() {
|
function _version() {
|
||||||
|
Loading…
Reference in New Issue
Block a user