diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/locale.sh | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/locale.sh b/lib/locale.sh index 943d02f..7189e0c 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:%s/%s/%s.ms' DEFAULT_LOCALE='en_US' TEXT_DOMAIN='@textdomain@' load_locale() { local localedir= - local localepath= # Make sure LC_MESSAGES is set. if [ "x${LC_MESSAGES+set}" != 'xset' ]; then @@ -42,14 +40,13 @@ load_locale() fi localedir="${LOCALEDIR}" - localepath="${LOCALE_PATH}" # 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 @@ -72,22 +69,16 @@ get_msg() _try_load_locale() { local localedir="${1}" - local localepath="${2}" - local locale="${3}" - local path= + local locale="${2}" local ms= - IFS=':' - for path in ${localepath}; do - unset IFS - ms="$(printf "${path}" \ - "${localedir}" "${locale}" "${TEXT_DOMAIN}")" + for ms in "${localedir}/${locale}/LC_MESSAGES/${TEXT_DOMAIN}.ms" \ + "${localedir}/${locale}.ms"; do if [ -f "${ms}" ]; then . "${ms}" return 0 fi done - unset IFS return 1 } |