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

[or-cvs] [bridgedb/master 3/3] Adopted changes according to Nickm's review at https://trac.torproject.org/projects/tor/ticket/1613 Also, let users request languages by URL via /?lang=foo *and* /foo (Thanks, arma)



Author: Christian Fromme <kaner@xxxxxxxxxx>
Date: Wed, 29 Sep 2010 14:53:51 +0200
Subject: Adopted changes according to Nickm's review at https://trac.torproject.org/projects/tor/ticket/1613
Commit: da2718a1f141b1d6d14191502db8e517ba2c244f

---
 README                      |    6 ++
 bridgedb.conf               |    2 -
 i18n/de/bridgedb.po         |  170 ++++++++++++-------------------------------
 i18n/en/bridgedb.po         |  101 +++++++-------------------
 i18n/templates/bridgedb.pot |  101 +++++++-------------------
 lib/bridgedb/I18n.py        |   82 +++++++--------------
 lib/bridgedb/Main.py        |    6 --
 lib/bridgedb/Server.py      |   84 ++++++++++++++++-----
 8 files changed, 199 insertions(+), 353 deletions(-)

diff --git a/README b/README
index 70bfc8a..a4e4d37 100644
--- a/README
+++ b/README
@@ -4,12 +4,18 @@ To set up:
  - Install Twisted-Web, Twisted-Mail, PyOpenSSL, and all their dependencies.
  - To run unit tests, "python setup.py test"
  - python setup.py install --prefix=$HOME
+ - To generate translation files, run "python setup.py trans" and then run
+   "python setup.py install_data" to install them
  - Edit bridgedb.conf; put it somewhere good.
  - Make sure that the input files referred to in bridgedb.conf exist.
    - You can make a self-signed certificate with
      openssl req -x509 -new -nodes > cert
  - Set up PYTHONPATH to include "~/lib/python2.4/site-packages/".
 
+To re-generate the i18n template (in case translation strings have changed 
+in BridgeDB):
+ - Run "xgettext lib/bridgedb/I18n.py -dbridgedb -oi18n/templates/bridgedb.pot"
+
 To run:
  - Run "python -m TorBridgeDB bridgedb.conf"
 
diff --git a/bridgedb.conf b/bridgedb.conf
index 625e53e..897ff13 100644
--- a/bridgedb.conf
+++ b/bridgedb.conf
@@ -139,5 +139,3 @@ EMAIL_INCLUDE_FINGERPRINTS=False
 # to these groups in a proportion of
 #   HTTPS_SHARE : EMAIL_SHARE : RESERVED_SHARE
 RESERVED_SHARE=2
-
-CONFIGURED_LOCALES = [ "en", "de" ]
diff --git a/i18n/de/bridgedb.po b/i18n/de/bridgedb.po
index 108cbec..420c73c 100644
--- a/i18n/de/bridgedb.po
+++ b/i18n/de/bridgedb.po
@@ -1,163 +1,87 @@
 # SOME DESCRIPTIVE TITLE.
 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# Christian Fromme <kaner@xxxxxxxxxx>, 2010
 #
 #, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-08-14 13:28+0200\n"
