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

[tor-commits] [gettor/master] Changed links message (SMTP)



commit 038ab13c87e2f28116180ec63853a225aebbce77
Author: ilv <ilv@xxxxxxxxxxxxxxxxxxxxxxxx>
Date:   Sun Jul 12 18:39:20 2015 -0300

    Changed links message (SMTP)
---
 gettor/core.py                      |   45 +++++++++++++++++++++++++----
 lang/core/i18n/en/en.po             |    9 ++++++
 lang/smtp/i18n/en/LC_MESSAGES/en.po |   53 +++--------------------------------
 upload/bundles2dropbox.py           |    5 ++--
 4 files changed, 55 insertions(+), 57 deletions(-)

diff --git a/gettor/core.py b/gettor/core.py
index 88fb707..df596a9 100644
--- a/gettor/core.py
+++ b/gettor/core.py
@@ -13,6 +13,7 @@
 import os
 import re
 import logging
+import gettext
 import tempfile
 import ConfigParser
 
@@ -121,6 +122,11 @@ class Core(object):
             loglevel = config.get('log', 'level')
         except ConfigParser.Error as e:
             raise ConfigError("Couldn't read 'level' from 'log'")
+        
+        try:
+            self.i18ndir = config.get('i18n', 'dir')
+        except ConfigParser.Error as e:
+            raise ConfigError("Couldn't read 'dir' from 'i18n'")
 
         try:
             logdir = config.get('log', 'dir')
@@ -137,6 +143,22 @@ class Core(object):
         # stop logging on stdout from now on
         log.propagate = False
 
