Locale: Fix pylint line-too-long
This commit is contained in:
parent
ef31fcd928
commit
e4ece434d1
@ -70,7 +70,8 @@ _ = lambda x: x
|
|||||||
_LOCALE_NAMES = {
|
_LOCALE_NAMES = {
|
||||||
'ar': ('Arabic_Saudi Arabia', '1256', _("Arabic")),
|
'ar': ('Arabic_Saudi Arabia', '1256', _("Arabic")),
|
||||||
'bg': ('Bulgrian_Bulgaria', '1251', _("Bulgarian")),
|
'bg': ('Bulgrian_Bulgaria', '1251', _("Bulgarian")),
|
||||||
'br': (None, None, _("Breton")), #Windows has no translation for Breton
|
#Windows has no translation for Breton
|
||||||
|
'br': (None, None, _("Breton")),
|
||||||
'ca': ('Catalan_Spain', '1252', _("Catalan")),
|
'ca': ('Catalan_Spain', '1252', _("Catalan")),
|
||||||
'cs': ('Czech_Czech Republic', '1250', _("Czech")),
|
'cs': ('Czech_Czech Republic', '1250', _("Czech")),
|
||||||
'da': ('Danish_Denmark', '1252', _("Danish")),
|
'da': ('Danish_Denmark', '1252', _("Danish")),
|
||||||
@ -79,11 +80,13 @@ _LOCALE_NAMES = {
|
|||||||
'el': ('Greek_Greece', '1253', _("Greek")),
|
'el': ('Greek_Greece', '1253', _("Greek")),
|
||||||
'en': ('English_United States', '1252', _("English (USA)")),
|
'en': ('English_United States', '1252', _("English (USA)")),
|
||||||
'en_GB': ('English_United Kingdom', '1252', _("English")),
|
'en_GB': ('English_United Kingdom', '1252', _("English")),
|
||||||
'eo': (None, None, _("Esperanto")), #Windows has no translation for Esperanto
|
#Windows has no translation for Esperanto
|
||||||
|
'eo': (None, None, _("Esperanto")),
|
||||||
'es': ('Spanish_Spain', '1252', _("Spanish")),
|
'es': ('Spanish_Spain', '1252', _("Spanish")),
|
||||||
'fi': ('Finnish_Finland', '1252', _("Finnish")),
|
'fi': ('Finnish_Finland', '1252', _("Finnish")),
|
||||||
'fr': ('French_France', '1252', _("French")),
|
'fr': ('French_France', '1252', _("French")),
|
||||||
'ga': (None, None, _("Gaelic")), #Windows has no translation for Gaelic
|
#Windows has no translation for Gaelic
|
||||||
|
'ga': (None, None, _("Gaelic")),
|
||||||
'he': ('Hebrew_Israel', '1255', _("Hebrew")),
|
'he': ('Hebrew_Israel', '1255', _("Hebrew")),
|
||||||
'hr': ('Croatian_Croatia', '1250', _("Croatian")),
|
'hr': ('Croatian_Croatia', '1250', _("Croatian")),
|
||||||
'hu': ('Hungarian_Hungary', '1250', _("Hungarian")),
|
'hu': ('Hungarian_Hungary', '1250', _("Hungarian")),
|
||||||
@ -92,7 +95,8 @@ _LOCALE_NAMES = {
|
|||||||
'it': ('Italian_Italy', '1252', _("Italian")),
|
'it': ('Italian_Italy', '1252', _("Italian")),
|
||||||
'ja': ('Japanese_Japan', '932', _("Japanese")),
|
'ja': ('Japanese_Japan', '932', _("Japanese")),
|
||||||
'lt': ('Lithuanian_Lithuania', '1252', _("Lithuanian")),
|
'lt': ('Lithuanian_Lithuania', '1252', _("Lithuanian")),
|
||||||
'mk': (None, None, _("Macedonian")), #Windows has no translation for Macedonian
|
#Windows has no translation for Macedonian
|
||||||
|
'mk': (None, None, _("Macedonian")),
|
||||||
'nb': ('Norwegian_Norway', '1252', _("Norwegian Bokmal")),
|
'nb': ('Norwegian_Norway', '1252', _("Norwegian Bokmal")),
|
||||||
'nl': ('Dutch_Netherlands', '1252', _("Dutch")),
|
'nl': ('Dutch_Netherlands', '1252', _("Dutch")),
|
||||||
'nn': ('Norwegian-Nynorsk_Norway', '1252', _("Norwegian Nynorsk")),
|
'nn': ('Norwegian-Nynorsk_Norway', '1252', _("Norwegian Nynorsk")),
|
||||||
@ -106,7 +110,8 @@ _LOCALE_NAMES = {
|
|||||||
'sq': ('Albanian_Albania', '1250', _("Albanian")),
|
'sq': ('Albanian_Albania', '1250', _("Albanian")),
|
||||||
'sr': ('Serbian(Cyrillic)_Serbia and Montenegro', '1251', _("Serbian")),
|
'sr': ('Serbian(Cyrillic)_Serbia and Montenegro', '1251', _("Serbian")),
|
||||||
'sv': ('Swedish_Sweden', '1252', _("Swedish")),
|
'sv': ('Swedish_Sweden', '1252', _("Swedish")),
|
||||||
'ta': (None, None, _("Tamil")), # Windows has no codepage for Tamil
|
# Windows has no codepage for Tamil
|
||||||
|
'ta': (None, None, _("Tamil")),
|
||||||
'tr': ('Turkish_Turkey', '1254', _("Turkish")),
|
'tr': ('Turkish_Turkey', '1254', _("Turkish")),
|
||||||
'uk': ('Ukrainian_Ukraine', '1251', _("Ukrainian")),
|
'uk': ('Ukrainian_Ukraine', '1251', _("Ukrainian")),
|
||||||
'vi': ('Vietnamese_Vietnam', '1258', _("Vietnamese")),
|
'vi': ('Vietnamese_Vietnam', '1258', _("Vietnamese")),
|
||||||
@ -230,9 +235,11 @@ class GrampsLocale:
|
|||||||
return cls.__first_instance
|
return cls.__first_instance
|
||||||
|
|
||||||
if not cls.__first_instance.initialized:
|
if not cls.__first_instance.initialized:
|
||||||
raise RuntimeError("Second GrampsLocale created before first one was initialized")
|
raise RuntimeError("Second GrampsLocale created before "
|
||||||
|
"first one was initialized")
|
||||||
if ((lang is None or lang == cls.__first_instance.lang)
|
if ((lang is None or lang == cls.__first_instance.lang)
|
||||||
and (localedir is None or localedir == cls.__first_instance.localedir)
|
and (localedir is None or
|
||||||
|
localedir == cls.__first_instance.localedir)
|
||||||
and (domain is None or domain == cls.__first_instance.localedomain)
|
and (domain is None or domain == cls.__first_instance.localedomain)
|
||||||
and (languages is None or len(languages) == 0 or
|
and (languages is None or len(languages) == 0 or
|
||||||
languages == cls.__first_instance.language)):
|
languages == cls.__first_instance.language)):
|
||||||
@ -290,7 +297,8 @@ class GrampsLocale:
|
|||||||
if language:
|
if language:
|
||||||
self.language = language
|
self.language = language
|
||||||
else:
|
else:
|
||||||
LOG.debug("No languages with translations found in %%LANGUAGES%%")
|
LOG.debug("No languages with translations found "
|
||||||
|
"in %%LANGUAGES%%")
|
||||||
if not self.language:
|
if not self.language:
|
||||||
self.language = [self.lang[:5]]
|
self.language = [self.lang[:5]]
|
||||||
|
|
||||||
@ -321,7 +329,9 @@ class GrampsLocale:
|
|||||||
# We can't import datahandler stuff or we'll get a circular
|
# We can't import datahandler stuff or we'll get a circular
|
||||||
# dependency, so we rely on the available translations list
|
# dependency, so we rely on the available translations list
|
||||||
if 'LC_TIME' in os.environ:
|
if 'LC_TIME' in os.environ:
|
||||||
self.calendar = self.check_available_translations(os.environ['LC_TIME']) or self.lang
|
self.calendar = (
|
||||||
|
self.check_available_translations(os.environ['LC_TIME']) or
|
||||||
|
self.lang)
|
||||||
else:
|
else:
|
||||||
self.calendar = self.lang
|
self.calendar = self.lang
|
||||||
|
|
||||||
@ -344,8 +354,11 @@ class GrampsLocale:
|
|||||||
_failure = False
|
_failure = False
|
||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
if not _check_locale(locale.getdefaultlocale(envvars=('LC_ALL', 'LANG', 'LANGUAGE'))):
|
if not _check_locale(locale.getdefaultlocale(envvars=('LC_ALL',
|
||||||
LOG.debug("Usable locale not found, localization settings ignored.");
|
'LANG',
|
||||||
|
'LANGUAGE'))):
|
||||||
|
LOG.debug("Usable locale not found, localization "
|
||||||
|
"settings ignored.")
|
||||||
self.lang = 'C'
|
self.lang = 'C'
|
||||||
self.encoding = 'ascii'
|
self.encoding = 'ascii'
|
||||||
self.language = ['en']
|
self.language = ['en']
|
||||||
@ -353,7 +366,7 @@ class GrampsLocale:
|
|||||||
|
|
||||||
except locale.Error as err:
|
except locale.Error as err:
|
||||||
LOG.debug("Locale error %s, localization settings ignored.",
|
LOG.debug("Locale error %s, localization settings ignored.",
|
||||||
err);
|
err)
|
||||||
self.lang = 'C'
|
self.lang = 'C'
|
||||||
self.encoding = 'ascii'
|
self.encoding = 'ascii'
|
||||||
self.language = ['en']
|
self.language = ['en']
|
||||||
@ -370,7 +383,8 @@ class GrampsLocale:
|
|||||||
|
|
||||||
if HAVE_ICU:
|
if HAVE_ICU:
|
||||||
self.calendar = locale.getlocale(locale.LC_TIME)[0] or self.lang[:5]
|
self.calendar = locale.getlocale(locale.LC_TIME)[0] or self.lang[:5]
|
||||||
self.collation = locale.getlocale(locale.LC_COLLATE)[0] or self.lang[:5]
|
self.collation = (locale.getlocale(locale.LC_COLLATE)[0]
|
||||||
|
or self.lang[:5])
|
||||||
else:
|
else:
|
||||||
loc = locale.getlocale(locale.LC_TIME)
|
loc = locale.getlocale(locale.LC_TIME)
|
||||||
if loc and self.check_available_translations(loc[0]):
|
if loc and self.check_available_translations(loc[0]):
|
||||||
@ -395,7 +409,9 @@ class GrampsLocale:
|
|||||||
if language:
|
if language:
|
||||||
self.language = language
|
self.language = language
|
||||||
if not self.lang.startswith(self.language[0]):
|
if not self.lang.startswith(self.language[0]):
|
||||||
LOG.debug("Overiding locale setting '%s' with LANGUAGE setting '%s'", self.lang, self.language[0])
|
LOG.debug("Overiding locale setting '%s' with "
|
||||||
|
"LANGUAGE setting '%s'",
|
||||||
|
self.lang, self.language[0])
|
||||||
self.lang = self.calendar = self.language[0]
|
self.lang = self.calendar = self.language[0]
|
||||||
elif _failure:
|
elif _failure:
|
||||||
LOG.warning("No valid locale settings found, using US English")
|
LOG.warning("No valid locale settings found, using US English")
|
||||||
@ -417,7 +433,8 @@ class GrampsLocale:
|
|||||||
libintl.bind_textdomain_codeset(localedomain, "UTF-8")
|
libintl.bind_textdomain_codeset(localedomain, "UTF-8")
|
||||||
|
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
LOG.warning("Localization library libintl not on %PATH%, localization will be incomplete")
|
LOG.warning("Localization library libintl not on %PATH%, "
|
||||||
|
"localization will be incomplete")
|
||||||
|
|
||||||
def __init_first_instance(self):
|
def __init_first_instance(self):
|
||||||
"""
|
"""
|
||||||
@ -427,7 +444,8 @@ class GrampsLocale:
|
|||||||
"""
|
"""
|
||||||
global _hdlr
|
global _hdlr
|
||||||
_hdlr = logging.StreamHandler()
|
_hdlr = logging.StreamHandler()
|
||||||
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: "
|
||||||
|
"%(message)s"))
|
||||||
LOG.addHandler(_hdlr)
|
LOG.addHandler(_hdlr)
|
||||||
|
|
||||||
#Now that we have a logger set up we can issue the icu error if needed.
|
#Now that we have a logger set up we can issue the icu error if needed.
|
||||||
@ -453,7 +471,8 @@ class GrampsLocale:
|
|||||||
if not self.language:
|
if not self.language:
|
||||||
self.language.append('en')
|
self.language.append('en')
|
||||||
if not self.localedir and not self.lang.startswith('en'):
|
if not self.localedir and not self.lang.startswith('en'):
|
||||||
LOG.warning("No translations for %s were found, setting localization to U.S. English", self.localedomain)
|
LOG.warning("No translations for %s were found, setting "
|
||||||
|
"localization to U.S. English", self.localedomain)
|
||||||
self.lang = 'en_US.UTF-8'
|
self.lang = 'en_US.UTF-8'
|
||||||
self.language = ['en']
|
self.language = ['en']
|
||||||
|
|
||||||
@ -598,11 +617,13 @@ class GrampsLocale:
|
|||||||
if HAVE_ICU:
|
if HAVE_ICU:
|
||||||
self.icu_locales["default"] = Locale.createFromName(self.lang)
|
self.icu_locales["default"] = Locale.createFromName(self.lang)
|
||||||
if self.collation and self.collation != self.lang:
|
if self.collation and self.collation != self.lang:
|
||||||
self.icu_locales["collation"] = Locale.createFromName(self.collation)
|
collation = Locale.createFromName(self.collation)
|
||||||
|
self.icu_locales["collation"] = collation
|
||||||
else:
|
else:
|
||||||
self.icu_locales["collation"] = self.icu_locales["default"]
|
self.icu_locales["collation"] = self.icu_locales["default"]
|
||||||
try:
|
try:
|
||||||
self.collator = Collator.createInstance(self.icu_locales["collation"])
|
collation = self.icu_locales["collation"]
|
||||||
|
self.collator = Collator.createInstance(collation)
|
||||||
except ICUError as err:
|
except ICUError as err:
|
||||||
LOG.warning("Unable to create collator: %s", str(err))
|
LOG.warning("Unable to create collator: %s", str(err))
|
||||||
self.collator = None
|
self.collator = None
|
||||||
@ -612,7 +633,8 @@ class GrampsLocale:
|
|||||||
self.localedir,
|
self.localedir,
|
||||||
self.language)
|
self.language)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
LOG.warning("Unable to find translation for languages in %s, using US English", ':'.join(self.language))
|
LOG.warning("Unable to find translation for languages in %s, "
|
||||||
|
"using US English", ':'.join(self.language))
|
||||||
self.translation = GrampsNullTranslations()
|
self.translation = GrampsNullTranslations()
|
||||||
self.translation._language = "en"
|
self.translation._language = "en"
|
||||||
|
|
||||||
@ -794,7 +816,8 @@ class GrampsLocale:
|
|||||||
|
|
||||||
path = self.localedir
|
path = self.localedir
|
||||||
if filename:
|
if filename:
|
||||||
path = os.path.join(os.path.dirname(os.path.abspath(filename)), "locale")
|
path = os.path.join(os.path.dirname(os.path.abspath(filename)),
|
||||||
|
"locale")
|
||||||
if languages:
|
if languages:
|
||||||
addon_translator = self._get_translation(domain,
|
addon_translator = self._get_translation(domain,
|
||||||
path,
|
path,
|
||||||
@ -907,7 +930,8 @@ class GrampsLocale:
|
|||||||
if HAVE_ICU and self.collator:
|
if HAVE_ICU and self.collator:
|
||||||
# ICU can digest strings and unicode
|
# ICU can digest strings and unicode
|
||||||
# Use hexlify() as to make a consistent string, fixing bug #10077
|
# Use hexlify() as to make a consistent string, fixing bug #10077
|
||||||
return hexlify(self.collator.getCollationKey(string).getByteArray()).decode()
|
key = self.collator.getCollationKey(string)
|
||||||
|
return hexlify(key.getByteArray()).decode()
|
||||||
else:
|
else:
|
||||||
if isinstance(string, bytes):
|
if isinstance(string, bytes):
|
||||||
string = string.decode("utf-8", "replace")
|
string = string.decode("utf-8", "replace")
|
||||||
@ -1023,7 +1047,8 @@ class Lexeme(str):
|
|||||||
|
|
||||||
msgctxt "localized lexeme inflections"
|
msgctxt "localized lexeme inflections"
|
||||||
msgid "|December"
|
msgid "|December"
|
||||||
msgstr "NOMINATIVE=декабрь|GENITIVE=декабря|ABLATIVE=декабрём|LOCATIVE=декабре"
|
msgstr "NOMINATIVE=декабрь|GENITIVE=декабря|ABLATIVE=декабрём|"
|
||||||
|
"LOCATIVE=декабре"
|
||||||
|
|
||||||
msgctxt "lexeme"
|
msgctxt "lexeme"
|
||||||
msgid "|Christmas"
|
msgid "|Christmas"
|
||||||
|
@ -90,7 +90,8 @@ def mac_setup_localization(glocale):
|
|||||||
if domain == "Global":
|
if domain == "Global":
|
||||||
args = ('/usr/bin/defaults', 'read', '-g', key)
|
args = ('/usr/bin/defaults', 'read', '-g', key)
|
||||||
else:
|
else:
|
||||||
args = ('/usr/bin/defaults', 'read', 'org.gramps-project.gramps', key)
|
args = ('/usr/bin/defaults', 'read',
|
||||||
|
'org.gramps-project.gramps', key)
|
||||||
|
|
||||||
answer = subprocess.Popen(
|
answer = subprocess.Popen(
|
||||||
args,
|
args,
|
||||||
@ -100,7 +101,8 @@ def mac_setup_localization(glocale):
|
|||||||
LOG.debug("No prefs found for %s:%s", domain, key)
|
LOG.debug("No prefs found for %s:%s", domain, key)
|
||||||
return None
|
return None
|
||||||
answer = answer.decode("utf-8")
|
answer = answer.decode("utf-8")
|
||||||
LOG.debug("Found %s for defaults %s:%s", answer.strip(), domain, key)
|
LOG.debug("Found %s for defaults %s:%s", answer.strip(), domain,
|
||||||
|
key)
|
||||||
return answer
|
return answer
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
LOG.warning("Failed to read %s from System Preferences: %s",
|
LOG.warning("Failed to read %s from System Preferences: %s",
|
||||||
@ -134,13 +136,15 @@ def mac_setup_localization(glocale):
|
|||||||
translations = _mac_check_languages(languages)
|
translations = _mac_check_languages(languages)
|
||||||
if translations:
|
if translations:
|
||||||
return translations
|
return translations
|
||||||
LOG.debug("No suitable translations found in language list on Gramps defaults")
|
LOG.debug("No suitable translations found in language list on "
|
||||||
|
"Gramps defaults")
|
||||||
languages = _mac_get_gramps_defaults("Global", "AppleLanguages")
|
languages = _mac_get_gramps_defaults("Global", "AppleLanguages")
|
||||||
if languages:
|
if languages:
|
||||||
translations = _mac_check_languages(languages)
|
translations = _mac_check_languages(languages)
|
||||||
if translations:
|
if translations:
|
||||||
return translations
|
return translations
|
||||||
LOG.debug("No suitable translations found in language list on Global defaults")
|
LOG.debug("No suitable translations found in language list on "
|
||||||
|
"Global defaults")
|
||||||
LOG.debug("No translations found in System Preferences")
|
LOG.debug("No translations found in System Preferences")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -223,7 +227,8 @@ def mac_setup_localization(glocale):
|
|||||||
LOG.debug("Environment locale %s not supported", _locale)
|
LOG.debug("Environment locale %s not supported", _locale)
|
||||||
|
|
||||||
if not glocale.lang:
|
if not glocale.lang:
|
||||||
LOG.debug("Setting from the environment didn't work out, checking defaults")
|
LOG.debug("Setting from the environment didn't work out, checking "
|
||||||
|
"defaults")
|
||||||
(glocale.lang, glocale.calendar) = _mac_get_locale()
|
(glocale.lang, glocale.calendar) = _mac_get_locale()
|
||||||
|
|
||||||
glocale.coll_qualifier = None
|
glocale.coll_qualifier = None
|
||||||
@ -269,7 +274,8 @@ def mac_setup_localization(glocale):
|
|||||||
if glocale.lang:
|
if glocale.lang:
|
||||||
glocale.language = [glocale.lang[:5]]
|
glocale.language = [glocale.lang[:5]]
|
||||||
else:
|
else:
|
||||||
LOG.warning("No locale settings matching available translations found, using US English")
|
LOG.warning("No locale settings matching available "
|
||||||
|
"translations found, using US English")
|
||||||
glocale.lang = 'C'
|
glocale.lang = 'C'
|
||||||
glocale.language = ['en']
|
glocale.language = ['en']
|
||||||
glocale.encoding = 'utf-8'
|
glocale.encoding = 'utf-8'
|
||||||
@ -278,10 +284,12 @@ def mac_setup_localization(glocale):
|
|||||||
if not glocale.lang:
|
if not glocale.lang:
|
||||||
glocale.lang = locale.normalize(glocale.language[0])
|
glocale.lang = locale.normalize(glocale.language[0])
|
||||||
glocale.encoding = glocale.lang.split('.')[1]
|
glocale.encoding = glocale.lang.split('.')[1]
|
||||||
LOG.debug("Ended check for languages with glocale.language %s", glocale.language)
|
LOG.debug("Ended check for languages with glocale.language %s",
|
||||||
|
glocale.language)
|
||||||
|
|
||||||
if not glocale.collation:
|
if not glocale.collation:
|
||||||
glocale.collation = locale.getlocale(locale.LC_COLLATE)[0] or glocale.lang
|
glocale.collation = (locale.getlocale(locale.LC_COLLATE)[0] or
|
||||||
|
glocale.lang)
|
||||||
if not glocale.calendar:
|
if not glocale.calendar:
|
||||||
time = locale.getlocale(locale.LC_TIME)[0]
|
time = locale.getlocale(locale.LC_TIME)[0]
|
||||||
if glocale.check_available_translations(time):
|
if glocale.check_available_translations(time):
|
||||||
|
Loading…
Reference in New Issue
Block a user