i18n: Fix some ineffective calls to ugettext at top level.

Translation has no effect when we don’t yet know what language we’re
translating for.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-10-16 18:42:50 -07:00
committed by Tim Abbott
parent bba43f35ca
commit f461a64a6b
5 changed files with 38 additions and 43 deletions

View File

@@ -8,6 +8,7 @@ from django.shortcuts import render
from django.utils.html import escape
from django.utils.safestring import SafeString
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from confirmation.models import (
Confirmation,
@@ -45,7 +46,7 @@ from zerver.lib.validator import check_bool, check_int, check_int_in, check_stri
from zerver.models import UserProfile, avatar_changes_disabled, name_changes_disabled
from zproject.backends import check_password_strength, email_belongs_to_ldap
AVATAR_CHANGES_DISABLED_ERROR = _("Avatar changes are disabled in this organization.")
AVATAR_CHANGES_DISABLED_ERROR = ugettext_lazy("Avatar changes are disabled in this organization.")
def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResponse:
try:
@@ -242,7 +243,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
return json_error(_("You must upload exactly one avatar."))
if avatar_changes_disabled(user_profile.realm) and not user_profile.is_realm_admin:
return json_error(AVATAR_CHANGES_DISABLED_ERROR)
return json_error(str(AVATAR_CHANGES_DISABLED_ERROR))
user_file = list(request.FILES.values())[0]
if ((settings.MAX_AVATAR_FILE_SIZE * 1024 * 1024) < user_file.size):
@@ -260,7 +261,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
def delete_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
if avatar_changes_disabled(user_profile.realm) and not user_profile.is_realm_admin:
return json_error(AVATAR_CHANGES_DISABLED_ERROR)
return json_error(str(AVATAR_CHANGES_DISABLED_ERROR))
do_change_avatar_fields(user_profile, UserProfile.AVATAR_FROM_GRAVATAR, acting_user=user_profile)
gravatar_url = avatar_url(user_profile)