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

[tor-commits] [bridgedb/master] Localize templates and configure babel



commit 40746a46c798c10b08f7962766ba957cd7c88510
Author: aagbsn <aagbsn@xxxxxxxx>
Date:   Tue Mar 26 19:16:13 2013 +0000

    Localize templates and configure babel
    
    * Add gettext localization for template strings.
    * Add message_extractors to setup.py
    * Add babel command arguments to setup.cfg
    * Remove I18n.py
---
 i18n/templates/bridgedb.pot         |  111 +++++++++++++++++++++-------------
 lib/bridgedb/I18n.py                |   86 ---------------------------
 lib/bridgedb/templates/base.html    |   39 +++++++------
 lib/bridgedb/templates/bridges.html |    5 +-
 lib/bridgedb/templates/captcha.html |   13 ++---
 lib/bridgedb/templates/index.html   |   26 ++++----
 setup.cfg                           |   22 +++++++
 setup.py                            |    8 +-
 8 files changed, 135 insertions(+), 175 deletions(-)

diff --git a/i18n/templates/bridgedb.pot b/i18n/templates/bridgedb.pot
index 34d0510..ab95177 100644
--- a/i18n/templates/bridgedb.pot
+++ b/i18n/templates/bridgedb.pot
@@ -1,73 +1,98 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# Christian Fromme <kaner@xxxxxxxxxx>, 2010
+# Translations template for BridgeDB.
+# Copyright (C) 2013 ORGANIZATION
+# This file is distributed under the same license as the BridgeDB project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
 #
 #, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-01-01 07:48-0800\n"
+"Project-Id-Version: BridgeDB 0.1\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2013-03-27 21:41+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
-"Language: \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"
+"Generated-By: Babel 0.9.6\n"
 
-#: lib/bridgedb/I18n.py:21
-msgid "Here are your bridge relays: "
+#: lib/bridgedb/templates/base.html:33
+msgid "What are bridges?"
 msgstr ""
 
-#: lib/bridgedb/I18n.py:23
-msgid ""
-"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."
+#: lib/bridgedb/templates/base.html:34
+#, python-format
+msgid "%s Bridge relays %s are Tor relays that help you circumvent censorship."
+msgstr ""
+
+#: lib/bridgedb/templates/base.html:39
+msgid "I need an alternative way of getting bridges!"
 msgstr ""
 
-#: lib/bridgedb/I18n.py:28
+#: lib/bridgedb/templates/base.html:40
+#, python-format
 msgid ""
-"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."
+"Another way to find public bridge addresses is to send an email (from a %s or"
+" a %s address) to %s with the line 'get bridges' by itself in the body of the"
+" mail."
+msgstr ""
+
+#: lib/bridgedb/templates/base.html:48
+msgid "My bridges don't work! I need help!"
 msgstr ""
 
-#: lib/bridgedb/I18n.py:32
+#: lib/bridgedb/templates/base.html:49
+#, python-format
 msgid ""
-"Configuring more than one bridge address will make your Tor connection\n"
-"more stable, in case some of the bridges become unreachable."
+"If your Tor doesn't work, you should email %s. Try including as much info "
+"about your case as you can, including the list of bridges you used, the "
+"bundle filename/version you used, the messages that Tor gave out, etc."
 msgstr ""
 
-#: lib/bridgedb/I18n.py:35
+#: lib/bridgedb/templates/bridges.html:10
 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 an email address "
-"at\n"
-"one of the following domains:"
+"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."
 msgstr ""
 
-#: lib/bridgedb/I18n.py:41
-msgid "[This is an automated message; please do not reply.]"
+#: lib/bridgedb/templates/bridges.html:13
+msgid "No bridges currently available"
 msgstr ""
 
-#: lib/bridgedb/I18n.py:43
-msgid ""
-"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."
+#: lib/bridgedb/templates/captcha.html:6
+msgid "Upgrade your browser to Firefox"
+msgstr ""
+
+#: lib/bridgedb/templates/captcha.html:8
+msgid "Type the two words"
 msgstr ""
 
-#: lib/bridgedb/I18n.py:48
-msgid "(no bridges currently available)"
+#: lib/bridgedb/templates/index.html:6
+msgid "Step 1"
 msgstr ""
 
-#: lib/bridgedb/I18n.py:50
-msgid "(e-mail requests not currently supported)"
+#: lib/bridgedb/templates/index.html:8
+#, python-format
+msgid "Get %s Tor Browser Bundle %s"
 msgstr ""
