From 54a3f8e58e22c8bc5f9db4c628795fdad23e2956 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 23 Oct 2013 16:13:52 -0400 Subject: _try_load_locale(): Hardcode locale path formats. --- 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 } -- cgit v0.9.1