summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-15 23:55:21 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-15 23:55:21 (EDT)
commitb5aa7a33b9ecdc0175d2f58f131f6f7ce575a61b (patch)
treeb7867a42079d166e8662ac3a2417b17d7b6e265f /lib
parentac2d2b30da44758f0b58d110596c8e51432bf209 (diff)
ob_get_msg(): Make sure ob_set_text_domain() is called first
Diffstat (limited to 'lib')
-rw-r--r--lib/locale.sh9
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