+
+#: lib/bridgedb/templates/index.html:13
+msgid "Step 2"
+msgstr ""
+
+#: lib/bridgedb/templates/index.html:15
+#, python-format
+msgid "Get %s bridges %s"
+msgstr ""
+
+#: lib/bridgedb/templates/index.html:19
+msgid "Step 3"
+msgstr ""
+
+#: lib/bridgedb/templates/index.html:21
+#, python-format
+msgid "Now %s add the bridges to Tor %s"
+msgstr ""
+
diff --git a/lib/bridgedb/I18n.py b/lib/bridgedb/I18n.py
deleted file mode 100644
index 112b8ae..0000000
--- a/lib/bridgedb/I18n.py
+++ /dev/null
@@ -1,86 +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
-    """
-    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/templates/base.html b/lib/bridgedb/templates/base.html
index affff60..adbc81c 100644
--- a/lib/bridgedb/templates/base.html
+++ b/lib/bridgedb/templates/base.html
@@ -30,25 +30,28 @@ ${self.body()}
 <div class="faq">
   <div class="row-fluid marketing">
 
-    <h4>What are bridges?</h4>
-    <p><a href="https://www.torproject.org/docs/bridges";>Bridge
-        relays</a> are Tor relays that help you circumvent censorship.</p>
-
-    <h4>I need an alternative way of getting bridges!</h4>
-    <p>Another way to find public bridge addresses is to send an email (from
-      a <a href="https://mail.google.com/";>gmail</a> or a <a
-        href="https://mail.yahoo.com/";> yahoo</a> address) to <a
-        href="mailto:bridges@xxxxxxxxxxxxxx";>bridges@xxxxxxxxxxxxxx</a>
-      with the line "get bridges" by itself in the body of the
-      mail.</p>
-
-    <h4>My bridges don't work! I need help!</h4>
-    <p>If your Tor doesn't work, you should email
-      <a href="mailto:help@xxxxxxxxxxxxxxxxx";>help@xxxxxxxxxxxxxxxxx</a>. Try
-      including as much info about your case as you can, including the
-      list of bridges you used, the bundle filename/version you used, the
-      messages that Tor gave out, etc.</p>
+    <h4>${_("What are bridges?")}</h4>
+    <p>${_("%s Bridge relays %s are Tor relays that help you circumvent "
+           "censorship.") % \
+           ("""<a href="https://www.torproject.org/docs/bridges";>""", "</a>")}
+    </p>
 
+    <h4>${_("I need an alternative way of getting bridges!")}</h4>
+    <p>${_("Another way to find public bridge addresses is to send an email "
+           "(from a %s or a %s address) to %s with the line 'get bridges' by "
+           "itself in the body of the mail.""") % \
+            ("""<a href="https://mail.google.com/";>gmail</a>""",
+             """<a href="https://mail.yahoo.com/";>yahoo</a>""",
+             """<a href="mailto:bridges@xxxxxxxxxxxxxxxxxxxxxx";>
+             bridges@xxxxxxxxxxxxxxxxxxxxxx</a>""")}</p>
+
+    <h4>${_("My bridges don't work! I need help!")}</h4>
+    <p>${_("If your Tor doesn't work, you should email %s. Try including as "
+           "much info about your case as you can, including the list of "
+           "bridges you used, the bundle filename/version you used, the "
+           "messages that Tor gave out, etc.") \
+                % ("""<a href="mailto:help@xxxxxxxxxxxxxxxxx";>
+                   help@xxxxxxxxxxxxxxxxx</a>""")}</p>
   </div>
 </div>
 </div>
diff --git a/lib/bridgedb/templates/bridges.html b/lib/bridgedb/templates/bridges.html
index bf6f7d6..71e3050 100644
--- a/lib/bridgedb/templates/bridges.html
+++ b/lib/bridgedb/templates/bridges.html
@@ -7,10 +7,9 @@
 ${answer}
 </pre>
 <br />
-<p >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.
+<p >${_("""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.""")}
 </p>
-</pre>
 % else:
-<h3> No bridges currently available </h3>
+<h3> ${_("No bridges currently available")} </h3>
 % endif
 <hr>
diff --git a/lib/bridgedb/templates/captcha.html b/lib/bridgedb/templates/captcha.html
index b037eed..1504b54 100644
--- a/lib/bridgedb/templates/captcha.html
+++ b/lib/bridgedb/templates/captcha.html
@@ -1,17 +1,14 @@
 <%inherit file="base.html"/>
-
 <div class="captcha">
 <form action="" method="POST">
   <input type="hidden" name="recaptcha_challenge_field"
     id="recaptcha_challenge_field" value="${challenge_field}">
