summaryrefslogtreecommitdiffstats
path: root/lib/locale.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-09-04 23:15:28 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-09-04 23:15:28 (EDT)
commit042f369c110fc184ba71d180ccfbb107bbf8064a (patch)
treeedb51b27db8b62ae2203afb2e482c1a6b6359b3d /lib/locale.sh
parent0dff1771f49e419c5db8a1eb27ec97202c98dec5 (diff)
Change ob_add_text_domain to ob_set_text_domain.
Also add ob_get_msg.
Diffstat (limited to 'lib/locale.sh')
-rw-r--r--lib/locale.sh42
1 files changed, 26 insertions, 16 deletions
diff --git a/lib/locale.sh b/lib/locale.sh
index 203faba..f23f3d1 100644
--- a/lib/locale.sh
+++ b/lib/locale.sh
@@ -23,15 +23,13 @@ _OB_LOCALE_SM='true'
. '@@LIBOPKBUILD@@/output.sm'
_OB_DEFAULT_LOCALE='en_US'
+_OB_TEXT_DOMAIN=
-ob_add_text_domain()
+ob_set_text_domain()
{
- _obatd_domain=
-
if [ ${#} -eq 1 ]; then
- _obatd_domain="${1}"
+ _OB_TEXT_DOMAIN="${1}"
else
- unset _obatd_domain
return 125
fi
@@ -49,35 +47,47 @@ ob_add_text_domain()
# TODO: Exit early if domain's messages have already been loaded.
# Try to load the messages.
- if ! _ob_try_load_messages "${LC_MESSAGES%.*}" "${obsl_domain}"; then
- if ! _ob_try_load_messages "${LC_MESSAGES%_*}" "${_obatd_domain}"; then
- if ! _ob_try_load_messages "${_OB_DEFAULT_LOCALE}" \
- "${_obatd_domain}"; then
+ if ! _ob_try_load_messages "${LC_MESSAGES%.*}"; then
+ if ! _ob_try_load_messages "${LC_MESSAGES%_*}"; then
+ if ! _ob_try_load_messages "${_OB_DEFAULT_LOCALE}"; then
ob_warn 'Cannot load messages in "%s" domain.' \
- "${_obatd_domain}"
- unset _obatd_domain
+ "${_OB_TEXT_DOMAIN}"
return 1
fi
fi
fi
- unset _obatd_domain
+ return 0
+}
+
+ob_get_msg()
+{
+ _obgm_msgid=
+
+ if [ ${#} -eq 1 ]; then
+ _obgm_msgid="${1}"
+ else
+ unset _obgm_msgid
+ return 125
+ fi
+
+ IFS= eval echo "\$\{msg_${_OB_TEXT_DOMAIN}_${_obgm_msgid}\}"
+
return 0
}
_ob_try_load_messages()
{
_obtlm_locale="${1}"
- _obtlm_domain="${2}"
- _obtlm_ms="@@LOCALEDIR@@/${_obtlm_locale}/LC_MESSAGES/${_obtlm_domain}.ms"
+ _obtlm_ms="@@LOCALEDIR@@/${_obtlm_locale}/LC_MESSAGES/${_OB_TEXT_DOMAIN}.ms"
if [ -f "${_obtlm_ms}" ]; then
. "${_obtlm_ms}"
else
- unset _obtlm_locale _obtlm_domain _obtlm_ms
+ unset _obtlm_locale _obtlm_ms
return 1
fi
- unset _obtlm_locale _obtlm_domain _obtlm_ms
+ unset _obtlm_locale _obtlm_ms
return 0
}