python: Convert deprecated Django ugettext alias to gettext.

django.utils.translation.ugettext is a deprecated alias of
django.utils.translation.gettext as of Django 3.0, and will be removed
in Django 4.0.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-04-15 15:57:30 -07:00
committed by Tim Abbott
parent 173ce9a3fc
commit e7ed907cf6
93 changed files with 150 additions and 150 deletions

View File

@@ -166,7 +166,7 @@ A string in Python can be marked for translation using the `_()` function,
which can be imported as follows:
```
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
```
Zulip expects all the error messages to be translatable as well. To
@@ -180,13 +180,13 @@ JsonableError(_('English Text'))
```
If you're declaring a user-facing string at top level or in a class, you need to
use `ugettext_lazy` instead, to ensure that the translation happens at
use `gettext_lazy` instead, to ensure that the translation happens at
request-processing time when Django knows what language to use, e.g.:
```python
from zproject.backends import check_password_strength, email_belongs_to_ldap
AVATAR_CHANGES_DISABLED_ERROR = ugettext_lazy("Avatar changes are disabled in this organization.")
AVATAR_CHANGES_DISABLED_ERROR = gettext_lazy("Avatar changes are disabled in this organization.")
def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResponse:
...
@@ -200,7 +200,7 @@ class Realm(models.Model):
...
...
STREAM_EVENTS_NOTIFICATION_TOPIC = ugettext_lazy('stream events')
STREAM_EVENTS_NOTIFICATION_TOPIC = gettext_lazy('stream events')
```
To ensure we always internationalize our JSON errors messages, the