diff options
author | P. J. McDermott <pjm@nac.net> | 2013-10-23 16:13:52 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-10-23 16:13:52 (EDT) |
commit | 54a3f8e58e22c8bc5f9db4c628795fdad23e2956 (patch) | |
tree | 29269bb2db1eb6e48b0453ab4c12d31ef5726c13 /lib | |
parent | d7491b6f2c71c03ce7f4833f0fe0e3d6de90d2ff (diff) |
_try_load_locale(): Hardcode locale path formats.
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 } |