diff --git a/gramps/gen/plug/_manager.py b/gramps/gen/plug/_manager.py index 081333ada..c437536b9 100644 --- a/gramps/gen/plug/_manager.py +++ b/gramps/gen/plug/_manager.py @@ -41,9 +41,6 @@ from __future__ import print_function import os import sys import re -import logging -LOG = logging.getLogger('.' + __name__) -LOG.progagate = True from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext @@ -255,12 +252,7 @@ class BasePluginManager(object): if pdata.fpath not in sys.path: if pdata.mod_name: sys.path.insert(0, pdata.fpath) - try: - module = __import__(pdata.mod_name) - except ValueError as err: - LOG.warning('Plugin error: %s', err) - except ImportError as err: - LOG.warning('Plugin error: %s', err) + module = __import__(pdata.mod_name) sys.path.pop(0) else: print("WARNING: module cannot be loaded") diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 57a303f75..b38787459 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -237,10 +237,10 @@ class GrampsLocale(object): if not self.language: self.language = [self.lang[:5]] - if 'COLLATION' in os.environ: - coll = os.environ['COLLATION'] + if 'LC_COLLATE' in os.environ: + coll = os.environ['LC_COLLATE'] if HAVE_ICU: - if coll[:2] in ICU_LOCALES: + if coll[:5] in ICU_LOCALES: self.collation = coll else: self.collation = self.lang @@ -347,9 +347,6 @@ class GrampsLocale(object): else: self.collation = self.lang - if HAVE_ICU and 'COLLATION' in os.environ: - self.collation = os.environ['COLLATION'] - loc = locale.getlocale(locale.LC_NUMERIC) if loc and loc[0]: self.numeric = '.'.join(loc) @@ -550,6 +547,9 @@ class GrampsLocale(object): else: self.language = None + #For alternate collation sequences. Works only with ICU, and + #set only on Macs. + self.coll_qualifier = None _first = self._GrampsLocale__first_instance if self == _first: self._GrampsLocale__init_first_instance() @@ -561,7 +561,6 @@ class GrampsLocale(object): if HAVE_ICU: self.icu_locales["default"] = Locale.createFromName(self.lang) if self.collation and self.collation != self.lang: - print ("Setting up for collation %s" % self.collation) self.icu_locales["collation"] = Locale.createFromName(self.collation) else: self.icu_locales["collation"] = self.icu_locales["default"] @@ -617,7 +616,7 @@ class GrampsLocale(object): if not languages or len(languages) == 0: LOG.warning("No language provided, using US English") else: - raise ValueError("No usable translations in %s for " % + raise ValueError("No usable translations in %s" % ':'.join(languages)) translator = GrampsNullTranslations() translator._language = "en" diff --git a/gramps/gen/utils/maclocale.py b/gramps/gen/utils/maclocale.py index d0474ebd6..5cfdeb9b8 100644 --- a/gramps/gen/utils/maclocale.py +++ b/gramps/gen/utils/maclocale.py @@ -194,27 +194,24 @@ def mac_setup_localization(glocale): """ Extract the collation (sort order) locale from the defaults string. """ - # The locale module can't deal with collation-qualified - # locales, so we read $LC_COLLATE directly rather than trying - # to use locale.getlocale. - if ('LC_COLLATE') in os.environ: - apple_collation = os.environ['LC_COLLATE'] - else: - apple_collation = _mac_get_gramps_defaults("Gramps", - "AppleCollationOrder") + apple_collation = _mac_get_gramps_defaults("Gramps", "AppleCollationOrder") if not apple_collation: apple_collation = _mac_get_gramps_defaults("Global", "AppleCollationOrder") if not apple_collation: - print('No apple collation') - return None + return (None, None) apple_collation = apple_collation.strip() if not apple_collation or apple_collation.startswith("root"): - print('No meaningful apple collation') - return None - print('Got collation %s from defaults' % apple_collation) - return apple_collation + return (None, None) + div = apple_collation.split(b"@") + collation = div[0] + qualifier = None + if len(div) > 1: + parts = div[1].split(b"=") + if len(parts) == 2 and parts[0] == 'collation': + qualifier = parts[1] + return (collation, qualifier) #The action starts here _locale = None @@ -237,11 +234,12 @@ def mac_setup_localization(glocale): (glocale.lang, glocale.currency, glocale.calendar) = _mac_get_locale() glocale.coll_qualifier = None - glocale.collation = _mac_get_collation() + glocale.collation = locale.getlocale(locale.LC_COLLATE)[0] + if not glocale.collation: + (glocale.collation, glocale.coll_qualifier) = _mac_get_collation() if not glocale.lang and glocale.collation: - coll_parts = glocale.collation.split('@') - glocale.lang = glocale.check_available_translations(coll_parts[0]) + glocale.lang = glocale.check_available_translations(glocale.collation) glocale.lang = locale.normalize(glocale.lang) glocale.encoding = glocale.lang.split('.')[1]