+"POT-Creation-Date: 2010-09-29 14:16+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: lib/bridgedb/I18n.py:7
-msgid ""
-"\n"
-"    Here are your bridge relays:\n"
-"    "
-msgstr ""
-"\n"
-"   Hier sind deine Bridge Relays:\n"
-"    "
-
-#: lib/bridgedb/I18n.py:11
-msgid ""
-"\n"
-"    Bridge relays (or \"bridges\" for short) are Tor relays that aren't "
-"listed\n"
-"    in the main directory. Since there is no complete public list of them,\n"
-"    even if your ISP is filtering connections to all the known Tor relays,\n"
-"    they probably won't be able to block all the bridges.\n"
-"    "
-msgstr ""
-"\n"
-"    Sogenannte \"Bridge Relays\" (oder kurz \"Bridges\" ) sind Tor Relays, die"
-"    nicht in den oeffentlich publizierten Relay-Listen auftauchen."
-"    Dadurch, dass die Bridges der Oeffentlichkeit nicht bekannt ist, "
-"    sind ISPs nicht dazu in der Lage, alle Tor Relays zu filtern."
-"    "
-
-#: lib/bridgedb/I18n.py:18
-msgid ""
-"\n"
-"    To use the above lines, go to Vidalia's Network settings page, and "
-"click\n"
-"    \"My ISP blocks connections to the Tor network\". Then add each bridge\n"
-"    address one at a time.\n"
-"    "
-msgstr ""
-"\n"
-"    Um die oben genannten Zeilen zu nutzen, sollten Sie in Vidalia's   "
-"    Network Settings gehen und den Menuepunkt \"Mein ISP blockt Verbindungen "
-"    zum Tor Netzwerk\" anklicken. Anschliessend koennen sie die Bridge-Adressen"
-"    hinzufuegen."
-"    "
-
-#: lib/bridgedb/I18n.py:24
-msgid ""
-"\n"
-"    Configuring more than one bridge address will make your Tor connection\n"
-"    more stable, in case some of the bridges become unreachable.\n"
-"    "
-msgstr ""
-"\n"
-"    Mehr als eine Brigde-Adresse zu verwenden fuehrt zu einer stabileren\n"
-"    Verbindung. Es kann immer sein, dass mal eine Bridge kurzzeitig nicht "
-"    erreichbar ist.\n"
-"    "
+#: lib/bridgedb/I18n.py:21
+msgid "Here are your bridge relays: "
+msgstr "Hier sind Ihre Bridge Relays: "
 
-#: lib/bridgedb/I18n.py:29
+#: lib/bridgedb/I18n.py:23
 msgid ""
-"\n"
-"    Another way to find public bridge addresses is to send mail to\n"
-"    bridges@xxxxxxxxxxxxxx with the line \"get bridges\" by itself in the "
-"body\n"
-"    of the mail. However, so we can make it harder for an attacker to learn\n"
-"    lots of bridge addresses, you must send this request from a gmail or\n"
-"    yahoo account.\n"
-"    "
-msgstr ""
-"\n"
-"    Eine weitere Moeglichkeit Bridge-Adressen zu finden ist, eine Email\n"
-"    an bridges@xxxxxxxxxxxxxx mit der Zeile \"get bridges\" zu Schreiben.\n"
-"    Diesen Reqeuest muessen Sie allerdings von einem GMail oder Yahoo-Account"
-"    schicken.\n"
-"    "
-
-#: lib/bridgedb/I18n.py:48
-msgid ""
-"\n"
-"[This is an automated message; please do not reply.]\n"
-msgstr ""
-"\n"
-"[Diese Mail wurde elektronisch erstellt; Bitte nicht antworten.]\n"
-
-#: lib/bridgedb/I18n.py:52
-msgid ""
-"\n"
-"Here are your bridge relays:\n"
-msgstr ""
-"\n"
-"Hier sind Ihre Bridge Relays:\n"
-
-#: lib/bridgedb/I18n.py:56
-msgid ""
-"\n"
 "Bridge relays (or \"bridges\" for short) are Tor relays that aren't listed\n"
 "in the main directory. Since there is no complete public list of them,\n"
 "even if your ISP is filtering connections to all the known Tor relays,\n"
-"they probably won't be able to block all the bridges.\n"
+"they probably won't be able to block all the bridges."
 msgstr ""
-"\n"
-"    Sogenannte \"Bridge Relays\" (oder kurz \"Bridges\" ) sind Tor Relays, die"
-"    nicht in den oeffentlich publizierten Relay-Listen auftauchen."
-"    Dadurch, dass die Bridges der Oeffentlichkeit nicht bekannt ist, "
-"    sind ISPs nicht dazu in der Lage, alle Tor Relays zu filtern.\n"
+"Sogenannte \"Bridge Relays\" (oder kurz \"Bridges\" ) sind Tor Relays, die\n"
+"nicht in den oeffentlich publizierten Relay-Listen auftauchen. Daurch, dass\n"
+"die Bridges der Oeffentlichkeit nicht bekannt ist, sind ISPs nicht dazu in\n"
+"der Lage, alle Tor Relays zu filtern."
 
-#: lib/bridgedb/I18n.py:63
+#: lib/bridgedb/I18n.py:28
 msgid ""
-"\n"
 "To use the above lines, go to Vidalia's Network settings page, and click\n"
 "\"My ISP blocks connections to the Tor network\". Then add each bridge\n"
-"address one at a time.\n"
+"address one at a time."
 msgstr ""
