summaryrefslogtreecommitdiffstats
path: root/lib/locale.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/locale.sh')
-rw-r--r--lib/locale.sh45
1 files changed, 15 insertions, 30 deletions
diff --git a/lib/locale.sh b/lib/locale.sh
index e6132d2..3628670 100644
--- a/lib/locale.sh
+++ b/lib/locale.sh
@@ -24,15 +24,11 @@ _OB_LOCALE_PATH="${LOCALEDIR}/%s/LC_MESSAGES/%s.ms"
## @brief Get the current message domain
## @details \fBob_get_text_domain\fP prints the currently loaded message domain.
-## @return Returns 0 on success or 125 if any arguments are given.
+## @return Returns 0 on success.
## @stdout Prints the name of the currently loaded message domain.
## @pure yes This function has no side effects.
ob_get_text_domain()
{
- if [ ${#} -ne 0 ]; then
- return 125
- fi
-
printf '%s' "${_ob_text_domain}"
return 0
}
@@ -62,20 +58,19 @@ _ob_try_load_messages()
## should have its own message domain. libopkbuild also has its own
## message domain and temporarily switches to it when needed.
## @operand text_domain req The message domain to load.
-## @return Returns 0 on success, 1 if the message domain cannot be loaded, or
-## 125 if \fItext_domain\fP is missing or invalid.
+## @return Returns 0 on success or 1 if \fItext_domain\fP is missing or invalid
+## or if the message domain cannot be loaded.
## @pure no This function sets an internal global variable and loads a message
## catalog that sets numerous message variables.
ob_set_text_domain()
{
- if [ ${#} -eq 1 ]; then
- _ob_text_domain="${1}"
- else
- return 125
- fi
- case "${_ob_text_domain}" in *[!A-Za-z0-9_]*)
- return 125
+ local text_domain="${1}"
+ shift 1 || _ob_abort
+
+ case "${text_domain}" in *[!A-Za-z0-9_]* | '')
+ return 1
esac
+ _ob_text_domain="${text_domain}"
# Make sure LC_MESSAGES is set.
if [ -z "${LC_MESSAGES}" ]; then
@@ -108,13 +103,8 @@ ob_set_text_domain()
ob_set_locale_path()
{
- local format=
-
- if [ ${#} -eq 1 ]; then
- format="${1}"
- else
- return 125
- fi
+ local format="${1}"
+ shift 1 || _ob_abort
_OB_LOCALE_PATH="${format}"
@@ -125,18 +115,13 @@ ob_set_locale_path()
## @details \fBob_get_msg\fP prints a message, identified by a message ID, from
## the currently loaded message catalog.
## @operand msgid req The ID of the message to print
-## @return Returns 0 on success or 125 if \fImsgid\fP is missing.
+## @return Returns 0 on success.
## @stdout Prints the requested message from the current message domain.
## @pure yes This function has no side effects.
ob_get_msg()
{
- local msgid=
-
- if [ ${#} -eq 1 ]; then
- msgid="${1}"
- else
- return 125
- fi
+ local msgid="${1}"
+ shift 1 || _ob_abort
eval "printf '%s' \"\${msg_${_ob_text_domain}_${msgid}}\""
@@ -146,7 +131,7 @@ ob_get_msg()
_ob_get_msg()
{
local msgid="${1}"
- shift 1
+ shift 1 || _ob_abort
local orig_text_domain=
orig_text_domain="$(ob_get_text_domain)"