OSDN Git Service

[update] : Added translation warning
authorhayao <shun819.mail@gmail.com>
Tue, 22 Dec 2020 13:12:11 +0000 (22:12 +0900)
committerhayao <shun819.mail@gmail.com>
Tue, 22 Dec 2020 13:12:11 +0000 (22:12 +0900)
wfa

diff --git a/wfa b/wfa
index 2d90f01..0d8f1c5 100755 (executable)
--- a/wfa
+++ b/wfa
@@ -425,6 +425,9 @@ translate() {
             local _translated_text="$(eval echo '$'{${_locale}[\"${*}\"]})"
             set -eu
             if [[ -z "${_translated_text}" ]]; then
+                if [[ ! "${_locale}" = "C" ]] && [[ ! "${_locale}" = "en_US" ]]; then
+                    echo "$(text -nc cyan "[WFA]") $(text -nc yellow "Warning") No translation data was found" 1>&2
+                fi
                 echo "${*}"
             else
                 echo "${_translated_text}"
@@ -526,8 +529,8 @@ msg_error() {
 }
 
 text() {
-    local OPTIND OPTARG arg _textcolor _decotypes=() _message
-    while getopts "c:b" arg; do
+    local OPTIND OPTARG arg _textcolor _decotypes=() _message _notranslate=false
+    while getopts "c:bn" arg; do
         case ${arg} in
             c)
                 case "${OPTARG}" in
@@ -563,12 +566,17 @@ text() {
             b)
                 _decotypes+=(1)
                 ;;
+            n)
+                _notranslate=true
+                ;;
         esac
     done
     shift $((OPTIND - 1))
 
     _message="${@}"
-    _message="$(translate "${@}")"
+    if [[ "${_notranslate}" = false ]]; then
+        _message="$(translate "${@}")"
+    fi
     if [[ "${nocolor}" = true ]]; then
         echo -ne "${@}"
     else