From d006b87ee23a27f3f03491ec85c4c518c18cf6d3 Mon Sep 17 00:00:00 2001 From: Christian Fromme Date: Mon, 27 Sep 2010 21:47:24 +0200 Subject: [PATCH] Moved indexed variables to a list as Nickm suggested --- lib/bridgedb/I18n.py | 60 ++++++++++++++++++++++---------------------------- lib/bridgedb/Server.py | 33 ++++++++++++--------------- 2 files changed, 40 insertions(+), 53 deletions(-) diff --git a/lib/bridgedb/I18n.py b/lib/bridgedb/I18n.py index 4999b5b..928f4cc 100644 --- a/lib/bridgedb/I18n.py +++ b/lib/bridgedb/I18n.py @@ -17,67 +17,59 @@ def _(text): """ return text -HTML_1 = _(""" +# All text that needs translation goes here +BRIDGEDB_TEXT = [ + _(""" Here are your bridge relays: - """) - -HTML_2 = _(""" + """), + _(""" 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. - """) - -HTML_3 = _(""" + """), + _(""" 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. - """) - -HTML_4 = _(""" + """), + _(""" Configuring more than one bridge address will make your Tor connection more stable, in case some of the bridges become unreachable. - """) - -HTML_5 = _(""" + """), + _(""" Another way to find public bridge addresses is to send mail to bridges@torproject.org 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. - """) - -EMAIL_1 = _(""" + """), + _(""" [This is an automated message; please do not reply.] -""") - -EMAIL_2 = _(""" + """), + _(""" Here are your bridge relays: -""") - -EMAIL_3 = _(""" + """), + _(""" 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. -""") - -EMAIL_4 = _(""" + """), + _(""" 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. -""") - -EMAIL_5 = _(""" + """), + _(""" Configuring more than one bridge address will make your Tor connection more stable, in case some of the bridges become unreachable. -""") - -EMAIL_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 = _("(no bridges currently available)") + """), + _("(no bridges currently available)") +] diff --git a/lib/bridgedb/Server.py b/lib/bridgedb/Server.py index dd5066d..cd1d760 100644 --- a/lib/bridgedb/Server.py +++ b/lib/bridgedb/Server.py @@ -75,7 +75,7 @@ class WebResource(twisted.web.resource.Resource): answer = "".join("%s\n" % b.getConfigLine(self.includeFingerprints) for b in bridges) else: - answer = _(I18n.NO_BRIDGES) + answer = _(I18n.BRIDGEDB_TEXT[-1]) logging.info("Replying to web request from %s. Parameters were %r", ip, request.args) @@ -88,18 +88,17 @@ class WebResource(twisted.web.resource.Resource): def buildHTMLMessageTemplate(self): """DOCDOC""" - template_string = "" \ - + "

" + _(I18n.HTML_1) \ - + "

" \
-                             + "%s" \
-                             + "

" \ - + "

" + _(I18n.HTML_2) + "

" \ - + "

" + _(I18n.HTML_3) + "

" \ - + "

" + _(I18n.HTML_4) + "

" \ - + "

" + _(I18n.HTML_5) + "

" \ - + "" + html_msg = "" \ + + "

" + _(I18n.BRIDGEDB_TEXT[1]) \ + + "

" \
+                   + "%s" \
+                   + "

" \ + + "

" + _(I18n.BRIDGEDB_TEXT[2]) + "

" \ + + "

" + _(I18n.BRIDGEDB_TEXT[3]) + "

" \ + + "

" + _(I18n.BRIDGEDB_TEXT[4]) + "

" \ + + "" - return template_string + return html_msg def addWebServer(cfg, dist, sched): @@ -241,14 +240,10 @@ def getMailResponse(lines, ctx): else: answer = "(no bridges currently available)" - EMAIL_MESSAGE_TEMPLATE = _(EMAIL_1) \ - + _(EMAIL_2) \ + EMAIL_MESSAGE_TEMPLATE = "".join("%s\n" % _(I18n.BRIDGEDB_TEXT[5:2])) \ + "%s" \ - + _(EMAIL_3) \ - + _(EMAIL_4) \ - + _(EMAIL_5) \ - + _(EMAIL_6) - body.write(_(EMAIL_MESSAGE_TEMPLATE) % answer) + + "".join("%s\n" % _(I18n.BRIDGEDB_TEXT[7:4])) + body.write(EMAIL_MESSAGE_TEMPLATE % answer) f.seek(0) logging.info("Email looks good; we should send an answer.") -- 2.11.4.GIT