Fix up mactrans.py for python3
svn: r21010
This commit is contained in:
parent
e07ec97571
commit
f14b5d8944
@ -71,7 +71,7 @@ locale, leaving $LANGUAGE unset (which is the same as setting it to
|
||||
|
||||
"""
|
||||
|
||||
import os, subprocess
|
||||
import sys, os, subprocess
|
||||
|
||||
def get_available_translations(dir, domain):
|
||||
"""
|
||||
@ -108,18 +108,21 @@ def mac_setup_localization(dir, domain):
|
||||
languages = subprocess.Popen(
|
||||
[defaults, "read", "-app", "Gramps", "AppleLanguages"],
|
||||
stderr=open("/dev/null"),
|
||||
stdout=subprocess.PIPE).communicate()[0].strip("()\n").split(",\n")
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
if not sys.version_info[0] < 3:
|
||||
languages = languages.decode("utf-8")
|
||||
languages = languages.strip("()\n").split(",\n")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if len(languages) == 0 or (len(languages) == 1 and languages[0] == ""):
|
||||
# try:
|
||||
languages = subprocess.Popen(
|
||||
[defaults, "read", "-g", "AppleLanguages"],
|
||||
stderr=open("/dev/null"),
|
||||
stdout=subprocess.PIPE).communicate()[0].strip("()\n").split(",\n")
|
||||
# except OSError:
|
||||
# pass
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
if not sys.version_info[0] < 3:
|
||||
languages = languages.decode("utf-8")
|
||||
languages = languages.strip("()\n").split(",\n")
|
||||
usable = []
|
||||
for lang in languages:
|
||||
lang = lang.strip().strip('"').replace("-", "_", 1)
|
||||
@ -157,7 +160,7 @@ def mac_setup_localization(dir, domain):
|
||||
except OSError:
|
||||
return (locale, calendar, currency)
|
||||
|
||||
div = default_locale.split("@")
|
||||
div = default_locale.split(b"@")
|
||||
locale = div[0]
|
||||
if len(div) > 1:
|
||||
div = div[1].split(";")
|
||||
|
Loading…
x
Reference in New Issue
Block a user