From 4dba70c44c6e2de78b36c41f9d98f620e858e02e Mon Sep 17 00:00:00 2001 From: hayao Date: Tue, 22 Dec 2020 22:12:11 +0900 Subject: [PATCH] [update] : Added translation warning --- wfa | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wfa b/wfa index 2d90f01..0d8f1c5 100755 --- 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 -- 2.11.0