From 83982a5f83625f9704470c4d1c2babcf61a20b02 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 22 Jul 2017 11:10:56 -0400 Subject: lib/locale.sh: Fix locale paths --- (limited to 'lib') 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 } -- cgit v0.9.1