[Inteproxy-commits] r87 - in trunk: . inteproxy po

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue May 8 15:18:24 CEST 2007


Author: bh
Date: 2007-05-08 15:18:23 +0200 (Tue, 08 May 2007)
New Revision: 87

Added:
   trunk/inteproxy/resources.py
   trunk/po/
   trunk/po/Makefile
   trunk/po/README
   trunk/po/de.po
Modified:
   trunk/ChangeLog
   trunk/inteproxy/getpassword.py
   trunk/inteproxy/gtkapp.py
Log:
* po/de.po: New. German translations

* po/Makefile: New. Commands to manage translations

* po/README: New. Notes aout translations in InteProxy

* inteproxy/resources.py: New.  Provides acces to resources
bundled with inteproxy.  For now only implements translations.

* inteproxy/gtkapp.py (InteProxyApplication),
inteproxy/getpassword.py (get_password_with_cache):
Internationalization of strings


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/ChangeLog	2007-05-08 13:18:23 UTC (rev 87)
@@ -1,5 +1,25 @@
+2007-05-08  Bernhard Herzog  <bh at intevation.de>
+
+	* po/de.po: New. German translations
+
+	* po/Makefile: New. Commands to manage translations
+
+	* po/README: New. Notes aout translations in InteProxy
+
+	* inteproxy/resources.py: New.  Provides acces to resources
+	bundled with inteproxy.  For now only implements translations.
+
+	* inteproxy/gtkapp.py (InteProxyApplication),
+	inteproxy/getpassword.py (get_password_with_cache):
+	Internationalization of strings
+
 2007-05-07  Bernhard Herzog  <bh at intevation.de>
 
+	* inteproxy/gtkapp.py, inteproxy/getpassword.py: Mark strings for
+	translation
+
+2007-05-07  Bernhard Herzog  <bh at intevation.de>
+
 	* inteproxy/feesdialog.py (handle_fees_and_access_constraints):
 	Remove the little test exececuted when the module is run as a
 	script.  It doesn't work anymore and the dialog is now in

Modified: trunk/inteproxy/getpassword.py
===================================================================
--- trunk/inteproxy/getpassword.py	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/inteproxy/getpassword.py	2007-05-08 13:18:23 UTC (rev 87)
@@ -10,6 +10,7 @@
 import threading
 
 import inteproxy.main
+from inteproxy.resources import gettext as _
 
 
 
@@ -34,7 +35,7 @@
         if path in pw_cache:
             user, password = pw_cache[path]
         else:
-            title = "Username for %s: " % path
+            title = _("Username for %s:") % path
             user, password = inteproxy.main.the_application.get_password(title)
 
             # cache the password if the user didn't cancel.

Modified: trunk/inteproxy/gtkapp.py
===================================================================
--- trunk/inteproxy/gtkapp.py	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/inteproxy/gtkapp.py	2007-05-08 13:18:23 UTC (rev 87)
@@ -15,6 +15,7 @@
 
 import inteproxy.app
 import inteproxy.main
+from inteproxy.resources import gettext as _
 
 
 def run_password_dialog(title):
