From 3f4979bfb07389b33d7a1d71ed02dc4a8aadf24c Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 08 Sep 2012 17:45:52 -0400 Subject: Implement ob_set_locale_path. --- (limited to 'lib') diff --git a/lib/locale.sh b/lib/locale.sh index 6c2baad..b1314bf 100644 --- a/lib/locale.sh +++ b/lib/locale.sh @@ -24,6 +24,7 @@ _OB_LOCALE_SM='true' _OB_DEFAULT_LOCALE='en_US' _OB_TEXT_DOMAIN= +_OB_LOCALE_PATH='@@LOCALEDIR@@/%s/LC_MESSAGES/%s.ms' ob_get_text_domain() { @@ -70,6 +71,23 @@ ob_set_text_domain() return 0 } +ob_set_locale_path() +{ + _obslp_format= + + if [ ${#} -eq 1 ]; then + _obslp_format="${1}" + else + unset _obslp_format + return 125 + fi + + _OB_LOCALE_PATH="${_obslp_format}" + + unset _obslp_format + return 0 +} + ob_get_msg() { _obgm_msgid= @@ -89,7 +107,8 @@ ob_get_msg() _ob_try_load_messages() { _obtlm_locale="${1}" - _obtlm_ms="@@LOCALEDIR@@/${_obtlm_locale}/LC_MESSAGES/${_OB_TEXT_DOMAIN}.ms" + _obtlm_ms="$(printf "${_OB_LOCALE_PATH}" \ + "${_obtlm_locale}" "${_OB_TEXT_DOMAIN}")" if [ -f "${_obtlm_ms}" ]; then . "${_obtlm_ms}" -- cgit v0.9.1