summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/locale.sh42
-rw-r--r--man/Makefile.in4
2 files changed, 28 insertions, 18 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
}
diff --git a/man/Makefile.in b/man/Makefile.in
index 9342070..dbbdc68 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -45,8 +45,8 @@ SRCS_1 = opkbuild.1.in \
ob-gencontrol.1.in \
ob-buildopk.1.in \
ob-genchanges.1.in \
-SRCS_3 = ob_set_locale.3.in \
- ob_set_locale_domain.3.in \
+SRCS_3 = ob_set_text_domain.3.in \
+ ob_get_msg.3.in \
ob_error.3.in \
ob_warn.3.in \
ob_info.3.in \