-"\n"
-"    Um die oben genannten Zeilen zu nutzen, sollten Sie in Vidalia's   "
-"    Network Settings gehen und den Menuepunkt \"Mein ISP blockt Verbindungen "
-"    zum Tor Netzwerk\" anklicken. Anschliessend koennen sie die Bridge-Adressen"
-"    hinzufuegen.\n"
+"Um die oben genannten Zeilen zu nutzen, sollten Sie in Vidalia's \"Network\n"
+"Settings\" gehen und den Menuepunkt \"Mein ISP blockt Verbindungen zum Tor\n"
+"Netzwerk\" anklicken. Anschliessend koennen sie die Bridge-Adressen\n"
+"hinzufuegen."
 
-#: lib/bridgedb/I18n.py:69
+
+#: lib/bridgedb/I18n.py:32
 msgid ""
-"\n"
 "Configuring more than one bridge address will make your Tor connection\n"
-"more stable, in case some of the bridges become unreachable.\n"
+"more stable, in case some of the bridges become unreachable."
+msgstr ""
+"Mehr als eine Brigde-Adresse zu verwenden fuehrt zu einer stabileren\n"
+"Verbindung. Es kann immer sein, dass mal eine Bridge kurzzeitig nicht\n"
+"erreichbar ist."
+
+#: lib/bridgedb/I18n.py:35
+msgid ""
+"Another way to find public bridge addresses is to send mail to\n"
+"bridges@xxxxxxxxxxxxxx with the line \"get bridges\" by itself in the body\n"
+"of the mail. However, so we can make it harder for an attacker to learn\n"
+"lots of bridge addresses, you must send this request from a gmail or\n"
+"yahoo account."
 msgstr ""
-"\n"
-"    Mehr als eine Brigde-Adresse zu verwenden fuehrt zu einer stabileren\n"
-"    Verbindung. Es kann immer sein, dass mal eine Bridge kurzzeitig nicht "
-"    erreichbar ist.\n"
+"Eine weitere Moeglichkeit Bridge-Adressen zu finden ist, eine Email\n"
+"an bridges@xxxxxxxxxxxxxx mit der Zeile \"get bridges\" zu Schreiben.\n"
+"Diesen Reqeuest muessen Sie allerdings von einem GMail oder Yahoo-Account"
+"schicken."
+
+#: lib/bridgedb/I18n.py:41
+msgid "[This is an automated message; please do not reply.]"
+msgstr "[Diese Mail wurde elektronisch erstellt; Bitte nicht antworten.]"
 
-#: lib/bridgedb/I18n.py:74
+#: lib/bridgedb/I18n.py:43
 msgid ""
-"\n"
 "Another way to find public bridge addresses is to visit\n"
 "https://bridges.torproject.org/. The answers you get from that page\n"
 "will change every few days, so check back periodically if you need more\n"
-"bridge addresses.\n"
+"bridge addresses."
 msgstr ""
-"\n"
-"Ein anderer Weg, neue Bridge-Adressen zu finden, ist folgende Web-Adresse zu"
-" besuchen:\n"
+"Eine andere Moeglichkeit neue Bridge-Adressen zu finden besteht darin,\n"
+"folgende Web-Adresse zu besuchen:\n"
 "https://bridges.torproject.org/. Sie koennen diese Adresse alle paar Tage\n"
-"besuchen, um neue Bridge-Adressen zu erhalten.\n"
+"besuchen, um neue Bridge-Adressen zu erhalten."
 
-#: lib/bridgedb/I18n.py:89
+#: lib/bridgedb/I18n.py:48
 msgid "(no bridges currently available)"
 msgstr "(Zur Zeit sind keine Bridges verfuegbar)"
diff --git a/i18n/en/bridgedb.po b/i18n/en/bridgedb.po
index 0604f29..339e3d5 100644
--- a/i18n/en/bridgedb.po
+++ b/i18n/en/bridgedb.po
@@ -1,114 +1,67 @@
 # SOME DESCRIPTIVE TITLE.
 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# Christian Fromme <kaner@xxxxxxxxxx>, 2010
 #
 #, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-08-14 13:28+0200\n"