+    def _get_msg(self, msgid, lc):
+        """Get message identified by msgid in a specific locale.
+
+        :param: msgid (string) the identifier of a string.
+        :param: lc (string) the locale.
+
+        :return: (string) the message from the .po file.
+
+        """
+        # obtain the content in the proper language
+        t = gettext.translation(lc, self.i18ndir, languages=[lc])
+        _ = t.ugettext
+
+        msgstr = _(msgid)
+        return msgstr
+
     def get_links(self, service, os, lc):
         """Get links for OS in locale.
 
@@ -201,6 +223,9 @@ class Core(object):
         # links were found
         providers = {}
 
+        # separator
+        spt = '=' * 72
+
         # reading links from providers directory
         for name in links:
             # we're reading files listed on linksdir, so they must exist!
@@ -216,17 +241,17 @@ class Core(object):
             try:
                 providers[pname] = config.get(osys, lc)
                 # avoid showing it all together
-                providers[pname] = providers[pname].replace(",", "\n")
+                providers[pname] = providers[pname].replace(",", "")
+                providers[pname] = providers[pname].replace("$", "\n\n")
             except ConfigParser.Error as e:
                 raise InternalError("Couldn't get %s from %s (%s)" %
                                     (lc, osys, name))
 
-            # each provider must have a fingerprint of the key used to
-            # sign the uploaded packages
+            # all packages are signed with the same key (Tor Browser developers)
             try:
                 fingerprint = config.get('key', 'fingerprint')
-                providers[pname] = "%s\n\nFingerprint: %s" %\
-                                   (providers[pname], fingerprint)
+                fingerprint_msg = self._get_msg('fingerprint', lc)
+                fingerprint_msg = fingerprint_msg % fingerprint
             except ConfigParser.Error as e:
                 raise InternalError("Couldn't get 'fingerprint' from 'key'")
 
@@ -234,10 +259,18 @@ class Core(object):
         all_links = []
 
         for key in providers.keys():
+            # get more friendly description of the provider
+            provider_desc = self._get_msg('provider_desc', lc)
+            provider_desc = provider_desc % key
+
             all_links.append(
-                "\n%s\n\n%s\n" % (key, ''.join(providers[key]))
+                "%s\n%s\n\n%s%s\n\n\n" %
+                (provider_desc, spt, ''.join(providers[key]), spt)
             )
 
+        # add fingerprint after the links
+        all_links.append(fingerprint_msg)
+
         if all_links:
             return "".join(all_links)
         else:
diff --git a/lang/core/i18n/en/en.po b/lang/core/i18n/en/en.po
new file mode 100644
index 0000000..b8d4509
--- /dev/null
+++ b/lang/core/i18n/en/en.po
@@ -0,0 +1,9 @@
+domain "en"
+
+#: Fingerprint message
+msgid "fingerprint"
+msgstr "Fingerprint of the key used to sign Tor Browser:\n%s"
+
+#: Provider description
+msgid "provider_desc"
+msgstr "[From %s]"
diff --git a/lang/smtp/i18n/en/LC_MESSAGES/en.po b/lang/smtp/i18n/en/LC_MESSAGES/en.po
index 6f78da2..906dbb8 100644
--- a/lang/smtp/i18n/en/LC_MESSAGES/en.po
+++ b/lang/smtp/i18n/en/LC_MESSAGES/en.po
@@ -4,18 +4,10 @@ domain "en"
 msgid "links_subject"
 msgstr "[GetTor] Links for your request"
 
-#: Links subject (PT)
-msgid "links_pt_subject"
-msgstr "[GetTor] Links for your request"
-
 #: Help subject
 msgid "help_subject"
 msgstr "[GetTor] Help"
 
-#: Delay subject
-msgid "delay_subject"
-msgstr "[GetTor] Delay message"
-
 # Unsupported locale subject
 msgid "unsupported_locale_subject"
 msgstr "[GetTor] Unsupported locale"
@@ -26,44 +18,11 @@ msgstr "The locale you requested '%s' is not supported."
 
 #: Links message
 msgid "links_msg"
-msgstr "Thank you for your request for %s-%s.\n\
-\n\
-Here are the download links:\n\
-\n\
-===\n\
-Tor Browser Bundle:\n\
-===\n\
-%s\n\
-===\n\
-\n\
-===\n\
-Support:\n\
-===\n\
-\n\
-Still need help? If you have any questions, trouble connecting to Tor\n\
-network, or need to talk to a human, please contact our support team at:\n\
+msgstr "Hello there! this is the 'GetTor' robot.\n\
 \n\
-    help@xxxxxxxxxxxxxxxxx\n\
+Below are the links for your request (Tor Browser for %s, %s package):\n\
 \n\
-We are ready to answer your queries in English, Farsi, Chinese, Arabic,\n\
-French and Spanish."
-
-#: Links message (PT)
-msgid "links_pt_msg"
-msgstr "Thank you for your request for %s-%s.\n\
-\n\
-Here are the download links:\n\
-\n\
-===\n\
-Tor Browser Bundle:\n\
-===\n\
 %s\n\
-===\n\
-Info about pluggable transports.\n\
-\n\
-===\n\
-Support:\n\
-===\n\
 \n\
 Still need help? If you have any questions, trouble connecting to Tor\n\
 network, or need to talk to a human, please contact our support team at:\n\
@@ -75,10 +34,10 @@ French and Spanish."
 
 #: Help message
 msgid "help_msg"
-msgstr "Hello, this is the 'GetTor' robot.\n\
+msgstr "Hello there! this is the 'GetTor' robot.\n\
 \n\
 Thank you for your request. I am here to help you download the latest\n\
-Tor Browser Bundle.\n\
+Tor Browser.\n\
 \n\
 Please reply to this message with one of the options below:\n\
 \n\
@@ -89,7 +48,3 @@ Please reply to this message with one of the options below:\n\
 And I will send you the download instructions quickly.\n\
 \n\
 Tip: Just send a blank reply to this message if you are not sure."
-
-#: Delay message
-msgid "delay_msg"
-msgstr "Delay message."
diff --git a/upload/bundles2dropbox.py b/upload/bundles2dropbox.py
index a1328d8..bedeec0 100644
--- a/upload/bundles2dropbox.py
+++ b/upload/bundles2dropbox.py
@@ -236,8 +236,9 @@ if __name__ == '__main__':
             elif p3.match(file):
                 osys, arch, lc = get_bundle_info(file, 'osx')
 
-            link = "Package (%s-bit): %s\nASC signature (%s-bit): %s\n"\
-                   "Package SHA256 checksum (%s-bit): %s\n" %\
+            link = "Tor Browser %s-bit:\n%s$Tor Browser's signature %s-bit:"\
+                    "\n%s$SHA256 checksum of Tor Browser %s-bit (advanced):"\
+                    "\n%s$" %\
                    (arch, link_file[u'url'], arch, link_asc[u'url'],
                     arch, sha_file)
 



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