@@ -25,7 +26,7 @@
     information entered by the user.  If the user cancels the dialog,
     both values are None.
     """
-    dialog = gtk.Dialog("My dialog", None,
+    dialog = gtk.Dialog(_("InteProxy: Login"), None,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
                          gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
@@ -47,8 +48,8 @@
                      xpadding=5, ypadding=5)
         return entry
 
-    username_entry = add_field(0, "Username:", True)
-    password_entry = add_field(1, "Password:", False)
+    username_entry = add_field(0, _("Username:"), True)
+    password_entry = add_field(1, _("Password:"), False)
 
     table.show_all()
 
@@ -101,7 +102,7 @@
     if not fees and not access_constraints:
         return
 
-    dialog = gtk.Dialog("Fees and AccessConstraints", None,
+    dialog = gtk.Dialog(_("InteProxy: Fees and AccessConstraints"), None,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dialog.set_size_request(320, 240)
@@ -122,14 +123,15 @@
 
     bi = buf.get_iter_at_offset(0)
 
-    buf.insert_with_tags_by_name(bi, "Service information for '%s'\n" % title,
+    buf.insert_with_tags_by_name(bi,
+                                 _("Service information for '%s'\n") % title,
                                  "title")
     if fees:
-        buf.insert_with_tags_by_name(bi, "Fees:\n", "heading")
+        buf.insert_with_tags_by_name(bi, _("Fees:\n"), "heading")
         buf.insert(bi, fees)
         buf.insert(bi, "\n")
     if access_constraints:
-        buf.insert_with_tags_by_name(bi, "Access Constraints:\n", "heading")
+        buf.insert_with_tags_by_name(bi, _("Access Constraints:\n"), "heading")
         buf.insert(bi, access_constraints)
         buf.insert(bi, "\n")
 
@@ -213,7 +215,7 @@
         constructor = getattr(gtk, "status_icon_new_from_file",  None)
         if constructor is not None:
             self.status_icon = constructor(image_filename("InteProxy-icon.png"))
-            self.status_icon.set_tooltip("InteProxy")
+            self.status_icon.set_tooltip(_("InteProxy"))
             self.status_icon.connect("activate", self.show_window)
             self.status_icon.connect("popup-menu", self.popup_menu)
         else:
@@ -256,7 +258,7 @@
         self.add_accel_group(self.application.ui.get_accel_group())
 
         self.set_position(gtk.WIN_POS_CENTER)
-        self.set_title('InteProxy')
+        self.set_title(_('InteProxy'))
         self.connect('delete-event', self.delete_event)
         self.set_size_request(320, 240)
         vbox = gtk.VBox()
@@ -286,8 +288,8 @@
         buf.insert(bi, "\n")
         buf.apply_tag_by_name("centered", buf.get_iter_at_offset(0), bi)
 
-        buf.insert(bi, "InteProxy can be used as HTTP-proxy"
-                   " with the following URL:\n")
+        buf.insert(bi, _("InteProxy can be used as HTTP-proxy"
+                         " with the following URL:\n"))
 
         url = self.application.server.get_inteproxy_url()
         buf.insert_with_tags_by_name(bi, url, "monospace", "centered")
@@ -350,17 +352,17 @@
         """Internal: Parses the ui_definition"""
         ag = gtk.ActionGroup('WindowActions')
         actions = [
-            ('FileMenu', None, '_File'),
-            ('Close',    gtk.STOCK_CLOSE, '_Close', '<control>W',
-             'Close the InteProxy window', self.hide_main_window),
-            ('Quit',     gtk.STOCK_QUIT, '_Quit', '<control>Q',
-             'Quit application', self.quit),
-            ('HelpMenu', None, '_Help'),
-            ('About',    None, '_About', None, 'About application',
+            ('FileMenu', None, _('_File')),
+            ('Close',    gtk.STOCK_CLOSE, _('_Close'), '<control>W',
+             _('Close the InteProxy window'), self.hide_main_window),
+            ('Quit',     gtk.STOCK_QUIT, _('_Quit'), '<control>Q',
+             _('Quit application'), self.quit),
+            ('HelpMenu', None, _('_Help')),
+            ('About',    None, _('_About'), None, _('About application'),
              self.run_about_dialog),
             ('StatusIconMenu', None, '_StatusIconMenu'),
-            ('ShowWindow', None, '_Show Window', '<control>S',
-             'Show the InteProxy window', self.show_main_window),
+            ('ShowWindow', None, _('_Show Window'), '<control>S',
+             _('Show the InteProxy window'), self.show_main_window),
             ]
         ag.add_actions(actions)
         self.ui = gtk.UIManager()
@@ -394,12 +396,13 @@
 
     def run_about_dialog(self, *args):
         """Run the about dialog"""
-        run_about_dialog(self, name="InteProxy",
+        run_about_dialog(self, name=_("InteProxy"),
                          logo=load_image("InteProxy-logo.png"),
                          version=inteproxy.main.inteproxy_version,
-                         copyright="Copyright 2006, 2007 by Intevation GmbH",
-                         comments="InteProxy is distributed under the"
-                         " GNU General Public License (GPL) version 2 or later",
+                         copyright=_("Copyright 2006, 2007 by Intevation GmbH"),
+                         comments=_("InteProxy is distributed under the"
+                                    " GNU General Public License (GPL)"
+                                    " version 2 or later"),
                          website="http://inteproxy.wald.intevation.org/")
 
     def get_password(self, *args):

Added: trunk/inteproxy/resources.py
===================================================================
--- trunk/inteproxy/resources.py	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/inteproxy/resources.py	2007-05-08 13:18:23 UTC (rev 87)
@@ -0,0 +1,23 @@
+# Copyright (C) 2007 by Intevation GmbH
+# Authors:
+# Bernhard Herzog <bh at intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+"""Access to resources bundled with InteProxy"""
+
+import os
+import gettext as py_gettext
+
+def gettext(message):
+    """Translates the message according to the user's locale.
+
+    If a translation can be found, the return value is a unicode object
+    otherwise the message is returned unchanged.
+    """
+    modir = os.path.join(os.path.dirname(__file__),
+                         "..", "share", "locale")
+    t = py_gettext.translation("inteproxy", modir)
+
+    return t.ugettext(message)


Property changes on: trunk/inteproxy/resources.py
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/po/Makefile
===================================================================
--- trunk/po/Makefile	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/po/Makefile	2007-05-08 13:18:23 UTC (rev 87)
@@ -0,0 +1,42 @@
+all:
+	@echo 'Usage:'
+	@echo '   make pot     create inteproxy.pot'
+	@echo '   make merge   merge a new inteproxy.pot with the *.po files'
+	@echo '   make mo      create the mo files'
+	@echo '   make stat    print statistics about the translation status'
+
+MO_DIR = ../share/locale
+DOMAIN = inteproxy
+
+pot:
+	pygettext -o $(DOMAIN).pot ../inteproxy/*.py
+
+merge:
+	for po in *.po; do \
+		lingua=`basename $$po .po`; \
+	        mv $$lingua.po $$lingua.old.po; \
+		if msgmerge -o $$lingua.po $$lingua.old.po $(DOMAIN).pot; then\
+		    rm $$lingua.old.po; \
+		else \
+		    rm -f $$lingua.po; \
+		    mv $$lingua.old.po $$lingua.po; \
+		fi \
+	done
+
+
+mo:
+	for po in *.po; do\
+		lingua=`basename $$po .po`; \
+		install -d $(MO_DIR)/$$lingua/LC_MESSAGES/ ; \
+		echo -n $$po": "; \
+		msgfmt --statistics \
+			-o $(MO_DIR)/$$lingua/LC_MESSAGES/$(DOMAIN).mo $$po ;\
+	done
+
+
+stat:
+	@for po in *.po; do\
+		echo -n $$po": "; \
+		msgfmt --statistics -o /dev/null $$po 2>&1 \
+		 | sed -e 's/ \(messages*\|translations*\)//g' -e 's/\.$$//' ; \
+	done


Property changes on: trunk/po/Makefile
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/po/README
===================================================================
--- trunk/po/README	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/po/README	2007-05-08 13:18:23 UTC (rev 87)
@@ -0,0 +1,34 @@
+InteProxy Message Translations
+==============================
+
+The message catalogs are managed with the following software:
+
+ - pygettext (usually distributed with Python)
+
+ - GNU gettext (msgmerge and msgfmt)
+
+
+Common tasks:
+
+ - Create/Update inteproxy.pot-File when the sources were edited and
+   messages have been added or changed and after a fresh checkout
+
+     $ make pot
+
+ - When the inteproxy.pot has been changed, run
+
+     $ make merge
+
+   to merge the changes in the pot file with the messages already in the
+   *.po files.
+
+ - When the translations in the po files have been changed, run
+
+     $ make mo
+
+   to generate new .mo files under ../share/locale
+
+ - The make mo command prints statistics about the translations.  To get
+   a less verbose version use this:
+
+     $ make stat


Property changes on: trunk/po/README
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/po/de.po
===================================================================
--- trunk/po/de.po	2007-05-07 14:40:22 UTC (rev 86)
+++ trunk/po/de.po	2007-05-08 13:18:23 UTC (rev 87)
@@ -0,0 +1,107 @@
+# German translations for InteProxy.
+# Copyright (C) 2007 Intevation GmbH
+# Bernhard Herzog <bh at intevation.de>, 2007.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: InteProxy SVN\n"
+"POT-Creation-Date: 2007-05-08 11:34+CEST\n"
+"PO-Revision-Date: 2007-05-07 16:55+CEST\n"
+"Last-Translator: Bernhard Herzog <bh at intevation.de>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+"Generated-By: pygettext.py 1.5\n"
+
+#: ../inteproxy/getpassword.py:38
+msgid "Username for %s:"
+msgstr "Benutzername für %s:"
+
+#: ../inteproxy/gtkapp.py:29
+msgid "InteProxy: Login"
+msgstr "InteProxy: Login"
+
+#: ../inteproxy/gtkapp.py:51
+msgid "Username:"
+msgstr "Benutzername:"
+
+#: ../inteproxy/gtkapp.py:52
+msgid "Password:"
+msgstr "Passwort:"
+
+#: ../inteproxy/gtkapp.py:105
+msgid "InteProxy: Fees and AccessConstraints"
+msgstr "InteProxy: Gebühren und Zugriffsbeschränkungen"
+
+#: ../inteproxy/gtkapp.py:127
+msgid "Service information for '%s'\n"
+msgstr "Serviceinformation für '%s'\n"
+
+#: ../inteproxy/gtkapp.py:130
+msgid "Fees:\n"
+msgstr "Gebühren:\n"
+
+#: ../inteproxy/gtkapp.py:134
+msgid "Access Constraints:\n"
+msgstr "Zugriffsbeschränkungen:\n"
+
+#: ../inteproxy/gtkapp.py:218 ../inteproxy/gtkapp.py:261
+#: ../inteproxy/gtkapp.py:399
+msgid "InteProxy"
+msgstr "InteProxy"
+
+#: ../inteproxy/gtkapp.py:291
+msgid "InteProxy can be used as HTTP-proxy with the following URL:\n"
+msgstr ""
+"InteProxy kann mit der folgenden URL als HTTP-Proxy verwendet werden:\n"
+
+#: ../inteproxy/gtkapp.py:355
+msgid "_File"
+msgstr "_Datei"
+
+#: ../inteproxy/gtkapp.py:356
+msgid "_Close"
+msgstr "_Schließen"
+
+#: ../inteproxy/gtkapp.py:357
+msgid "Close the InteProxy window"
+msgstr "Das InteProxy-Fenster schließen"
+
+#: ../inteproxy/gtkapp.py:358
+msgid "_Quit"
+msgstr "_Beenden"
+
+#: ../inteproxy/gtkapp.py:359
+msgid "Quit application"
+msgstr "Beendet die Anwendung"
+
+#: ../inteproxy/gtkapp.py:360
+msgid "_Help"
+msgstr "_Hilfe"
+
+#: ../inteproxy/gtkapp.py:361
+msgid "About application"
+msgstr "Über InteProxy"
+
+#: ../inteproxy/gtkapp.py:361
+msgid "_About"
+msgstr "_Über"
+
+#: ../inteproxy/gtkapp.py:364
+msgid "_Show Window"
+msgstr "Fenster _zeigen"
+
+#: ../inteproxy/gtkapp.py:365
+msgid "Show the InteProxy window"
+msgstr "InteProxy Fenster zeigen"
+
+#: ../inteproxy/gtkapp.py:402
+msgid "Copyright 2006, 2007 by Intevation GmbH"
+msgstr "Copyright 2006, 2007 by Intevation GmbH"
+
+#: ../inteproxy/gtkapp.py:403
+msgid ""
+"InteProxy is distributed under the GNU General Public License (GPL) version "
+"2 or later"
+msgstr ""
+"InteProxy steht unter der GNU General Public License (GPL) version 2 oder "
+"später"


Property changes on: trunk/po/de.po
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Inteproxy-commits mailing list