summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2017-07-22 11:10:56 (EDT)
committer P. J. McDermott <pj@pehjota.net>2017-07-22 11:10:56 (EDT)
commit83982a5f83625f9704470c4d1c2babcf61a20b02 (patch)
tree59210c3e9669d35fd8241208853551e515e796ad
parent3db8c0fc8cbbe0c01a4ceddbb7829083dc65af4a (diff)
lib/locale.sh: Fix locale paths
-rw-r--r--lib/locale.sh30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/locale.sh b/lib/locale.sh
index b3f54f4..25a7758 100644
--- a/lib/locale.sh
+++ b/lib/locale.sh
@@ -21,14 +21,12 @@
_LOCALE_SM=1
LOCALEDIR='@@LOCALEDIR@@'
-LOCALE_PATH='%s/%s/LC_MESSAGES/%s.ms'
DEFAULT_LOCALE='en_US'
TEXT_DOMAIN='pro_archman'
load_locale()
{
local localedir=
- local localepath=
# Make sure LC_MESSAGES is set.
if [ "x${LC_MESSAGES+set}" != 'xset' ]; then
@@ -43,18 +41,16 @@ load_locale()
if [ "${ARCHMAN_LOCALEDIR+set}" = 'set' ]; then
localedir="${ARCHMAN_LOCALEDIR:-.}"
- localepath='%s/%s/%s.ms'
else
localedir="${LOCALEDIR}"
- localepath="${LOCALE_PATH}"
fi
# Try to load the locale.
- if ! _try_load_locale "${localedir}" "${localepath}" \
+ if ! _try_load_locale "${localedir}" \
"${LC_MESSAGES%.*}"; then
- if ! _try_load_locale "${localedir}" "${localepath}" \
+ if ! _try_load_locale "${localedir}" \
"${LC_MESSAGES%_*}"; then
- if ! _try_load_locale "${localedir}" "${localepath}" \
+ if ! _try_load_locale "${localedir}" \
"${DEFAULT_LOCALE}"; then
warn 'Cannot load locale'
return 1
@@ -77,18 +73,16 @@ get_msg()
_try_load_locale()
{
local localedir="${1}"
- local localepath="${2}"
- local locale="${3}"
+ local locale="${2}"
local ms=
- ms="$(printf "${localepath}" \
- "${localedir}" "${locale}" "${TEXT_DOMAIN}")"
-
- if [ -f "${ms}" ]; then
- . "${ms}"
- else
- return 1
- fi
+ for ms in "${localedir}/${locale}/LC_MESSAGES/${TEXT_DOMAIN}.ms" \
+ "${localedir}/${locale}.ms"; do
+ if [ -f "${ms}" ]; then
+ . "${ms}"
+ return 0
+ fi
+ done
- return 0
+ return 1
}