Revision: 3985
Author: wikipedian
Date: 2007-08-07 14:31:30 +0000 (Tue, 07 Aug 2007)
Log Message:
-----------
experimental: code for user interface internationalization, using gettext
Modified Paths:
--------------
trunk/pywikipedia/config.py
trunk/pywikipedia/selflink.py
trunk/pywikipedia/wikipedia.py
Added Paths:
-----------
trunk/pywikipedia/translations/
trunk/pywikipedia/translations/de/
trunk/pywikipedia/translations/de/LC_MESSAGES/
trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.mo
trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.po
trunk/pywikipedia/translations/en/
trunk/pywikipedia/translations/en/LC_MESSAGES/
trunk/pywikipedia/translations/en/LC_MESSAGES/pywikipedia.mo
trunk/pywikipedia/translations/en/LC_MESSAGES/pywikipedia.po
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2007-08-07 13:13:22 UTC (rev 3984)
+++ trunk/pywikipedia/config.py 2007-08-07 14:31:30 UTC (rev 3985)
@@ -85,6 +85,8 @@
# tkinter isn't yet ready
userinterface = 'terminal'
+userinterface_lang = None
+
# What color should we used for text? This should match your
# operating system's default color for console text.
# Note: This setting is only required for Windows users.
Modified: trunk/pywikipedia/selflink.py
===================================================================
--- trunk/pywikipedia/selflink.py 2007-08-07 13:13:22 UTC (rev 3984)
+++ trunk/pywikipedia/selflink.py 2007-08-07 14:31:30 UTC (rev 3985)
@@ -36,8 +36,6 @@
}
# Summary messages in different languages
-# NOTE: Predefined replacement tasks might use their own dictionary, see 'fixes'
-# below.
msg = {
'de':u'Bot: Entferne Selbstlinks',
'en':u'Robot: Removing selflinks',
@@ -110,7 +108,7 @@
# at the end of the link, reset the color to default
colors = [None for c in text[max(0, match.start() - context) :
match.start()]] + [12 for c in text[match.start() : match.end()]] + [None for c in
text[match.end() : match.end() + context]]
wikipedia.output(text[max(0, match.start() - context) : match.end() +
context], colors = colors)
- choice = wikipedia.inputChoice(u'\nWhat shall be done with this
selflink?', ['unlink', 'make bold', 'skip', 'edit',
'more context'], ['U', 'b', 's', 'e',
'm'], 'u')
+ choice = wikipedia.inputChoice(_(u'\nWhat shall be done with this
selflink?'), ['unlink', 'make bold', 'skip', 'edit',
'more context'], ['u', 'b', 's', 'e',
'm'], 'u')
wikipedia.output(u'')
if choice == 's':
Added: trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.mo
===================================================================
(Binary files differ)
Property changes on: trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.po
===================================================================
--- trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.po
(rev 0)
+++ trunk/pywikipedia/translations/de/LC_MESSAGES/pywikipedia.po 2007-08-07 14:31:30 UTC
(rev 3985)
@@ -0,0 +1,29 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2007-08-07 16:25+CEST\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL(a)li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: ENCODING\n"
+"Generated-By: pygettext.py 1.5\n"
+
+#: selflink.py:111
+msgid ""
+"\n"
+"What shall be done with this selflink?"
+msgstr "Was soll mit diesem Selbstlink gemacht werden?"
+
+#: wikipedia.py:2414
+msgid ""
+"Checked for running processes. %i processes currently running, including the
"
+"current process."
+msgstr ""
+"Prüfe auf laufende Prozesse. %i Prozesse laufen momentan, diesen Prozess "
+"eingeschlossen."
Added: trunk/pywikipedia/translations/en/LC_MESSAGES/pywikipedia.mo
===================================================================
(Binary files differ)
Property changes on: trunk/pywikipedia/translations/en/LC_MESSAGES/pywikipedia.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/pywikipedia/translations/en/LC_MESSAGES/pywikipedia.po
===================================================================
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-08-07 13:13:22 UTC (rev 3984)
+++ trunk/pywikipedia/wikipedia.py 2007-08-07 14:31:30 UTC (rev 3985)
@@ -118,11 +118,12 @@
import traceback
import time, threading, Queue
import math
-import re, md5, codecs, difflib, locale
+import re, md5, codecs, difflib
import xml.sax, xml.sax.handler
import htmlentitydefs
import warnings
import unicodedata
+import gettext, locale
import config, login
import xmlreader
@@ -2410,7 +2411,7 @@
f.write(str(p)+' '+str(processes[p])+'\n')
f.close()
self.process_multiplicity = count
- output(u"Checked for running processes. %s processes currently running,
including the current process." % count)
+ output(_(u"Checked for running processes. %i processes currently
running, including the current process.") % count)
finally:
self.lock.release()
@@ -4215,6 +4216,8 @@
""")
sys.exit(1)
+ui_langs = [(config.userinterface_lang or config.mylang), 'en']
+gettext.translation(domain = 'pywikipedia', localedir =
_wt.absoluteFilename('translations'), languages = ui_langs).install(unicode =
True)
# Languages to use for comment text after the actual language but before
# en:. For example, if for language 'xx', you want the preference of