+"POT-Creation-Date: 2010-09-29 14:25+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: lib/bridgedb/I18n.py:7
-msgid ""
-"\n"
-"    Here are your bridge relays:\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/I18n.py:11
-msgid ""
-"\n"
-"    Bridge relays (or \"bridges\" for short) are Tor relays that aren't "
-"listed\n"
-"    in the main directory. Since there is no complete public list of them,\n"
-"    even if your ISP is filtering connections to all the known Tor relays,\n"
-"    they probably won't be able to block all the bridges.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/I18n.py:18
-msgid ""
-"\n"
-"    To use the above lines, go to Vidalia's Network settings page, and "
-"click\n"
-"    \"My ISP blocks connections to the Tor network\". Then add each bridge\n"
-"    address one at a time.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/I18n.py:24
-msgid ""
-"\n"
-"    Configuring more than one bridge address will make your Tor connection\n"
-"    more stable, in case some of the bridges become unreachable.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/I18n.py:29
-msgid ""
-"\n"
-"    Another way to find public bridge addresses is to send mail to\n"
-"    bridges@xxxxxxxxxxxxxx with the line \"get bridges\" by itself in the "
-"body\n"
-"    of the mail. However, so we can make it harder for an attacker to learn\n"
-"    lots of bridge addresses, you must send this request from a gmail or\n"
-"    yahoo account.\n"
-"    "
+#: lib/bridgedb/I18n.py:21
+msgid "Here are your bridge relays: "
 msgstr ""
 
-#: lib/bridgedb/I18n.py:48
-msgid ""
-"\n"
-"[This is an automated message; please do not reply.]\n"
-msgstr ""
-
-#: lib/bridgedb/I18n.py:52
-msgid ""
-"\n"
-"Here are your bridge relays:\n"
-msgstr ""
-
-#: lib/bridgedb/I18n.py:56
+#: lib/bridgedb/I18n.py:23
 msgid ""
-"\n"
 "Bridge relays (or \"bridges\" for short) are Tor relays that aren't listed\n"
 "in the main directory. Since there is no complete public list of them,\n"
 "even if your ISP is filtering connections to all the known Tor relays,\n"
-"they probably won't be able to block all the bridges.\n"
+"they probably won't be able to block all the bridges."
 msgstr ""
 
-#: lib/bridgedb/I18n.py:63
+#: lib/bridgedb/I18n.py:28
 msgid ""
-"\n"
 "To use the above lines, go to Vidalia's Network settings page, and click\n"
 "\"My ISP blocks connections to the Tor network\". Then add each bridge\n"
-"address one at a time.\n"
+"address one at a time."
 msgstr ""
 
-#: lib/bridgedb/I18n.py:69
+#: lib/bridgedb/I18n.py:32
 msgid ""
-"\n"
 "Configuring more than one bridge address will make your Tor connection\n"
-"more stable, in case some of the bridges become unreachable.\n"
+"more stable, in case some of the bridges become unreachable."
 msgstr ""
 
-#: lib/bridgedb/I18n.py:74
+#: lib/bridgedb/I18n.py:35
+msgid ""
+"Another way to find public bridge addresses is to send mail to\n"
+"bridges@xxxxxxxxxxxxxx with the line \"get bridges\" by itself in the body\n"
+"of the mail. However, so we can make it harder for an attacker to learn\n"
+"lots of bridge addresses, you must send this request from a gmail or\n"
+"yahoo account."
+msgstr ""
+
+#: lib/bridgedb/I18n.py:41
+msgid "[This is an automated message; please do not reply.]"
+msgstr ""
+
+#: lib/bridgedb/I18n.py:43
 msgid ""
-"\n"
 "Another way to find public bridge addresses is to visit\n"
 "https://bridges.torproject.org/. The answers you get from that page\n"
 "will change every few days, so check back periodically if you need more\n"
-"bridge addresses.\n"
+"bridge addresses."
 msgstr ""
 
-#: lib/bridgedb/I18n.py:89
+#: lib/bridgedb/I18n.py:48
 msgid "(no bridges currently available)"
 msgstr ""
diff --git a/i18n/templates/bridgedb.pot b/i18n/templates/bridgedb.pot
index c88de86..339e3d5 100644
--- a/i18n/templates/bridgedb.pot
+++ b/i18n/templates/bridgedb.pot
@@ -1,114 +1,67 @@
 # SOME DESCRIPTIVE TITLE.
 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# Christian Fromme <kaner@xxxxxxxxxx>, 2010
 #
 #, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-08-14 13:28+0200\n"
