diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index cf92e9e67..bd0620842 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -275,7 +275,7 @@ class GrampsLocale: self.lang = loc[0] self.encoding = loc[1] else: - (lang, loc) = _check_mswin_locale(locale.getdefaultlocale()[0]) + (lang, loc) = _check_mswin_locale(locale.getlocale()[0]) if lang: self.lang = lang self.encoding = loc[1] @@ -356,9 +356,7 @@ class GrampsLocale: _failure = False try: locale.setlocale(locale.LC_ALL, '') - if not _check_locale(locale.getdefaultlocale(envvars=('LC_ALL', - 'LANG', - 'LANGUAGE'))): + if not _check_locale(locale.getlocale(category=locale.LC_MESSAGES)): LOG.debug("Usable locale not found, localization " "settings ignored.") self.lang = 'C' @@ -987,22 +985,14 @@ class GrampsLocale: from ..lib.grampstype import GrampsType return GrampsType.xml_str(name) - def format(self, format, val, grouping=False, monetary=False): - """ - Format a number in the current numeric locale. See python's - locale.format for details. ICU's formatting codes are - incompatible with locale's, so just use locale.format for now. - """ - return locale.format(format, val, grouping, monetary) - - def format_string(self, format, val, grouping=False): + def format_string(self, fmt, val, grouping=False, monetary=False): """ Format a string in the current numeric locale. See python's locale.format_string for details. ICU's message formatting codes are incompatible with locale's, so just use locale.format_string for now. """ - return locale.format_string(format, val, grouping) + return locale.format_string(fmt, val, grouping, monetary) def float(self, val): """ diff --git a/gramps/gui/widgets/histogram.py b/gramps/gui/widgets/histogram.py index e44f57ec0..1d73d24d5 100644 --- a/gramps/gui/widgets/histogram.py +++ b/gramps/gui/widgets/histogram.py @@ -178,7 +178,7 @@ class Histogram(Gtk.DrawingArea): total = sum(self.data) for i in range(len(self.data)): if total > 0: - percent = glocale.format('%.2f', self.data[i] / total * 100) + percent = glocale.format_string('%.2f', self.data[i] / total * 100) else: percent = '' layout = self.create_pango_layout(percent) diff --git a/gramps/plugins/gramplet/pedigreegramplet.py b/gramps/plugins/gramplet/pedigreegramplet.py index 1f11a1cef..11aec5c72 100644 --- a/gramps/plugins/gramplet/pedigreegramplet.py +++ b/gramps/plugins/gramplet/pedigreegramplet.py @@ -260,13 +260,13 @@ class PedigreeGramplet(Gramplet): if g == 0: self.link(_("Generation 1"), 'PersonList', handles, tooltip=_("Double-click to see people in generation")) - percent = glocale.format('%.2f', 100) + percent_sign + percent = glocale.format_string('%.2f', 100) + percent_sign self.append_text(_(" has 1 of 1 individual (%(percent)s complete)\n") % {'percent': percent}) else: all.extend(handles) self.link(_("Generation %d") % g, 'PersonList', handles, tooltip=_("Double-click to see people in generation %d") % g) - percent = glocale.format('%.2f', float(count)/2**(g-1) * 100) + percent_sign + percent = glocale.format_string('%.2f', float(count)/2**(g-1) * 100) + percent_sign self.append_text( # Translators: leave all/any {...} untranslated ngettext(" has {count_person} of {max_count_person} " diff --git a/gramps/plugins/textreport/numberofancestorsreport.py b/gramps/plugins/textreport/numberofancestorsreport.py index a42f5fe63..15556dbd3 100644 --- a/gramps/plugins/textreport/numberofancestorsreport.py +++ b/gramps/plugins/textreport/numberofancestorsreport.py @@ -115,7 +115,7 @@ class NumberOfAncestorsReport(Report): gen += 1 theoretical = math.pow(2, (gen - 1)) total_theoretical += theoretical - percent = '(%s%%)' % self._locale.format( + percent = '(%s%%)' % self._locale.format_string( '%3.2f', ((sum(thisgen.values()) / theoretical) * 100)) # TC # English return something like: