Remove deprecated functions locale.getdefaultlocale and locale.format.
Remove also GrampsLocale.format because it was there only to mirror locale's API, and update GrampsLocale.format_string's signature to match locale.format_string's post-python3.7.
This commit is contained in:
parent
7f8455c867
commit
d5dd8d698c
@ -275,7 +275,7 @@ class GrampsLocale:
|
|||||||
self.lang = loc[0]
|
self.lang = loc[0]
|
||||||
self.encoding = loc[1]
|
self.encoding = loc[1]
|
||||||
else:
|
else:
|
||||||
(lang, loc) = _check_mswin_locale(locale.getdefaultlocale()[0])
|
(lang, loc) = _check_mswin_locale(locale.getlocale()[0])
|
||||||
if lang:
|
if lang:
|
||||||
self.lang = lang
|
self.lang = lang
|
||||||
self.encoding = loc[1]
|
self.encoding = loc[1]
|
||||||
@ -356,9 +356,7 @@ 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',
|
if not _check_locale(locale.getlocale(category=locale.LC_MESSAGES)):
|
||||||
'LANG',
|
|
||||||
'LANGUAGE'))):
|
|
||||||
LOG.debug("Usable locale not found, localization "
|
LOG.debug("Usable locale not found, localization "
|
||||||
"settings ignored.")
|
"settings ignored.")
|
||||||
self.lang = 'C'
|
self.lang = 'C'
|
||||||
@ -987,22 +985,14 @@ class GrampsLocale:
|
|||||||
from ..lib.grampstype import GrampsType
|
from ..lib.grampstype import GrampsType
|
||||||
return GrampsType.xml_str(name)
|
return GrampsType.xml_str(name)
|
||||||
|
|
||||||
def format(self, format, val, grouping=False, monetary=False):
|
def format_string(self, fmt, 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):
|
|
||||||
"""
|
"""
|
||||||
Format a string in the current numeric locale. See python's
|
Format a string in the current numeric locale. See python's
|
||||||
locale.format_string for details. ICU's message formatting codes are
|
locale.format_string for details. ICU's message formatting codes are
|
||||||
incompatible with locale's, so just use locale.format_string
|
incompatible with locale's, so just use locale.format_string
|
||||||
for now.
|
for now.
|
||||||
"""
|
"""
|
||||||
return locale.format_string(format, val, grouping)
|
return locale.format_string(fmt, val, grouping, monetary)
|
||||||
|
|
||||||
def float(self, val):
|
def float(self, val):
|
||||||
"""
|
"""
|
||||||
|
@ -178,7 +178,7 @@ class Histogram(Gtk.DrawingArea):
|
|||||||
total = sum(self.data)
|
total = sum(self.data)
|
||||||
for i in range(len(self.data)):
|
for i in range(len(self.data)):
|
||||||
if total > 0:
|
if total > 0:
|
||||||
percent = glocale.format('%.2f', self.data[i] / total * 100)
|
percent = glocale.format_string('%.2f', self.data[i] / total * 100)
|
||||||
else:
|
else:
|
||||||
percent = ''
|
percent = ''
|
||||||
layout = self.create_pango_layout(percent)
|
layout = self.create_pango_layout(percent)
|
||||||
|
@ -260,13 +260,13 @@ class PedigreeGramplet(Gramplet):
|
|||||||
if g == 0:
|
if g == 0:
|
||||||
self.link(_("Generation 1"), 'PersonList', handles,
|
self.link(_("Generation 1"), 'PersonList', handles,
|
||||||
tooltip=_("Double-click to see people in generation"))
|
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})
|
self.append_text(_(" has 1 of 1 individual (%(percent)s complete)\n") % {'percent': percent})
|
||||||
else:
|
else:
|
||||||
all.extend(handles)
|
all.extend(handles)
|
||||||
self.link(_("Generation %d") % g, 'PersonList', handles,
|
self.link(_("Generation %d") % g, 'PersonList', handles,
|
||||||
tooltip=_("Double-click to see people in generation %d") % g)
|
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(
|
self.append_text(
|
||||||
# Translators: leave all/any {...} untranslated
|
# Translators: leave all/any {...} untranslated
|
||||||
ngettext(" has {count_person} of {max_count_person} "
|
ngettext(" has {count_person} of {max_count_person} "
|
||||||
|
@ -115,7 +115,7 @@ class NumberOfAncestorsReport(Report):
|
|||||||
gen += 1
|
gen += 1
|
||||||
theoretical = math.pow(2, (gen - 1))
|
theoretical = math.pow(2, (gen - 1))
|
||||||
total_theoretical += theoretical
|
total_theoretical += theoretical
|
||||||
percent = '(%s%%)' % self._locale.format(
|
percent = '(%s%%)' % self._locale.format_string(
|
||||||
'%3.2f', ((sum(thisgen.values()) / theoretical) * 100))
|
'%3.2f', ((sum(thisgen.values()) / theoretical) * 100))
|
||||||
|
|
||||||
# TC # English return something like:
|
# TC # English return something like:
|
||||||
|
Loading…
Reference in New Issue
Block a user