[hamster-applet] now using translation context instead of my wonder things.



commit 7c18874862c3481e1c40e25f21aa2f9fc7a3072e
Author: Toms Bauģis <toms baugis gmail com>
Date:   Mon Jul 20 13:49:01 2009 +0300

    now using translation context instead of my wonder things.
    could potentially use it for dates, hmmm

 hamster/Makefile.am |    1 +
 hamster/i18n.py     |   12 ++++++++++++
 hamster/stats.py    |    8 +++++---
 3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/hamster/Makefile.am b/hamster/Makefile.am
index 28e753d..340c794 100644
--- a/hamster/Makefile.am
+++ b/hamster/Makefile.am
@@ -31,6 +31,7 @@ hamster_PYTHON = \
 	about.py \
 	hamsterdbus.py \
 	idle.py \
+        i18n.py \
 	__init__.py
 
 BUILT_SOURCES = \
diff --git a/hamster/i18n.py b/hamster/i18n.py
new file mode 100644
index 0000000..8055f25
--- /dev/null
+++ b/hamster/i18n.py
@@ -0,0 +1,12 @@
+# - coding: utf-8 -
+import gettext
+
+def C_(ctx, s):
+    """Provide qualified translatable strings via context.
+        Taken from gnome-games.
+    """
+    translated = gettext.gettext('%s\x04%s' % (ctx, s))
+    if '\x04' in translated:
+        # no translation found, return input string
+        return s
+    return translated
diff --git a/hamster/stats.py b/hamster/stats.py
index 7bff23c..a3d2c13 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -39,6 +39,7 @@ from gettext import ngettext
 import datetime as dt
 import calendar
 import time
+from hamster.i18n import C_
 
 class ReportChooserDialog(gtk.Dialog):
     __gsignals__ = {
@@ -116,8 +117,7 @@ class ReportChooserDialog(gtk.Dialog):
         self.end_date.set_date(end_date)
         
         #add unsorted category
-        button_all = gtk.CheckButton((_("All %(categories)s") %
-                                       dict(categories = '')).strip().encode("utf-8"))
+        button_all = gtk.CheckButton(C_("categories", "All").encode("utf-8"))
         button_all.value = None
         button_all.set_active(True)
         
@@ -430,7 +430,9 @@ class StatsViewer(object):
                 self.year = year
                 self.connect("clicked", on_clicked)
         
-        all_button = YearButton((_("All %(years)s") % dict(years = "")).strip().encode("utf-8"), None, self.on_year_changed)
+        all_button = YearButton(C_("years", "All").encode("utf-8"),
+                                None,
+                                self.on_year_changed)
         year_box.pack_start(all_button)
         self.bubbling = True # TODO figure out how to properly work with togglebuttons as radiobuttons
         all_button.set_active(True)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]