+"POT-Creation-Date: 2010-09-29 14:25+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: lib/bridgedb/Strings.py:7
-msgid ""
-"\n"
-"    Here are your bridge relays:\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/Strings.py:11
-msgid ""
-"\n"
-"    Bridge relays (or \"bridges\" for short) are Tor relays that aren't "
-"listed\n"
-"    in the main directory. Since there is no complete public list of them,\n"
-"    even if your ISP is filtering connections to all the known Tor relays,\n"
-"    they probably won't be able to block all the bridges.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/Strings.py:18
-msgid ""
-"\n"
-"    To use the above lines, go to Vidalia's Network settings page, and "
-"click\n"
-"    \"My ISP blocks connections to the Tor network\". Then add each bridge\n"
-"    address one at a time.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/Strings.py:24
-msgid ""
-"\n"
-"    Configuring more than one bridge address will make your Tor connection\n"
-"    more stable, in case some of the bridges become unreachable.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/Strings.py:29
-msgid ""
-"\n"
-"    Another way to find public bridge addresses is to send mail to\n"
-"    bridges@xxxxxxxxxxxxxx with the line \"get bridges\" by itself in the "
-"body\n"
-"    of the mail. However, so we can make it harder for an attacker to learn\n"
-"    lots of bridge addresses, you must send this request from a gmail or\n"
-"    yahoo account.\n"
-"    "
-msgstr ""
-
-#: lib/bridgedb/Strings.py:48
-msgid ""
-"\n"
-"[This is an automated message; please do not reply.]\n"
-msgstr ""
-
-#: lib/bridgedb/Strings.py:52
-msgid ""
-"\n"
-"Here are your bridge relays:\n"
+#: lib/bridgedb/I18n.py:21
+msgid "Here are your bridge relays: "
 msgstr ""
 
-#: lib/bridgedb/Strings.py:56
+#: lib/bridgedb/I18n.py:23
 msgid ""
-"\n"
 "Bridge relays (or \"bridges\" for short) are Tor relays that aren't listed\n"
 "in the main directory. Since there is no complete public list of them,\n"
 "even if your ISP is filtering connections to all the known Tor relays,\n"
-"they probably won't be able to block all the bridges.\n"
+"they probably won't be able to block all the bridges."
 msgstr ""
 
-#: lib/bridgedb/Strings.py:63
+#: lib/bridgedb/I18n.py:28
 msgid ""
-"\n"
 "To use the above lines, go to Vidalia's Network settings page, and click\n"
 "\"My ISP blocks connections to the Tor network\". Then add each bridge\n"
-"address one at a time.\n"
+"address one at a time."
 msgstr ""
 
-#: lib/bridgedb/Strings.py:69
+#: lib/bridgedb/I18n.py:32
 msgid ""
-"\n"
 "Configuring more than one bridge address will make your Tor connection\n"
-"more stable, in case some of the bridges become unreachable.\n"
+"more stable, in case some of the bridges become unreachable."
+msgstr ""
+
+#: lib/bridgedb/I18n.py:35
+msgid ""
+"Another way to find public bridge addresses is to send mail to\n"
+"bridges@xxxxxxxxxxxxxx with the line \"get bridges\" by itself in the body\n"
+"of the mail. However, so we can make it harder for an attacker to learn\n"
+"lots of bridge addresses, you must send this request from a gmail or\n"
+"yahoo account."
+msgstr ""
+
+#: lib/bridgedb/I18n.py:41
+msgid "[This is an automated message; please do not reply.]"
 msgstr ""
 
-#: lib/bridgedb/Strings.py:74
+#: lib/bridgedb/I18n.py:43
 msgid ""
-"\n"
 "Another way to find public bridge addresses is to visit\n"
 "https://bridges.torproject.org/. The answers you get from that page\n"
 "will change every few days, so check back periodically if you need more\n"
-"bridge addresses.\n"
+"bridge addresses."
 msgstr ""
 
-#: lib/bridgedb/Strings.py:89
+#: lib/bridgedb/I18n.py:48
 msgid "(no bridges currently available)"
 msgstr ""
diff --git a/lib/bridgedb/I18n.py b/lib/bridgedb/I18n.py
index 928f4cc..44565b6 100644
--- a/lib/bridgedb/I18n.py
+++ b/lib/bridgedb/I18n.py
@@ -2,13 +2,11 @@
 
 import gettext
 
