Better localization support for decimal separator.
svn: r11999
This commit is contained in:
parent
00a667a54e
commit
ce8b02c9f6
@ -21,6 +21,8 @@
|
|||||||
This Gramplet shows textual distributions of age breakdowns of various types.
|
This Gramplet shows textual distributions of age breakdowns of various types.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import locale
|
||||||
|
|
||||||
from DataViews import register, Gramplet
|
from DataViews import register, Gramplet
|
||||||
import gen.lib
|
import gen.lib
|
||||||
|
|
||||||
@ -214,7 +216,7 @@ class AgeStatsGramplet(Gramplet):
|
|||||||
retval = _("Statistics") + ":\n"
|
retval = _("Statistics") + ":\n"
|
||||||
retval += " " + _("Total") + ": %d\n" % count
|
retval += " " + _("Total") + ": %d\n" % count
|
||||||
retval += " " + _("Minimum") + ": %d\n" % minval
|
retval += " " + _("Minimum") + ": %d\n" % minval
|
||||||
retval += " " + _("Average") + ": %.1f\n" % average
|
retval += " " + _("Average") + locale.format_string(": %.1f\n", average)
|
||||||
retval += " " + _("Median") + ": %d\n" % median
|
retval += " " + _("Median") + ": %d\n" % median
|
||||||
retval += " " + _("Maximum") + ": %d\n" % maxval
|
retval += " " + _("Maximum") + ": %d\n" % maxval
|
||||||
return retval
|
return retval
|
||||||
@ -253,10 +255,7 @@ class AgeStatsGramplet(Gramplet):
|
|||||||
selected,
|
selected,
|
||||||
tooltip=_("Double-click to see %d people") % len(selected))
|
tooltip=_("Double-click to see %d people") % len(selected))
|
||||||
procent = float(len(selected))/(float(sum(hash.values())))*100
|
procent = float(len(selected))/(float(sum(hash.values())))*100
|
||||||
if procent > 10.0:
|
self.append_text(locale.format("%#5.2f", procent))
|
||||||
self.append_text("%2.2f" % procent)
|
|
||||||
else:
|
|
||||||
self.append_text("% 1.2f" % procent)
|
|
||||||
self.append_text("\n")
|
self.append_text("\n")
|
||||||
i += 1
|
i += 1
|
||||||
self.append_text("--------" + self.format("", graph_width-4, fill = "-", borders="++") + "-----\n")
|
self.append_text("--------" + self.format("", graph_width-4, fill = "-", borders="++") + "-----\n")
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import cgi
|
import cgi
|
||||||
|
import locale
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -247,13 +248,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 = '%.2f%s' % ( 100, percent_sign)
|
percent = locale.format( '%.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 = '%.2f%s' % ( float(count)/2**(g-1) * 100, percent_sign)
|
percent = locale.format('%.2f', float(count)/2**(g-1) * 100) + percent_sign
|
||||||
self.append_text(ngettext(
|
self.append_text(ngettext(
|
||||||
" has %(count_person)d of %(max_count_person)d individuals (%(percent)s complete)\n",
|
" has %(count_person)d of %(max_count_person)d individuals (%(percent)s complete)\n",
|
||||||
" has %(count_person)d of %(max_count_person)d individuals (%(percent)s complete)\n",
|
" has %(count_person)d of %(max_count_person)d individuals (%(percent)s complete)\n",
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from gettext import ngettext
|
from gettext import ngettext
|
||||||
|
import locale
|
||||||
import math
|
import math
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -95,7 +96,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 = '(%3.2f%%)' % ((sum(thisgen.values()) / theoretical ) * 100)
|
percent = '(%s%%)' % locale.format('%3.2f', ((sum(thisgen.values()) / theoretical ) * 100))
|
||||||
|
|
||||||
# TC # English return something like:
|
# TC # English return something like:
|
||||||
# Generation 3 has 2 individuals. (50.00%)
|
# Generation 3 has 2 individuals. (50.00%)
|
||||||
|
Loading…
Reference in New Issue
Block a user