Commit d43b45af authored by Hiro's avatar Hiro 🏄
Browse files

Update locales and tests

parent 3726d31b
......@@ -154,7 +154,7 @@ class EmailParser(object):
request["command"] = "help"
break
if not request["command"] and not request["language"]:
if not request["command"] or not request["language"]:
for word in re.split(r"\s+", msg_str.strip()):
if word.lower() in languages:
request["language"] = word.lower()
......
......@@ -85,7 +85,7 @@ def get_locales():
"""
Get available_locales
"""
filename = get_resource_path("available_locales.json", '../share/locale')
locales = {}
with open(filename, encoding='utf-8') as f:
......@@ -109,15 +109,10 @@ def load_strings(current_locale):
with open(filename, encoding='utf-8') as f:
translations[locale] = json.load(f)
# Build strings
default_locale = 'en'
strings = {}
for s in translations[default_locale]:
if s in translations[current_locale] and translations[current_locale][s] != "":
strings[s] = translations[current_locale][s]
else:
strings[s] = translations[default_locale][s]
for s in translations[current_locale]:
strings[s] = translations[current_locale][s]
def translated(k):
......
......@@ -7,7 +7,7 @@
"help_config": "Custom config file location (optional)",
"smtp_links_subject": "[GetTor] Links for your request",
"smtp_mirrors_subject": "[GetTor] Mirrors",
"smtp_help_subject": "[GetTor] Help",
"smtp_help_subject": "[GetTor] Ayuda",
"smtp_unsupported_locale_subject": "[GetTor] Unsupported locale",
"smtp_unsupported_locale_msg": "The locale you requested '{}' is not supported.",
"smtp_vlinks_msg": "You requested Tor Browser for {}.\n\nYou will need only one of the links below to download the bundle. If a link does not work for you, try the next one.\n\n{}\n\n \n--\nGetTor",
......
......@@ -3,5 +3,6 @@ from __future__ import print_function
from __future__ import unicode_literals
from gettor.utils import options
from gettor.utils import strings
from gettor.services.email import sendmail
from gettor.parse.email import EmailParser, AddressError, DKIMError
#!/usr/bin/env python3
import pytest
from twisted.trial import unittest
from twisted.internet import defer, reactor
from twisted.internet import task
from . import conftests
class EmailServiceTests(unittest.TestCase):
# Fail any tests which take longer than 15 seconds.
timeout = 15
def setUp(self):
self.settings = conftests.options.parse_settings()
self.locales = conftests.strings.get_locales()
def tearDown(self):
print("tearDown()")
def test_get_available_locales(self):
self.assertEqual({"en": "English", "es": "Español", "pt": "Português Brasil"}, self.locales)
def test_load_en_strings(self):
conftests.strings.load_strings("en")
self.assertEqual(conftests.strings._("smtp_mirrors_subject"), "[GetTor] Mirrors")
def test_load_es_strings(self):
conftests.strings.load_strings("es")
self.assertEqual(conftests.strings._("smtp_help_subject"), "[GetTor] Ayuda")
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment