[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:
parent
5ecdde56f4
commit
a323c33c30
@ -115,9 +115,6 @@ def mac_setup_localization(glocale, lang, language):
|
|||||||
if lang == "cn_Hans": #Simplified; Gettext uses cn_CN
|
if lang == "cn_Hans": #Simplified; Gettext uses cn_CN
|
||||||
lang = "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:
|
if lang in available or lang[:2] in available:
|
||||||
usable.append(lang)
|
usable.append(lang)
|
||||||
|
|
||||||
@ -167,7 +164,7 @@ def mac_setup_localization(glocale, lang, language):
|
|||||||
"""
|
"""
|
||||||
Extract the collation (sort order) locale from the defaults string.
|
Extract the collation (sort order) locale from the defaults string.
|
||||||
"""
|
"""
|
||||||
collation = ""
|
collation = None
|
||||||
try:
|
try:
|
||||||
collation = subprocess.Popen(
|
collation = subprocess.Popen(
|
||||||
[defaults, "read", "-app", "Gramps", "AppleCollationOrder"],
|
[defaults, "read", "-app", "Gramps", "AppleCollationOrder"],
|
||||||
@ -183,7 +180,7 @@ def mac_setup_localization(glocale, lang, language):
|
|||||||
stdout = subprocess.PIPE).communicate()[0]
|
stdout = subprocess.PIPE).communicate()[0]
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
if collation == "root":
|
if collation.startswith("root"):
|
||||||
return None
|
return None
|
||||||
return collation
|
return collation
|
||||||
|
|
||||||
@ -247,10 +244,10 @@ def mac_setup_localization(glocale, lang, language):
|
|||||||
|
|
||||||
if not language or len(language) == 0:
|
if not language or len(language) == 0:
|
||||||
if "LANGUAGE" in os.environ:
|
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]
|
if l[:5] in available or l[:2] in available]
|
||||||
elif lang != "en_US":
|
elif "LANG" in os.environ and not lang.startswith("en_US"):
|
||||||
language = [lang]
|
language = [lang[:5]]
|
||||||
else:
|
else:
|
||||||
if len(translations) > 0:
|
if len(translations) > 0:
|
||||||
language = translations
|
language = translations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user