[hamster-applet] fixed bug 617774 - respecting decimal separator for the locale
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] fixed bug 617774 - respecting decimal separator for the locale
- Date: Wed, 5 May 2010 15:41:11 +0000 (UTC)
commit 61107a2c5313722ef08b3068025bba56a0ece12e
Author: Toms Bauģis <toms baugis gmail com>
Date: Wed May 5 16:40:59 2010 +0100
fixed bug 617774 - respecting decimal separator for the locale
src/hamster/applet.py | 3 ++-
src/hamster/charting.py | 3 ++-
src/hamster/overview_totals.py | 3 ++-
src/hamster/stats.py | 7 ++++---
4 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/hamster/applet.py b/src/hamster/applet.py
index f0e97d9..0481ebc 100755
--- a/src/hamster/applet.py
+++ b/src/hamster/applet.py
@@ -29,6 +29,7 @@ import gtk
import gnomeapplet
import gobject
import dbus, dbus.service, dbus.mainloop.glib
+import locale
import eds
from configuration import conf, runtime, dialogs
@@ -383,7 +384,7 @@ class HamsterApplet(object):
total_strings = []
for category in by_category:
# listing of today's categories and time spent in them
- duration = "%.1f" % (by_category[category] / 60.0)
+ duration = locale.format("%.1f", (by_category[category] / 60.0))
total_strings.append(_("%(category)s: %(duration)s") % \
({'category': category,
#duration in main drop-down per category in hours
diff --git a/src/hamster/charting.py b/src/hamster/charting.py
index 7d62d6e..419053e 100644
--- a/src/hamster/charting.py
+++ b/src/hamster/charting.py
@@ -22,6 +22,7 @@ import pango
import datetime as dt
import time
import graphics
+import locale
class Bar(graphics.Shape):
def __init__(self, key, value, normalized, label_color):
@@ -136,7 +137,7 @@ class Chart(graphics.Scene):
normalized = value / max_val
else:
normalized = 0
- bar = Bar(key, self.value_format % value, normalized, self.label_color)
+ bar = Bar(key, locale.format(self.value_format, value), normalized, self.label_color)
bar.interactive = self.graph_interactive
if key in bars:
diff --git a/src/hamster/overview_totals.py b/src/hamster/overview_totals.py
index 809d686..a83d3f7 100644
--- a/src/hamster/overview_totals.py
+++ b/src/hamster/overview_totals.py
@@ -22,6 +22,7 @@ import calendar
import time
import webbrowser
from itertools import groupby
+import locale
from gettext import ngettext
@@ -144,7 +145,7 @@ class TotalsBox(gtk.VBox):
facts = copy.deepcopy(self.facts)
total_hours = sum([stuff.duration_minutes(fact["delta"]) for fact in facts])
- total_label = _("%s hours tracked total") % ("%.1f" % (total_hours / 60.0))
+ total_label = _("%s hours tracked total") % locale.format("%.1f", total_hours / 60.0)
self.get_widget("total_hours").set_text(total_label)
diff --git a/src/hamster/stats.py b/src/hamster/stats.py
index 320b1e2..8c33224 100644
--- a/src/hamster/stats.py
+++ b/src/hamster/stats.py
@@ -26,6 +26,7 @@ import datetime as dt
import calendar
from itertools import groupby
from gettext import ngettext
+import locale
import gtk, gobject
import pango
@@ -322,11 +323,11 @@ A week of usage would be nice!"""))
human_years_str = ngettext("%(num)s year",
"%(num)s years",
total_delta.days / 365) % {
- 'num': "<b>%.2f</b>" % (total_delta.days / 365.0)}
+ 'num': "<b>%s</b>" % locale.format("%.2f", (total_delta.days / 365.0))}
working_years_str = ngettext("%(num)s year",
"%(num)s years",
total_delta.days * 3 / 365) % {
- 'num': "<b>%.2f</b>" % (total_delta.days * 3 / 365.0) }
+ 'num': "<b>%s</b>" % locale.format("%.2f", (total_delta.days * 3 / 365.0)) }
#FIXME: difficult string to properly pluralize
summary += " " + _("""Time tracked so far is %(human_days)s human days \
(%(human_years)s) or %(working_days)s working days (%(working_years)s).""") % {
@@ -349,7 +350,7 @@ A week of usage would be nice!"""))
C_("date of the longest activity", "%b %d, %Y"))
num_hours = max_fact["delta"].seconds / 60 / 60.0 + max_fact["delta"].days * 24
- hours = "<b>%.1f</b>" % (num_hours)
+ hours = "<b>%s</b>" % locale.format("%.1f", num_hours)
summary += "\n" + ngettext("Longest continuous work happened on \
%(date)s and was %(hours)s hour.",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]