Skip to content

Commit

Permalink
Internationalize verification code SMS. (#1525)
Browse files Browse the repository at this point in the history
I forgot that NoRent can potentially send the verification code SMS if a user forgets their password. This internationalizes the message.
  • Loading branch information
toolness authored Jun 8, 2020
1 parent c5cade5 commit 2f8bdad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion locales/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-27 21:56+0000\n"
"POT-Creation-Date: 2020-06-08 10:07+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -72,6 +72,11 @@ msgstr ""
msgid "Passwords do not match!"
msgstr ""

#: project/password_reset.py:65
#, python-format
msgid "%(site_name)s here! Your verification code is %(code)s."
msgstr ""

#: project/tests/test_compilemessages.py:6
msgid "Hello world"
msgstr ""
Expand Down
8 changes: 6 additions & 2 deletions locales/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tenants2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-27 21:56+0000\n"
"POT-Creation-Date: 2020-06-08 10:07+0000\n"
"PO-Revision-Date: 2020-06-06 17:48\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Spanish\n"
Expand Down Expand Up @@ -69,6 +69,11 @@ msgstr "Ya existe un usuario con esa dirección de correo electrónico."
msgid "Passwords do not match!"
msgstr "¡Las contraseñas no coinciden!"

#: project/password_reset.py:65
#, python-format
msgid "%(site_name)s here! Your verification code is %(code)s."
msgstr ""

#: project/tests/test_compilemessages.py:6
msgid "Hello world"
msgstr "Hola mundo"
Expand Down Expand Up @@ -98,4 +103,3 @@ msgstr "%(areacode)s no es un prefijo telefónico válido."
#: project/util/phone_number.py:68
msgid "This does not look like a U.S. phone number. Please include the area code, e.g. (555) 123-4567."
msgstr "Ese no parece un número de teléfono de los Estados Unidos de América. Por favor, incluye el prefijo telefónico, por ejemplo, (555) 123-4567."

6 changes: 5 additions & 1 deletion project/password_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Optional
from django.utils.crypto import get_random_string, constant_time_compare
from django.http import HttpRequest
from django.utils.translation import gettext as _

from . import slack
from .util.site_util import get_site_name
Expand Down Expand Up @@ -61,7 +62,10 @@ def create_verification_code(request: HttpRequest, phone_number: str):
request.session[TIMESTAMP_SESSION_KEY] = time.time()
twilio.send_sms_async(
phone_number,
f"{get_site_name()} here! Your verification code is {vcode}.",
_("%(site_name)s here! Your verification code is %(code)s.") % {
"site_name": get_site_name(),
"code": vcode,
}
)
slack.sendmsg_async(
f"{slack.hyperlink(text=user.first_name, href=user.admin_url)} "
Expand Down

0 comments on commit 2f8bdad

Please sign in to comment.