summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/locale.sh28
1 files changed, 7 insertions, 21 deletions
diff --git a/lib/locale.sh b/lib/locale.sh
index cc3560d..0920493 100644
--- a/lib/locale.sh
+++ b/lib/locale.sh
@@ -20,6 +20,7 @@
_OB_DEFAULT_LOCALE='en_US'
_OB_INTERNAL_TEXT_DOMAIN="libopkbuild_${LIBOPKBUILD_SHSOVERSION}"
_ob_text_domain=
+_ob_builddir=
_OB_LOCALE_PATH="${LOCALEDIR}/%s/LC_MESSAGES/%s.ms"
## @brief Get the current message domain
@@ -40,8 +41,8 @@ _ob_try_load_messages()
shift 1 || _ob_abort
local ms=
- if [ x"${OB_EXE_BUILDDIR:+set}" = 'xset' ]; then # Set and not null
- ms="${OB_EXE_BUILDDIR}"
+ if [ x"${_ob_builddir}" = x'' ]; then # Env var set and not null
+ ms="${_ob_builddir}"
ms="${ms}/${locale}/${_ob_text_domain}.ms"
else
ms="${LOCALEDIR}"
@@ -77,6 +78,7 @@ ob_set_text_domain()
return 1
esac
_ob_text_domain="${text_domain}"
+ _ob_builddir="${OB_EXE_BUILDDIR-}"
# Exit early if domain's messages have already been loaded.
if eval "\${_ob_text_domain_${_ob_text_domain}_loaded}"; then
@@ -133,24 +135,6 @@ _ob_get_msg()
return 0
}
-_ob_try_load_internal_messages()
-{
- local locale="${1}"
- shift 1 || _ob_abort
- local ms=
-
- if [ x"${OB_LIB_BUILDDIR:+set}" = 'xset' ]; then # Set and not null
- ms="${OB_LIB_BUILDDIR}"
- ms="${ms}/${locale}/${_OB_INTERNAL_TEXT_DOMAIN}.ms"
- else
- ms="${LOCALEDIR}"
- ms="${ms}/${locale}/LC_MESSAGES/${_OB_INTERNAL_TEXT_DOMAIN}.ms"
- fi
-
- eval "$(cat "${ms}" 2>/dev/null)" || return 1
- return 0
-}
-
_ob_load_internal_text_domain()
{
# Make sure LC_MESSAGES is set.
@@ -165,7 +149,9 @@ _ob_load_internal_text_domain()
fi
# Try to load the messages.
- if ! _ob_try_load_internal_messages "${LC_MESSAGES%.*}"; then
+ _ob_text_domain="${_OB_INTERNAL_TEXT_DOMAIN}"
+ _ob_builddir="${OB_LIB_BUILDDIR-}"
+ if ! _ob_try_load_messages "${LC_MESSAGES%.*}"; then
printf '%s: Error: Failed to load locale messages\n' \
"${0##*/}" >&2
fi