-  <img width="300" height="57" alt="Upgrade your browser to Firefox" src="${imgstr}">
+  <img width="300" height="57" alt="${_('Upgrade your browser to Firefox')}" src="${imgstr}">
   <div class="recaptcha_input_area">
-    <label for="recaptcha_response_field">Type the two words</label>
-  </div>
-
-    <input name="recaptcha_response_field" id="recaptcha_response_field"
+    <label for="recaptcha_response_field">${_("Type the two words")}</label></div>
+  <input name="recaptcha_response_field" id="recaptcha_response_field"
     type="text" autocomplete="off">
-    <input class="btn btn-success" type="submit" name="submit" value="I am human">
-</div>
+  <input class="btn btn-success" type="submit" name="submit" value="I am human">
 </form>
+</div>
 <hr>
diff --git a/lib/bridgedb/templates/index.html b/lib/bridgedb/templates/index.html
index 1114418..ae1f0e5 100644
--- a/lib/bridgedb/templates/index.html
+++ b/lib/bridgedb/templates/index.html
@@ -2,22 +2,22 @@
 
 <div class="main-steps">
 <div class="step row">
-<div class="span1">
-  <p class="lead"> <span class="step-title"> Step 1 </span></div><div
-    class="span5 step-text">Get <a
-    href="#">Tor Browser Bundle</a></p></div>
+  <div class="span1">
+    <p class="lead"><span class="step-title"> ${_("Step 1")} </span></p></div>
+  <div class="span5 step-text">
+    ${_("Get %s Tor Browser Bundle %s") % ("""<a href="#">""", "</a>")}</div>
 </div>
 <div class="step row">
   <div class="span1">
-    <p class="lead"><span class="step-title">Step 2 </span></div>
-  <div class="span5 step-text">Get <a
-    href="#">bridges</a></p></div>
-</div>
-<div class="step row"><div class="span1">
-    <p class="lead"><span class="step-title"> Step 3
-  </span></div><div class="span5 step-text">Now <a href="#">add
-      the bridges to
-      Vidalia</a></p>
+    <p class="lead"><span class="step-title"> ${_("Step 2")} </span></p></div>
+  <div class="span5 step-text">
+    ${_("Get %s bridges %s") % ("""<a href="/bridges">""", "</a>")}</div>
 </div>
+<div class="step row">
+  <div class="span1">
+    <p class="lead"><span class="step-title"> ${_("Step 3")} </span></p></div>
+  <div class="span5 step-text">
+    ${_("Now %s add the bridges to Vidalia %s") % ("""<a href="#">""", "</a>")}
+  </div>
 </div>
 <hr>
diff --git a/setup.cfg b/setup.cfg
index 9fa8c68..2cbb8b2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,25 @@
 [install]
 prefix=$HOME
 install-data=$HOME
+
+[compile_catalog]
+domain = bridgedb
+directory = i18n
+statistics = true
+
+[extract_messages]
+add_comments = TRANSLATORS:
+output_file = i18n/templates/bridgedb.pot
+width = 80
+
+[init_catalog]
+domain = torcheck
+input_file = i18n/templates/bridgedb.pot
+output_dir = i18n
+
+[update_catalog]
+domain = torcheck
+input_file = i18n/templates/torcheck.pot
+output_dir = i18n
+previous = true
+
diff --git a/setup.py b/setup.py
index 6e994d1..a3289c9 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ from babel.messages import frontend as babel
 import os
 import sys
 
-from distutils.core import setup, Command
+from setuptools import setup, Command, find_packages
 
 class installData(_install_data):
     def run(self):
@@ -56,7 +56,7 @@ setup(name='BridgeDB',
       author_email='nickm at torproject dot org',
       url='https://www.torproject.org',
       package_dir= {'' : 'lib'},
-      packages=['bridgedb'],
+      packages=find_packages('lib'),
       py_modules=['TorBridgeDB'],
       cmdclass={'test' : runTests,
                 'compile_catalog': babel.compile_catalog,
@@ -68,8 +68,8 @@ setup(name='BridgeDB',
       package_data={'bridgedb': ['i18n/*/LC_MESSAGES/*.mo',
                                  'templates/*.html',
                                  'templates/assets/*']},
-      message_extractors = {'bridgedb': [
+      message_extractors = {'lib/bridgedb': [
               ('**.py', 'python', None),
               ('templates/**.html', 'mako', None),
-              ('public/**', 'ignore', None)]},
+              ('public/**', 'ignore', None)]},  
 )



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits