diff options
Diffstat (limited to 'lib/locale.sh')
-rw-r--r-- | lib/locale.sh | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/locale.sh b/lib/locale.sh index bcc6b1e..2ade95c 100644 --- a/lib/locale.sh +++ b/lib/locale.sh @@ -21,6 +21,7 @@ _OB_DEFAULT_LOCALE='en_US' _OB_INTERNAL_TEXT_DOMAIN="libopkbuild_${LIBOPKBUILD_SHSOVERSION}" _ob_text_domain= _ob_builddir= +_ob_msgs_loaded=false ## @brief Get the current message domain ## @details \fBob_get_text_domain\fP() prints the currently loaded message @@ -94,12 +95,14 @@ ob_set_text_domain() fi fi + _ob_msgs_loaded=true return 0 } ## @brief Get a message from the current message domain ## @details \fBob_get_msg\fP() prints a message, identified by a message ID, -## from the currently loaded message catalog. +## from the currently loaded message catalog. +## \fBob_set_text_domain\fP() must be called first. ## @operand msgid req The ID of the message to print ## @return Returns 0 on success. ## @stdout Prints the requested message from the current message domain. @@ -109,6 +112,10 @@ ob_get_msg() local msgid="${1}" shift 1 || _ob_abort + if ! ${_ob_msgs_loaded}; then + printf '%s: Error: No text domain set\n' "${0##*/}" >&2 + _ob_abort + fi eval "printf '%s' \"\${msg_${_ob_text_domain}_${msgid}}\"" return 0 |