-languages = {}
-
-def setupLanguages(cfg):
-    """Set up all languages we support
+def getLang(lang):
+    """Return the Translation instance for a given language. If no Translation
+       instance is found, return the one for 'en'
     """
-    for lang in cfg.CONFIGURED_LOCALES:
-        languages[lang] = gettext.translation("bridgedb", languages=[lang])
+    return gettext.translation("bridgedb", languages=[lang], fallback="en")
 
 def _(text):
     """This is necessary because strings are translated when they're imported.
@@ -19,57 +17,33 @@ def _(text):
 
 # All text that needs translation goes here
 BRIDGEDB_TEXT = [
-        _("""
-    Here are your bridge relays:
-    """),
-        _("""
-    Bridge relays (or "bridges" for short) are Tor relays that aren't listed
-    in the main directory. Since there is no complete public list of them,
-    even if your ISP is filtering connections to all the known Tor relays,
-    they probably won't be able to block all the bridges.
-    """),
-        _("""
-    To use the above lines, go to Vidalia's Network settings page, and click
-    "My ISP blocks connections to the Tor network". Then add each bridge
-    address one at a time.
-    """),
-        _("""
-    Configuring more than one bridge address will make your Tor connection
-    more stable, in case some of the bridges become unreachable.
-    """),
-        _("""
-    Another way to find public bridge addresses is to send mail to
-    bridges@xxxxxxxxxxxxxx with the line "get bridges" by itself in the body
-    of the mail. However, so we can make it harder for an attacker to learn
-    lots of bridge addresses, you must send this request from a gmail or
-    yahoo account.
-    """),
-        _("""
-[This is an automated message; please do not reply.]
-    """),
-        _("""
-Here are your bridge relays:
-    """),
-        _("""
-Bridge relays (or "bridges" for short) are Tor relays that aren't listed
+ # BRIDGEDB_TEXT[0]
+ _("""Here are your bridge relays: """),
+ # BRIDGEDB_TEXT[1]
+ _("""Bridge relays (or "bridges" for short) are Tor relays that aren't listed
 in the main directory. Since there is no complete public list of them,
 even if your ISP is filtering connections to all the known Tor relays,
-they probably won't be able to block all the bridges.
-    """),
-        _("""
-To use the above lines, go to Vidalia's Network settings page, and click
+they probably won't be able to block all the bridges."""),
+ # BRIDGEDB_TEXT[2]
+ _("""To use the above lines, go to Vidalia's Network settings page, and click
 "My ISP blocks connections to the Tor network". Then add each bridge
-address one at a time.
-    """),
-        _("""
-Configuring more than one bridge address will make your Tor connection
-more stable, in case some of the bridges become unreachable.
-    """),
-        _("""
-Another way to find public bridge addresses is to visit
+address one at a time."""),
+ # BRIDGEDB_TEXT[3]
+ _("""Configuring more than one bridge address will make your Tor connection
+more stable, in case some of the bridges become unreachable."""),
+ # BRIDGEDB_TEXT[4]
+ _("""Another way to find public bridge addresses is to send mail to
+bridges@xxxxxxxxxxxxxx with the line "get bridges" by itself in the body
+of the mail. However, so we can make it harder for an attacker to learn
+lots of bridge addresses, you must send this request from a gmail or
+yahoo account."""),
+ # BRIDGEDB_TEXT[5]
+ _("""[This is an automated message; please do not reply.]"""),
+ # BRIDGEDB_TEXT[6]
+ _("""Another way to find public bridge addresses is to visit
 https://bridges.torproject.org/. The answers you get from that page
 will change every few days, so check back periodically if you need more
-bridge addresses.
-    """),
-        _("(no bridges currently available)")
+bridge addresses."""),
+ # BRIDGEDB_TEXT[7]
+ _("""(no bridges currently available)""")
 ]
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index eebd55c..0f192ae 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -19,7 +19,6 @@ import bridgedb.Dist as Dist
 import bridgedb.Time as Time
 import bridgedb.Server as Server
 import bridgedb.Storage
-import bridgedb.I18n as I18n
 
 class Conf:
     """A configuration object.  Holds unvalidated attributes.
@@ -90,8 +89,6 @@ CONFIG = Conf(
     EMAIL_INCLUDE_FINGERPRINTS = False,
 
     RESERVED_SHARE=2,
-
-    CONFIGURED_LOCALES = [ "en", "de" ]
   )
 
 def configureLogging(cfg):
@@ -228,9 +225,6 @@ def startup(cfg):
                                    cfg.DB_FILE)
     bridgedb.Storage.setGlobalDB(db)
 
-    # Setup languages
-    I18n.setupLanguages(cfg)
-
     # Get a proxy list.
     proxyList = ProxyCategory()
     proxyList.replaceProxyList(loadProxyList(cfg))
diff --git a/lib/bridgedb/Server.py b/lib/bridgedb/Server.py
index cd1d760..10a3ae4 100644
--- a/lib/bridgedb/Server.py
+++ b/lib/bridgedb/Server.py
@@ -12,6 +12,7 @@ import rfc822
 import time
 import logging
 import gettext
+import re
 
 from zope.interface import implements
 
@@ -60,10 +61,15 @@ class WebResource(twisted.web.resource.Resource):
             ip = request.getClientIP()
 
         # See if we did get a request for a certain locale, otherwise fall back
-        # to 'en'
-        lang = request.args.get("lang", ['en'])
-        lang = lang[0]
-        I18n.languages[lang].install()
+        # to 'en':
+        # Try evaluating the path /foo first, then check if we got a ?lang=foo
+        default_lang = lang = "en"
+        if len(request.path) > 1:
+            lang = request.path[1:]
+        if lang == default_lang:
+            lang = request.args.get("lang", [default_lang])
+            lang = lang[0]
+        t = I18n.getLang(lang)
 
         format = request.args.get("format", None)
         if format and len(format): format = format[0] # choose the first arg
@@ -75,7 +81,7 @@ class WebResource(twisted.web.resource.Resource):
             answer = "".join("%s\n" % b.getConfigLine(self.includeFingerprints)
                              for b in bridges)
         else:
-            answer = _(I18n.BRIDGEDB_TEXT[-1])
+            answer = t.gettext(I18n.BRIDGEDB_TEXT[-1])
 
         logging.info("Replying to web request from %s.  Parameters were %r", ip,
                      request.args)
@@ -83,19 +89,20 @@ class WebResource(twisted.web.resource.Resource):
             request.setHeader("Content-Type", "text/plain")
             return answer
         else:
-            HTML_MESSAGE_TEMPLATE = self.buildHTMLMessageTemplate()
+            HTML_MESSAGE_TEMPLATE = self.buildHTMLMessageTemplate(t)
             return HTML_MESSAGE_TEMPLATE % answer
 
-    def buildHTMLMessageTemplate(self):
+    def buildHTMLMessageTemplate(self, t):
         """DOCDOC"""
         html_msg = "<html><body>" \
-                   + "<p>" + _(I18n.BRIDGEDB_TEXT[1]) \
+                   + "<p>" + t.gettext(I18n.BRIDGEDB_TEXT[0]) \
                    + "<pre id=\"bridges\">" \
                    + "%s" \
                    + "</pre></p>" \
-                   + "<p>" + _(I18n.BRIDGEDB_TEXT[2]) + "</p>" \
-                   + "<p>" + _(I18n.BRIDGEDB_TEXT[3]) + "</p>" \
-                   + "<p>" + _(I18n.BRIDGEDB_TEXT[4]) + "</p>" \
+                   + "<p>" + t.gettext(I18n.BRIDGEDB_TEXT[1]) + "</p>" \
+                   + "<p>" + t.gettext(I18n.BRIDGEDB_TEXT[2]) + "</p>" \
+                   + "<p>" + t.gettext(I18n.BRIDGEDB_TEXT[3]) + "</p>" \
+                   + "<p>" + t.gettext(I18n.BRIDGEDB_TEXT[4]) + "</p>" \
                    + "</body></html>"
 
         return html_msg
@@ -150,6 +157,23 @@ class MailFile:
         except IndexError:
             return ""
 
+def getBridgeDBEmailAddrFromList(ctx, address_list):
+    """Loop through a list of (full name, email address) pairs and look up our
+       mail address. If our address isn't found (which can't happen), return
+       the default ctx from address so we can keep on working.
+    """
+    email = ctx.fromAddr
+    for _, address in address_list:
+        # Strip the @torproject.org part from the address
+        idx = address.find('@')
+        if idx != -1:
+            username = address[:idx]
+            # See if the user looks familiar. We do a 'find' instead
+            # of compare because we might have a '+' address here
+            if username.find(ctx.username) != -1:
+                email = address
+    return email
+
 def getMailResponse(lines, ctx):
     """Given a list of lines from an incoming email message, and a
        MailContext object, parse the email and decide what to do in response.
@@ -163,7 +187,9 @@ def getMailResponse(lines, ctx):
     if not subject: subject = "[no subject]"
     clientFromAddr = msg.getaddr("From")
     clientSenderAddr = msg.getaddr("Sender")
-    clientToaddr = msg.getaddr("To")
+    # RFC822 requires at least one 'To' address
+    clientToList = msg.getaddrlist("To")
+    clientToaddr = getBridgeDBEmailAddrFromList(ctx, clientToList)
     msgID = msg.getheader("Message-ID", None)
     if clientSenderAddr and clientSenderAddr[1]:
         clientAddr = clientSenderAddr[1]
@@ -173,10 +199,10 @@ def getMailResponse(lines, ctx):
         logging.info("No From or Sender header on incoming mail.")
         return None,None
 
-    # Look up the locale part in the 'To:' address, if there is one and install
-    # it
+    # Look up the locale part in the 'To:' address, if there is one and get
+    # the appropriate Translation object
     lang = getLocaleFromPlusAddr(clientToaddr)
-    I18n.languages[lang].install()
+    t = I18n.getLang(lang)
 
     try:
         _, addrdomain = bridgedb.Dist.extractAddrSpec(clientAddr.lower())
@@ -240,15 +266,24 @@ def getMailResponse(lines, ctx):
     else:
         answer = "(no bridges currently available)"
 
-    EMAIL_MESSAGE_TEMPLATE = "".join("%s\n" % _(I18n.BRIDGEDB_TEXT[5:2])) \
-                             + "%s" \
-                             + "".join("%s\n" % _(I18n.BRIDGEDB_TEXT[7:4]))
+    EMAIL_MESSAGE_TEMPLATE = buildMessageTemplate(t)
     body.write(EMAIL_MESSAGE_TEMPLATE % answer)
 
     f.seek(0)
     logging.info("Email looks good; we should send an answer.")
     return clientAddr, f
 
+def buildMessageTemplate(t):
+    msg_template =  t.gettext(I18n.BRIDGEDB_TEXT[5]) + "\n\n" \
+                    + t.gettext(I18n.BRIDGEDB_TEXT[0]) + "\n\n" \
+                    + "%s\n" \
+                    + t.gettext(I18n.BRIDGEDB_TEXT[1]) + "\n\n" \
+                    + t.gettext(I18n.BRIDGEDB_TEXT[2]) + "\n\n" \
+                    + t.gettext(I18n.BRIDGEDB_TEXT[3]) + "\n\n" \
+                    + t.gettext(I18n.BRIDGEDB_TEXT[6]) + "\n\n"
+
+    return msg_template
+
 def replyToMail(lines, ctx):
     """Given a list of lines from an incoming email message, and a
        MailContext object, possibly send a reply.
@@ -269,7 +304,7 @@ def replyToMail(lines, ctx):
     logging.info("Sending reply to %r", sendToUser)
     return d
 
-def getLocaleFromPlusAddr(self, address):
+def getLocaleFromPlusAddr(address):
     """See whether the user sent his email to a 'plus' address, for 
        instance to bridgedb+fa@tpo. Plus addresses are the current 
        mechanism to set the reply language
@@ -350,7 +385,16 @@ class MailDelivery:
     def validateFrom(self, helo, origin):
         return origin
     def validateTo(self, user):
-        if user.dest.local != self.ctx.username:
+        """If the local user that was addressed isn't our configured local 
+           user or doesn't contain a '+' with a prefix matching the local
+           configured user: Yell
+        """
+        u = user.dest.local
+        # Hasplus? If yes, strip '+foo'
+        idx = u.find('+')
+        if idx != -1:
+            u = u[:idx]
+        if u != self.ctx.username:
             raise twisted.mail.smtp.SMTPBadRcpt(user)
         return lambda: MailMessage(self.ctx)
 
-- 
1.7.1