[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Kill bridgedb.I18n and add new bridgedb.strings module.
commit 242409d57460d6ab47c4443c1741bc6cd282bfac
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Fri May 2 16:55:28 2014 +0000
Kill bridgedb.I18n and add new bridgedb.strings module.
This new module holds translated strings which are used in several places in
the code, in order to save our helpful translators from having to translate
the same boring string over and over again.
This has been redesigned to permit these strings to be formatted for both the
email and HTTPS distributors.
---
README | 2 +-
doc/sphinx/source/bridgedb.I18n.rst | 8 --
doc/sphinx/source/bridgedb.rst | 2 +-
doc/sphinx/source/bridgedb.strings.rst | 8 ++
doc/sphinx/source/conf.py | 2 +-
lib/bridgedb/HTTPServer.py | 2 +-
lib/bridgedb/I18n.py | 88 ---------------
lib/bridgedb/strings.py | 182 ++++++++++++++++++++++++++++++++
8 files changed, 194 insertions(+), 100 deletions(-)
diff --git a/README b/README
index 4724594..c5adf54 100644
--- a/README
+++ b/README
@@ -124,7 +124,7 @@ all the updated files in their correct locations.
**Requesting Translations for Altered/Added Source Code**: This should be done
whenever any of the strings requiring translation -- _("they are formatted
like this") -- are changed, or new ones are added.
- See ```lib/bridgedb/I18n.py```.
+ See ```lib/bridgedb/strings.py```.
Translations for Tor Project repos are kept
[in a separate repo](https://gitweb.torproject.org/translation.git). You'll
diff --git a/doc/sphinx/source/bridgedb.I18n.rst b/doc/sphinx/source/bridgedb.I18n.rst
deleted file mode 100644
index cd1274f..0000000
--- a/doc/sphinx/source/bridgedb.I18n.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-bridgedb.I18n
--------------
-
-.. automodule:: bridgedb.I18n
- :members:
- :undoc-members:
- :private-members:
- :show-inheritance:
diff --git a/doc/sphinx/source/bridgedb.rst b/doc/sphinx/source/bridgedb.rst
index 3c768cc..aa775f9 100644
--- a/doc/sphinx/source/bridgedb.rst
+++ b/doc/sphinx/source/bridgedb.rst
@@ -14,7 +14,6 @@ BridgeDB Package and Module Documentation
bridgedb.EmailServer
bridgedb.Filters
bridgedb.HTTPServer
- bridgedb.I18n
bridgedb.Main
bridgedb.parse
bridgedb.persistent
@@ -22,6 +21,7 @@ BridgeDB Package and Module Documentation
bridgedb.safelog
bridgedb.Stability
bridgedb.Storage
+ bridgedb.strings
bridgedb.Tests
bridgedb.txrecaptcha
bridgedb.util
diff --git a/doc/sphinx/source/bridgedb.strings.rst b/doc/sphinx/source/bridgedb.strings.rst
new file mode 100644
index 0000000..114931b
--- /dev/null
+++ b/doc/sphinx/source/bridgedb.strings.rst
@@ -0,0 +1,8 @@
+bridgedb.strings
+----------------
+
+.. automodule:: bridgedb.strings
+ :members:
+ :undoc-members:
+ :private-members:
+ :show-inheritance:
diff --git a/doc/sphinx/source/conf.py b/doc/sphinx/source/conf.py
index 0a71d87..977032f 100644
--- a/doc/sphinx/source/conf.py
+++ b/doc/sphinx/source/conf.py
@@ -35,13 +35,13 @@ import bridgedb.Dist
import bridgedb.EmailServer
import bridgedb.Filters
import bridgedb.HTTPServer
-import bridgedb.I18n
import bridgedb.Main
import bridgedb.persistent
import bridgedb.runner
import bridgedb.safelog
import bridgedb.Stability
import bridgedb.Storage
+import bridgedb.strings
import bridgedb.test
import bridgedb.Tests
import bridgedb.txrecaptcha
diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index c28dee0..cf8a83a 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -31,10 +31,10 @@ from twisted.web import static
from twisted.web.util import redirectTo
import bridgedb.Dist
-import bridgedb.I18n as I18n
from bridgedb import captcha
from bridgedb import crypto
+from bridgedb import strings
from bridgedb import translations
from bridgedb import txrecaptcha
from bridgedb.Filters import filterBridgesByIP4
diff --git a/lib/bridgedb/I18n.py b/lib/bridgedb/I18n.py
deleted file mode 100644
index c6fbf3f..0000000
--- a/lib/bridgedb/I18n.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# BridgeDB i18n strings & helper routines. The string should go into pootle
-
-import os
-import gettext
-
-def getLang(lang, localedir=os.path.expanduser("~") + "/share/locale"):
- """Return the Translation instance for a given language. If no Translation
- instance is found, return the one for 'en'
- """
- return gettext.translation("bridgedb", localedir=localedir,
- languages=[lang], fallback="en")
-
-def _(text):
- """This is necessary because strings are translated when they're imported.
- Otherwise this would make it impossible to switch languages more than
- once.
-
- :returns: The **text**.
- """
- return text
-
-# All text that needs translation goes here
-BRIDGEDB_TEXT = [
- # 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."""),
- # 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."""),
- # 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 an email address at
-one of the following domains:"""),
- # 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."""),
- # BRIDGEDB_TEXT[7]
- _("""(no bridges currently available)"""),
- # BRIDGEDB_TEXT[8]
- _("""(e-mail requests not currently supported)"""),
- # BRIDGEDB_TEXT[9]
- _("""To receive your bridge relays, please prove you are human"""),
- # BRIDGEDB_TEXT[10]
- _("""You have exceeded the rate limit. Please slow down, the minimum time
-between emails is: """),
- # BRIDGEDB_TEXT[11]
- _("""hours"""),
- # BRIDGEDB_TEXT[12]
- _("""All further emails will be ignored."""),
- # BRIDGEDB_TEXT[13]
- _("""Type the two words"""),
- # BRIDGEDB_TEXT[14]
- _("""I am human"""),
- # BRIDGEDB_TEXT[15]
- _("""Upgrade your browser to Firefox"""),
- # BRIDGEDB_TEXT[16]
- _("""(Might be blocked)"""),
- # BRIDGEDB_TEXT[17]
- _("""The following commands are also supported:"""),
- # BRIDGEDB_TEXT[18]
- _("""ipv6 : request ipv6 bridges."""),
- # BRIDGEDB_TEXT[19]
- _("""transport NAME : request transport NAME. Example: 'transport obfs2'"""),
- # BRIDGEDB_TEXT[20]
- _("""Looking for IPv6 bridges?"""),
- # BRIDGEDB_TEXT[21]
- _("""Looking for obfsproxy bridges?"""),
- # BRIDGEDB_TEXT[22]
- _("""Specify transport by name:"""),
- # BRIDGEDB_TEXT[23]
- _("""Submit"""),
- # BRIDGEDB_TEXT[24]
- _("""days at this address""")
-]
diff --git a/lib/bridgedb/strings.py b/lib/bridgedb/strings.py
new file mode 100644
index 0000000..0157ecb
--- /dev/null
+++ b/lib/bridgedb/strings.py
@@ -0,0 +1,182 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+
+
+def _(text):
+ """This is necessary because strings are translated when they're imported.
+ Otherwise this would make it impossible to switch languages more than
+ once.
+
+ :returns: The **text**.
+ """
+ return text
+
+
+# TRANSLATORS: Please do not translate the word "TYPE".
+EMAIL_MISC_TEXT = {
+ 0: _("""\
+[This is an automated message; please do not reply.]"""),
+ 1: _("""\
+Here are your bridges:"""),
+ 2: _("""\
+You have exceeded the rate limit. Please slow down! The minimum time between
+emails is %s hours. All further emails during this time period will be ignored."""),
+ 3: _("""\
+COMMANDs: (combine COMMANDs to specify multiple options simultaneously)"""),
+ 4: _("Welcome to BridgeDB!"),
+ # TRANLATORS: Please DO NOT tranlate the words "transport" or "TYPE".
+ 5: _("Currently supported tranport TYPEs:"),
+}
+
+WELCOME = {
+ 0: _("""\
+BridgeDB can provide bridges with several %stypes of Pluggable Transports%s,
+which can help obfuscate your connections to the Tor Network, making it more
+difficult for anyone watching your internet traffic to determine that you are
+using Tor.\n\n"""),
+
+ 1: _("""\
+Some bridges with IPv6 addresses are also available, though some Pluggable
+Transports aren't IPv6 compatible.\n\n"""),
+
+ 2: _("""\
+Additionally, BridgeDB has plenty of plain-ol'-vanilla bridges %s without any
+Pluggable Transports %s which maybe doesn't sound as cool, but they can still
+help to circumvent internet censorship in many cases.\n\n"""),
+}
+"""These strings should go on the first "Welcome" email sent by the
+:mod:`~bridgedb.EmailServer`, as well as on the ``index.html`` template used
+by the :mod:`~bridgedb.HTTPServer`. They are used as an introduction to
+explain what Tor bridges are, what bridges do, and why someone might want to
+use bridges.
+"""
+
+FAQ = {
+ 0: _("What are bridges?"),
+ 1: _("""\
+%s Bridges %s are Tor relays that help you circumvent censorship."""),
+}
+
+OTHER_DISTRIBUTORS = {
+ 0: _("I need an alternative way of getting bridges!"),
+ 1: _("""\
+Another way to get bridges is to send an email to %s. Please note that you must
+send the email using an address from one of the following email providers:
+%s or %s."""),
+}
+
+HELP = {
+ 0: _("My bridges don't work! I need help!"),
+ 1: _("""If your Tor doesn't work, you should email %s."""),
+ 2: _("""\
+Try including as much info about your case as you can, including the list of
+bridges and Pluggable Transports you tried to use, your Tor Browser version,
+and any messages which Tor gave out, etc."""),
+}
+
+BRIDGES = {
+ 0: _("Bridges"),
+ 1: _("Get Bridges!"),
+}
+
+OPTIONS = {
+ 0: _("Please select options for bridge type:"),
+ 1: _("Do you need IPv6 addresses?"),
+ 2: _("Do you need a %s?"),
+}
+
+CAPTCHA = {
+ 0: _('Your browser is not displaying images properly.'),
+ 1: _('Enter the characters from the image above...'),
+}
+
+HOWTO_TBB = {
+ 0: _("""How to start using your bridges"""),
+ 1: _("""\
+To enter bridges into Tor Browser, follow the instructions on the %s Tor
+Browser download page %s to start Tor Browser."""),
+ 2: _("""\
+When the 'Tor Network Settings' dialogue pops up, click 'Configure' and follow
+the wizard until it asks:"""),
+ 3: _("""\
+Does your Internet Service Provider (ISP) block or otherwise censor connections
+to the Tor network?"""),
+ 4: _("""\
+Select 'Yes' and then click 'Next'. To configure your new bridges, copy and
+paste the bridge lines (shown above) into the text input box. Finally, click
+'Connect', and you should be good to go! If you experience trouble, try
+clicking the 'Help' button in the 'Tor Network Settings' wizard for further
+assistance."""),
+}
+
+EMAIL_COMMANDS = {
+ "get help": _("Displays this message."),
+ "get bridges": _("Request vanilla bridges."),
+ "get ipv6": _("Request IPv6 bridges."),
+ # TRANLATORS: Please DO NOT tranlate the word the word "TYPE".
+ "get transport [TYPE]": _("Request a Pluggable Transport by TYPE."),
+ #"subscribe": _("Subscribe to receive new bridges once per week")
+ #"unsubscribe": _("Cancel a subscription to new bridges")
+}
+
+#-----------------------------------------------------------------------------
+# All of the following containers are untranslated!
+#-----------------------------------------------------------------------------
+
+#: A list of all currently available pluggable transports. By "currently
+#: available" we mean:
+#:
+#: 1. The PT is in a widely accepted, usable state for most Tor users.
+#: 2. The PT is currently publicly deployed *en masse*".
+#:
+CURRENT_TRANSPORTS = [
+ "obfs2",
+ "obfs3",
+ "scramblesuit",
+]
+
+EMAIL_SPRINTF = {
+ # Goes into the "%s types of Pluggable Transports %s" part of ``WELCOME[0]``
+ "WELCOME0": ("", "[0]"),
+ # Goes into the "%s without Pluggable Transport %s" part of ``WELCOME[2]``
+ "WELCOME2": ("-", "-"),
+ # For the "%s Tor Browser download page %s" part of ``HOWTO_TBB[1]``
+ "HOWTO_TBB1": ("", "[0]"),
+ # For the "you should email %s" in ``HELP[0]``
+ "HELP0": ("help@xxxxxxxxxxxxxxxxx"),
+}
+"""``EMAIL_SPRINTF`` is a dictionary that maps translated strings which
+contain format specifiers (i.e. ``%s``) to what those format specifiers should
+be replaced with in a given template system.
+
+For example, a string which needs a pair of HTML ``("<a href=''">, "</a>")``
+tags (for the templates used by :mod:`bridgedb.HTTPServer`) would need some
+alternative replacements for the :mod:`EmailServer`, because the latter uses
+templates with a ``text/plain`` mimetype instead of HTML. For the
+``EmailServer``, the format strings specifiers are replaced with an empty
+string where the opening ``<a>`` tags would go, and a numbered Markdown link
+specifier where the closing ``</a>`` tags would go.
+
+The keys in this dictionary are the Python variable names of the corresponding
+strings which are being formatted, i.e. ``WELCOME0`` would be the string
+replacements for ``strings.WELCOME.get(0)``.
+
+
+For example, the ``0`` string in :data:`WELCOME` above has the substring::
+
+ "%s without Pluggable Transport %s"
+
+and so to replace the two ``%s`` format specifiers, you would use this mapping
+like so::
+
+>>> from bridgedb import strings
+>>> welcome = strings.WELCOME.get(0)
+>>> emailWelcome = welcome.format(strings.EMAIL_SPRINTF.get("WELCOME0"))
+>>> emailWelcome
+"""
+
+EMAIL_REFERENCE_LINKS = {
+ "WELCOME0": "[0]: https://www.torproject.org/docs/pluggable-transports.html",
+ "HOWTO_TBB1": "[0]: https://www.torproject.org/projects/torbrowser.html.en#downloads-beta",
+}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits