[r21596]Mac: Improve language list handling

Make sure that lang overrides the language list only if $LANG is set. Don't add encodings to the language list (e.g., en_US, not en_US.UTF-8). Start collation with None, because `if collation:` is True for collation = "". defaults may have whitespace at the end of "root", so use "startswith".

svn: r21599
This commit is contained in:
John Ralls 2013-03-09 22:38:00 +00:00
parent 5ecdde56f4
commit a323c33c30

View File

@ -115,9 +115,6 @@ def mac_setup_localization(glocale, lang, language):
if lang == "cn_Hans": #Simplified; Gettext uses cn_CN
lang = "cn_CN"
if lang.startswith("en"): # Gramps doesn't have explicit
usable.append("C") # English translation, use C
continue
if lang in available or lang[:2] in available:
usable.append(lang)
@ -167,7 +164,7 @@ def mac_setup_localization(glocale, lang, language):
"""
Extract the collation (sort order) locale from the defaults string.
"""
collation = ""
collation = None
try:
collation = subprocess.Popen(
[defaults, "read", "-app", "Gramps", "AppleCollationOrder"],
@ -183,7 +180,7 @@ def mac_setup_localization(glocale, lang, language):
stdout = subprocess.PIPE).communicate()[0]
except OSError:
pass
if collation == "root":
if collation.startswith("root"):
return None
return collation
@ -247,10 +244,10 @@ def mac_setup_localization(glocale, lang, language):
if not language or len(language) == 0:
if "LANGUAGE" in os.environ:
language = [l for l in os.environ["LANGUAGE"].split(":")
language = [l[:5] for l in os.environ["LANGUAGE"].split(":")
if l[:5] in available or l[:2] in available]
elif lang != "en_US":
language = [lang]
elif "LANG" in os.environ and not lang.startswith("en_US"):
language = [lang[:5]]
else:
if len(translations) > 0:
language = translations