From e7ed907cf6663e2ab1db751fa8e6a6f7cea32e09 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 15 Apr 2021 15:57:30 -0700 Subject: [PATCH] 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 --- analytics/views.py | 2 +- corporate/lib/stripe.py | 8 ++-- corporate/views.py | 2 +- docs/translating/internationalization.md | 8 ++-- .../api/incoming-webhooks-walkthrough.md | 2 +- tools/semgrep.yml | 14 +++---- zerver/decorator.py | 2 +- zerver/forms.py | 2 +- zerver/lib/actions.py | 2 +- zerver/lib/addressee.py | 2 +- zerver/lib/attachments.py | 2 +- zerver/lib/bot_lib.py | 2 +- zerver/lib/domains.py | 2 +- zerver/lib/email_notifications.py | 2 +- zerver/lib/email_validation.py | 2 +- zerver/lib/emoji.py | 2 +- zerver/lib/error_notify.py | 2 +- zerver/lib/events.py | 2 +- zerver/lib/exceptions.py | 2 +- zerver/lib/external_accounts.py | 2 +- zerver/lib/hotspots.py | 22 +++++------ zerver/lib/integrations.py | 30 +++++++-------- zerver/lib/message.py | 2 +- zerver/lib/narrow.py | 2 +- zerver/lib/onboarding.py | 2 +- zerver/lib/outgoing_webhook.py | 2 +- zerver/lib/push_notifications.py | 2 +- zerver/lib/remote_server.py | 2 +- zerver/lib/request.py | 2 +- zerver/lib/response.py | 2 +- zerver/lib/send_email.py | 2 +- zerver/lib/streams.py | 2 +- zerver/lib/upload.py | 2 +- zerver/lib/user_groups.py | 2 +- zerver/lib/users.py | 2 +- zerver/lib/validator.py | 2 +- zerver/lib/webhooks/common.py | 2 +- zerver/lib/zcommand.py | 2 +- zerver/management/commands/compilemessages.py | 2 +- zerver/middleware.py | 2 +- zerver/models.py | 38 +++++++++---------- zerver/signals.py | 2 +- zerver/tornado/event_queue.py | 2 +- zerver/tornado/exceptions.py | 2 +- zerver/tornado/views.py | 2 +- zerver/views/auth.py | 2 +- zerver/views/camo.py | 2 +- zerver/views/compatibility.py | 2 +- zerver/views/custom_profile_fields.py | 2 +- zerver/views/drafts.py | 2 +- zerver/views/events_register.py | 2 +- zerver/views/hotspots.py | 2 +- zerver/views/invite.py | 2 +- zerver/views/message_edit.py | 2 +- zerver/views/message_fetch.py | 2 +- zerver/views/message_flags.py | 2 +- zerver/views/message_send.py | 2 +- zerver/views/muting.py | 2 +- zerver/views/presence.py | 2 +- zerver/views/push_notifications.py | 2 +- zerver/views/reactions.py | 2 +- zerver/views/realm.py | 2 +- zerver/views/realm_domains.py | 2 +- zerver/views/realm_emoji.py | 2 +- zerver/views/realm_export.py | 2 +- zerver/views/realm_icon.py | 2 +- zerver/views/realm_linkifiers.py | 2 +- zerver/views/realm_logo.py | 2 +- zerver/views/realm_playgrounds.py | 2 +- zerver/views/registration.py | 2 +- zerver/views/streams.py | 2 +- zerver/views/submessage.py | 2 +- zerver/views/thumbnail.py | 2 +- zerver/views/typing.py | 2 +- zerver/views/upload.py | 2 +- zerver/views/user_groups.py | 2 +- zerver/views/user_settings.py | 6 +-- zerver/views/users.py | 2 +- zerver/views/video_calls.py | 2 +- zerver/views/zephyr.py | 2 +- zerver/webhooks/front/view.py | 2 +- zerver/webhooks/ifttt/view.py | 2 +- zerver/webhooks/librato/view.py | 2 +- zerver/webhooks/newrelic/view.py | 2 +- zerver/webhooks/pivotal/view.py | 2 +- zerver/webhooks/slack/view.py | 2 +- zerver/webhooks/slack_incoming/view.py | 2 +- zerver/webhooks/wordpress/view.py | 2 +- zerver/webhooks/zabbix/view.py | 2 +- zerver/webhooks/zapier/view.py | 2 +- zerver/worker/queue_processors.py | 2 +- zilencer/views.py | 4 +- zproject/backends.py | 2 +- 93 files changed, 150 insertions(+), 150 deletions(-) diff --git a/analytics/views.py b/analytics/views.py index 43d0931c40..019a83dbf1 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -23,7 +23,7 @@ from django.urls import reverse from django.utils import translation from django.utils.timesince import timesince from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from jinja2 import Markup as mark_safe from psycopg2.sql import SQL, Composable, Literal diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 3dc895d805..79bfa86344 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -13,9 +13,9 @@ from django.conf import settings from django.core.signing import Signer from django.db import transaction from django.utils.timezone import now as timezone_now +from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_lazy from corporate.models import ( Customer, @@ -172,8 +172,8 @@ def get_idempotency_key(ledger_entry: LicenseLedger) -> Optional[str]: class BillingError(Exception): # error messages - CONTACT_SUPPORT = ugettext_lazy("Something went wrong. Please contact {email}.") - TRY_RELOADING = ugettext_lazy("Something went wrong. Please reload the page.") + CONTACT_SUPPORT = gettext_lazy("Something went wrong. Please contact {email}.") + TRY_RELOADING = gettext_lazy("Something went wrong. Please reload the page.") # description is used only for tests def __init__(self, description: str, message: Optional[str] = None) -> None: diff --git a/corporate/views.py b/corporate/views.py index 6dcd12bc2f..e727dcfcca 100644 --- a/corporate/views.py +++ b/corporate/views.py @@ -10,7 +10,7 @@ from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.shortcuts import render from django.urls import reverse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from corporate.lib.stripe import ( DEFAULT_INVOICE_DAYS_UNTIL_DUE, diff --git a/docs/translating/internationalization.md b/docs/translating/internationalization.md index d3bf441340..6f8ae6862c 100644 --- a/docs/translating/internationalization.md +++ b/docs/translating/internationalization.md @@ -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 diff --git a/templates/zerver/api/incoming-webhooks-walkthrough.md b/templates/zerver/api/incoming-webhooks-walkthrough.md index 72cfc00ce3..20fdbfbc01 100644 --- a/templates/zerver/api/incoming-webhooks-walkthrough.md +++ b/templates/zerver/api/incoming-webhooks-walkthrough.md @@ -84,7 +84,7 @@ The Hello World integration is in `zerver/webhooks/helloworld/view.py`: from typing import Any, Dict, Iterable, Optional from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.webhooks.common import check_send_webhook_message diff --git a/tools/semgrep.yml b/tools/semgrep.yml index d10583472a..b498399c21 100644 --- a/tools/semgrep.yml +++ b/tools/semgrep.yml @@ -70,16 +70,16 @@ rules: - id: translated-format languages: [python] pattern-either: - - pattern: django.utils.translation.ugettext(... .format(...)) - - pattern: django.utils.translation.ugettext(f"...") - - pattern: django.utils.translation.ugettext_lazy(... .format(...)) - - pattern: django.utils.translation.ugettext_lazy(f"...") + - pattern: django.utils.translation.gettext(... .format(...)) + - pattern: django.utils.translation.gettext(f"...") + - pattern: django.utils.translation.gettext_lazy(... .format(...)) + - pattern: django.utils.translation.gettext_lazy(f"...") severity: ERROR message: "Format strings after translation, not before" - id: translated-format-lazy languages: [python] - pattern: django.utils.translation.ugettext_lazy(...).format(...) + pattern: django.utils.translation.gettext_lazy(...).format(...) severity: ERROR message: "Immediately formatting a lazily translated string destroys its laziness" @@ -123,8 +123,8 @@ rules: languages: [python] pattern-either: - pattern: '"..." % ...' - - pattern: django.utils.translation.ugettext(...) % ... - - pattern: django.utils.translation.ugettext_lazy(...) % ... + - pattern: django.utils.translation.gettext(...) % ... + - pattern: django.utils.translation.gettext_lazy(...) % ... severity: ERROR message: "Prefer f-strings or .format for string formatting" diff --git a/zerver/decorator.py b/zerver/decorator.py index 6e4b139884..403978cfb1 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -18,7 +18,7 @@ from django.http.multipartparser import MultiPartParser from django.shortcuts import resolve_url from django.template.response import SimpleTemplateResponse, TemplateResponse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt from django_otp import user_has_device from two_factor.utils import default_device diff --git a/zerver/forms.py b/zerver/forms.py index 0c8e24c3a5..f426444107 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -13,7 +13,7 @@ from django.core.validators import validate_email from django.http import HttpRequest from django.urls import reverse from django.utils.http import urlsafe_base64_encode -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from jinja2 import Markup as mark_safe from two_factor.forms import AuthenticationTokenForm as TwoFactorAuthenticationTokenForm from two_factor.utils import totp_digits diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 32bc5ce800..96640856b0 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -33,8 +33,8 @@ from django.db.models import Count, Exists, F, OuterRef, Q, Sum from django.db.models.query import QuerySet from django.utils.html import escape from django.utils.timezone import now as timezone_now +from django.utils.translation import gettext as _ from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ from psycopg2.extras import execute_values from psycopg2.sql import SQL from typing_extensions import TypedDict diff --git a/zerver/lib/addressee.py b/zerver/lib/addressee.py index 6280219d5c..60817ea94c 100644 --- a/zerver/lib/addressee.py +++ b/zerver/lib/addressee.py @@ -1,6 +1,6 @@ from typing import Iterable, List, Optional, Sequence, Union, cast -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.exceptions import JsonableError from zerver.models import ( diff --git a/zerver/lib/attachments.py b/zerver/lib/attachments.py index 5785c98ae2..478a490b21 100644 --- a/zerver/lib/attachments.py +++ b/zerver/lib/attachments.py @@ -1,6 +1,6 @@ from typing import Any, Dict, List -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.request import JsonableError from zerver.lib.upload import delete_message_image diff --git a/zerver/lib/bot_lib.py b/zerver/lib/bot_lib.py index 43b6ff4259..2180412f88 100644 --- a/zerver/lib/bot_lib.py +++ b/zerver/lib/bot_lib.py @@ -4,7 +4,7 @@ import os from typing import Any, Callable, Dict, Optional from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.actions import ( internal_send_huddle_message, diff --git a/zerver/lib/domains.py b/zerver/lib/domains.py index b526e33be3..95b146e3aa 100644 --- a/zerver/lib/domains.py +++ b/zerver/lib/domains.py @@ -2,7 +2,7 @@ import re from typing import Optional from django.core.exceptions import ValidationError -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ def validate_domain(domain: Optional[str]) -> None: diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py index 7396490156..69f22070f9 100644 --- a/zerver/lib/email_notifications.py +++ b/zerver/lib/email_notifications.py @@ -13,8 +13,8 @@ from bs4 import BeautifulSoup from django.conf import settings from django.contrib.auth import get_backends from django.utils.timezone import now as timezone_now +from django.utils.translation import gettext as _ from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ from lxml.cssselect import CSSSelector from confirmation.models import one_click_unsubscribe_link diff --git a/zerver/lib/email_validation.py b/zerver/lib/email_validation.py index 3e8ee472fb..d5e712501b 100644 --- a/zerver/lib/email_validation.py +++ b/zerver/lib/email_validation.py @@ -2,7 +2,7 @@ from typing import Callable, Dict, Optional, Set, Tuple from django.core import validators from django.core.exceptions import ValidationError -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.name_restrictions import is_disposable_domain diff --git a/zerver/lib/emoji.py b/zerver/lib/emoji.py index 4ec5dd87fa..f684931326 100644 --- a/zerver/lib/emoji.py +++ b/zerver/lib/emoji.py @@ -3,7 +3,7 @@ import re from typing import Optional, Tuple import orjson -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.exceptions import OrganizationAdministratorRequired from zerver.lib.request import JsonableError diff --git a/zerver/lib/error_notify.py b/zerver/lib/error_notify.py index 808cb290bd..8e3854f5a3 100644 --- a/zerver/lib/error_notify.py +++ b/zerver/lib/error_notify.py @@ -5,7 +5,7 @@ from typing import Any, Dict from django.conf import settings from django.core.mail import mail_admins from django.http import HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.filters import clean_data_from_query_parameters from zerver.lib.actions import internal_send_stream_message diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 0b01672dfe..508d708d8c 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -4,7 +4,7 @@ import copy from typing import Any, Callable, Dict, Iterable, Optional, Sequence, Set from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from version import API_FEATURE_LEVEL, ZULIP_VERSION from zerver.lib.actions import ( diff --git a/zerver/lib/exceptions.py b/zerver/lib/exceptions.py index d2149aa79b..5a50c9f742 100644 --- a/zerver/lib/exceptions.py +++ b/zerver/lib/exceptions.py @@ -1,7 +1,7 @@ from enum import Enum from typing import Any, Dict, List, NoReturn, Optional, Type, TypeVar -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ T = TypeVar("T", bound="AbstractEnum") diff --git a/zerver/lib/external_accounts.py b/zerver/lib/external_accounts.py index d504ae3581..b6bba2f40b 100644 --- a/zerver/lib/external_accounts.py +++ b/zerver/lib/external_accounts.py @@ -2,7 +2,7 @@ This module stores data for "External Account" custom profile field. """ from django.core.exceptions import ValidationError -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.types import ProfileFieldData from zerver.lib.validator import ( diff --git a/zerver/lib/hotspots.py b/zerver/lib/hotspots.py index dbbc85b12c..ae43ae1875 100644 --- a/zerver/lib/hotspots.py +++ b/zerver/lib/hotspots.py @@ -4,39 +4,39 @@ from typing import Dict, List from django.conf import settings from django.utils.functional import Promise -from django.utils.translation import ugettext_lazy +from django.utils.translation import gettext_lazy from zerver.models import UserHotspot, UserProfile INTRO_HOTSPOTS: Dict[str, Dict[str, Promise]] = { "intro_reply": { - "title": ugettext_lazy("Reply to a message"), - "description": ugettext_lazy("Click anywhere on a message to reply."), + "title": gettext_lazy("Reply to a message"), + "description": gettext_lazy("Click anywhere on a message to reply."), }, "intro_streams": { - "title": ugettext_lazy("Catch up on a stream"), - "description": ugettext_lazy( + "title": gettext_lazy("Catch up on a stream"), + "description": gettext_lazy( "Messages sent to a stream are seen by everyone subscribed " "to that stream. Try clicking on one of the stream links below." ), }, "intro_topics": { - "title": ugettext_lazy("Topics"), - "description": ugettext_lazy( + "title": gettext_lazy("Topics"), + "description": gettext_lazy( "Every message has a topic. Topics keep conversations " "easy to follow, and make it easy to reply to conversations that start " "while you are offline." ), }, "intro_gear": { - "title": ugettext_lazy("Settings"), - "description": ugettext_lazy( + "title": gettext_lazy("Settings"), + "description": gettext_lazy( "Go to Settings to configure your notifications and display settings." ), }, "intro_compose": { - "title": ugettext_lazy("Compose"), - "description": ugettext_lazy( + "title": gettext_lazy("Compose"), + "description": gettext_lazy( "Click here to start a new conversation. Pick a topic " "(2-3 words is best), and give it a go!" ), diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py index 383ec6e322..e42a0180a6 100644 --- a/zerver/lib/integrations.py +++ b/zerver/lib/integrations.py @@ -7,7 +7,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage from django.urls.resolvers import RegexPattern from django.utils.functional import Promise from django.utils.module_loading import import_string -from django.utils.translation import ugettext as ugettext_lazy +from django.utils.translation import gettext as gettext_lazy from zerver.lib.storage import static_path from zerver.lib.types import Validator @@ -32,20 +32,20 @@ features for writing and configuring integrations efficiently. """ CATEGORIES: Dict[str, Promise] = { - "meta-integration": ugettext_lazy("Integration frameworks"), - "continuous-integration": ugettext_lazy("Continuous integration"), - "customer-support": ugettext_lazy("Customer support"), - "deployment": ugettext_lazy("Deployment"), - "communication": ugettext_lazy("Communication"), - "financial": ugettext_lazy("Financial"), - "hr": ugettext_lazy("HR"), - "marketing": ugettext_lazy("Marketing"), - "misc": ugettext_lazy("Miscellaneous"), - "monitoring": ugettext_lazy("Monitoring tools"), - "project-management": ugettext_lazy("Project management"), - "productivity": ugettext_lazy("Productivity"), - "version-control": ugettext_lazy("Version control"), - "bots": ugettext_lazy("Interactive bots"), + "meta-integration": gettext_lazy("Integration frameworks"), + "continuous-integration": gettext_lazy("Continuous integration"), + "customer-support": gettext_lazy("Customer support"), + "deployment": gettext_lazy("Deployment"), + "communication": gettext_lazy("Communication"), + "financial": gettext_lazy("Financial"), + "hr": gettext_lazy("HR"), + "marketing": gettext_lazy("Marketing"), + "misc": gettext_lazy("Miscellaneous"), + "monitoring": gettext_lazy("Monitoring tools"), + "project-management": gettext_lazy("Project management"), + "productivity": gettext_lazy("Productivity"), + "version-control": gettext_lazy("Version control"), + "bots": gettext_lazy("Interactive bots"), } diff --git a/zerver/lib/message.py b/zerver/lib/message.py index 60d7d1367c..4454cfe8d9 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -9,7 +9,7 @@ import orjson from django.db import connection from django.db.models import Max, Sum from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from psycopg2.sql import SQL from typing_extensions import TypedDict diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.py index 8054b2a81f..ff1ec77d92 100644 --- a/zerver/lib/narrow.py +++ b/zerver/lib/narrow.py @@ -2,7 +2,7 @@ import os from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.request import JsonableError from zerver.lib.topic import get_topic_from_message_info diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py index bcc5b90374..d1ccaed591 100644 --- a/zerver/lib/onboarding.py +++ b/zerver/lib/onboarding.py @@ -2,7 +2,7 @@ from typing import Dict, List from django.conf import settings from django.db.models import Count -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.actions import ( create_users, diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.py index ba26f781f1..32a1cc0be6 100644 --- a/zerver/lib/outgoing_webhook.py +++ b/zerver/lib/outgoing_webhook.py @@ -4,7 +4,7 @@ import logging from typing import Any, AnyStr, Dict, Optional import requests -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from requests import Response, Session from version import ZULIP_VERSION diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index a09353c995..dd13f29ea7 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -13,7 +13,7 @@ from django.conf import settings from django.db import IntegrityError, transaction from django.db.models import F from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import statsd_increment from zerver.lib.avatar import absolute_avatar_url diff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.py index ba10ed7e9e..cbc4f982b4 100644 --- a/zerver/lib/remote_server.py +++ b/zerver/lib/remote_server.py @@ -6,7 +6,7 @@ import orjson import requests from django.conf import settings from django.forms.models import model_to_dict -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from analytics.models import InstallationCount, RealmCount from version import ZULIP_VERSION diff --git a/zerver/lib/request.py b/zerver/lib/request.py index a37878bdee..e3ca34cc23 100644 --- a/zerver/lib/request.py +++ b/zerver/lib/request.py @@ -19,7 +19,7 @@ from typing import ( import orjson from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from typing_extensions import Literal from zerver.lib.exceptions import ErrorCode, InvalidJSONError, JsonableError diff --git a/zerver/lib/response.py b/zerver/lib/response.py index b68da22e53..5e5a400051 100644 --- a/zerver/lib/response.py +++ b/zerver/lib/response.py @@ -2,7 +2,7 @@ from typing import Any, List, Mapping, Optional import orjson from django.http import HttpResponse, HttpResponseNotAllowed -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.exceptions import JsonableError diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py index 2e980faf9c..7770832e79 100644 --- a/zerver/lib/send_email.py +++ b/zerver/lib/send_email.py @@ -17,8 +17,8 @@ from django.db import transaction from django.template import loader from django.template.exceptions import TemplateDoesNotExist from django.utils.timezone import now as timezone_now +from django.utils.translation import gettext as _ from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ from confirmation.models import generate_key from scripts.setup.inline_email_css import inline_template diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py index ebb1cd4246..b22405fb82 100644 --- a/zerver/lib/streams.py +++ b/zerver/lib/streams.py @@ -2,7 +2,7 @@ from typing import Iterable, List, Optional, Tuple, Union from django.db.models.query import QuerySet from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from typing_extensions import TypedDict from zerver.lib.exceptions import StreamAdministratorRequired diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index edbc2abb7e..1da131f313 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -23,7 +23,7 @@ from django.core.files import File from django.core.signing import BadSignature, TimestampSigner from django.http import HttpRequest from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from jinja2 import Markup as mark_safe from PIL import ExifTags, Image, ImageOps from PIL.GifImagePlugin import GifImageFile diff --git a/zerver/lib/user_groups.py b/zerver/lib/user_groups.py index 069f79c1c2..556c27e678 100644 --- a/zerver/lib/user_groups.py +++ b/zerver/lib/user_groups.py @@ -1,7 +1,7 @@ from typing import Any, Dict, List from django.db import transaction -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.exceptions import JsonableError from zerver.models import Realm, UserGroup, UserGroupMembership, UserProfile diff --git a/zerver/lib/users.py b/zerver/lib/users.py index 2d26bd86e2..f148da9354 100644 --- a/zerver/lib/users.py +++ b/zerver/lib/users.py @@ -7,7 +7,7 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.db.models.query import QuerySet from django.forms.models import model_to_dict -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zulip_bots.custom_exceptions import ConfigValidationError from zerver.lib.avatar import avatar_url, get_avatar_field diff --git a/zerver/lib/validator.py b/zerver/lib/validator.py index 7cb06ab428..3a708cb7ae 100644 --- a/zerver/lib/validator.py +++ b/zerver/lib/validator.py @@ -34,7 +34,7 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Un import orjson from django.core.exceptions import ValidationError from django.core.validators import URLValidator, validate_email -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.request import JsonableError, ResultT from zerver.lib.types import ProfileFieldData, Validator diff --git a/zerver/lib/webhooks/common.py b/zerver/lib/webhooks/common.py index 53f5aababe..212e0f42ab 100644 --- a/zerver/lib/webhooks/common.py +++ b/zerver/lib/webhooks/common.py @@ -4,7 +4,7 @@ from typing import Any, Callable, Dict, Optional, Union from urllib.parse import unquote from django.http import HttpRequest -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.actions import ( check_send_private_message, diff --git a/zerver/lib/zcommand.py b/zerver/lib/zcommand.py index 053f57a4ee..9c66205a0d 100644 --- a/zerver/lib/zcommand.py +++ b/zerver/lib/zcommand.py @@ -1,6 +1,6 @@ from typing import Any, Dict -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.actions import do_set_user_display_setting from zerver.lib.exceptions import JsonableError diff --git a/zerver/management/commands/compilemessages.py b/zerver/management/commands/compilemessages.py index 02b53a9129..a7f2c9277e 100644 --- a/zerver/management/commands/compilemessages.py +++ b/zerver/management/commands/compilemessages.py @@ -10,8 +10,8 @@ from django.conf import settings from django.conf.locale import LANG_INFO from django.core.management.base import CommandParser from django.core.management.commands import compilemessages +from django.utils.translation import gettext as _ from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ from django.utils.translation.trans_real import to_language from pyuca import Collator diff --git a/zerver/middleware.py b/zerver/middleware.py index ad8afe4a3d..f5ded34eef 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -15,7 +15,7 @@ from django.shortcuts import render from django.utils import translation from django.utils.cache import patch_vary_headers from django.utils.deprecation import MiddlewareMixin -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.csrf import csrf_failure as html_csrf_failure from sentry_sdk import capture_exception from sentry_sdk.integrations.logging import ignore_logger diff --git a/zerver/models.py b/zerver/models.py index c2fdeb3bd7..69ff825ecb 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -32,8 +32,8 @@ from django.db.models.query import QuerySet from django.db.models.signals import post_delete, post_save from django.utils.functional import Promise from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_lazy +from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy from confirmation import settings as confirmation_settings from zerver.lib import cache @@ -363,7 +363,7 @@ class Realm(models.Model): DEFAULT_NOTIFICATION_STREAM_NAME = "general" INITIAL_PRIVATE_STREAM_NAME = "core team" - STREAM_EVENTS_NOTIFICATION_TOPIC = ugettext_lazy("stream events") + STREAM_EVENTS_NOTIFICATION_TOPIC = gettext_lazy("stream events") notifications_stream: Optional["Stream"] = models.ForeignKey( "Stream", related_name="+", @@ -397,7 +397,7 @@ class Realm(models.Model): COMMUNITY = 2 org_type: int = models.PositiveSmallIntegerField(default=CORPORATE) - UPGRADE_TEXT_STANDARD = ugettext_lazy("Available on Zulip Standard. Upgrade to access.") + UPGRADE_TEXT_STANDARD = gettext_lazy("Available on Zulip Standard. Upgrade to access.") # plan_type controls various features around resource/feature # limitations for a Zulip organization on multi-tenant installations # like Zulip Cloud. @@ -815,7 +815,7 @@ class RealmEmoji(models.Model): # ending with one of the punctuation characters. RegexValidator( regex=r"^[0-9a-z.\-_]+(? str: @@ -2338,9 +2338,9 @@ class AbstractReaction(models.Model): REALM_EMOJI = "realm_emoji" ZULIP_EXTRA_EMOJI = "zulip_extra_emoji" REACTION_TYPES = ( - (UNICODE_EMOJI, ugettext_lazy("Unicode emoji")), - (REALM_EMOJI, ugettext_lazy("Custom emoji")), - (ZULIP_EXTRA_EMOJI, ugettext_lazy("Zulip extra emoji")), + (UNICODE_EMOJI, gettext_lazy("Unicode emoji")), + (REALM_EMOJI, gettext_lazy("Custom emoji")), + (ZULIP_EXTRA_EMOJI, gettext_lazy("Zulip extra emoji")), ) reaction_type: str = models.CharField( default=UNICODE_EMOJI, choices=REACTION_TYPES, max_length=30 @@ -3457,10 +3457,10 @@ class CustomProfileField(models.Model): # and value argument. i.e. SELECT require field_data, USER require # realm as argument. SELECT_FIELD_TYPE_DATA: List[ExtendedFieldElement] = [ - (SELECT, ugettext_lazy("List of options"), validate_select_field, str, "SELECT"), + (SELECT, gettext_lazy("List of options"), validate_select_field, str, "SELECT"), ] USER_FIELD_TYPE_DATA: List[UserFieldElement] = [ - (USER, ugettext_lazy("Person picker"), check_valid_user_ids, ast.literal_eval, "USER"), + (USER, gettext_lazy("Person picker"), check_valid_user_ids, ast.literal_eval, "USER"), ] SELECT_FIELD_VALIDATORS: Dict[int, ExtendedValidator] = { @@ -3472,13 +3472,13 @@ class CustomProfileField(models.Model): FIELD_TYPE_DATA: List[FieldElement] = [ # Type, Display Name, Validator, Converter, Keyword - (SHORT_TEXT, ugettext_lazy("Short text"), check_short_string, str, "SHORT_TEXT"), - (LONG_TEXT, ugettext_lazy("Long text"), check_long_string, str, "LONG_TEXT"), - (DATE, ugettext_lazy("Date picker"), check_date, str, "DATE"), - (URL, ugettext_lazy("Link"), check_url, str, "URL"), + (SHORT_TEXT, gettext_lazy("Short text"), check_short_string, str, "SHORT_TEXT"), + (LONG_TEXT, gettext_lazy("Long text"), check_long_string, str, "LONG_TEXT"), + (DATE, gettext_lazy("Date picker"), check_date, str, "DATE"), + (URL, gettext_lazy("Link"), check_url, str, "URL"), ( EXTERNAL_ACCOUNT, - ugettext_lazy("External account"), + gettext_lazy("External account"), check_short_string, str, "EXTERNAL_ACCOUNT", diff --git a/zerver/signals.py b/zerver/signals.py index b907f507cd..80cc0bf06b 100644 --- a/zerver/signals.py +++ b/zerver/signals.py @@ -6,7 +6,7 @@ from django.contrib.auth.signals import user_logged_in, user_logged_out from django.dispatch import receiver from django.utils.timezone import get_current_timezone_name as timezone_get_current_timezone_name from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from confirmation.models import one_click_unsubscribe_link from zerver.lib.actions import do_set_zoom_token diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 4823786f57..866d78bfa4 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -30,7 +30,7 @@ from typing import ( import orjson import tornado.ioloop from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from typing_extensions import TypedDict from zerver.decorator import cachify diff --git a/zerver/tornado/exceptions.py b/zerver/tornado/exceptions.py index 17a05c907f..c777df086f 100644 --- a/zerver/tornado/exceptions.py +++ b/zerver/tornado/exceptions.py @@ -1,4 +1,4 @@ -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.exceptions import ErrorCode, JsonableError diff --git a/zerver/tornado/views.py b/zerver/tornado/views.py index a42de7d9b9..8b7c6dbd04 100644 --- a/zerver/tornado/views.py +++ b/zerver/tornado/views.py @@ -3,7 +3,7 @@ from typing import Iterable, Optional, Sequence import orjson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables, internal_notify_view, process_client from zerver.lib.response import json_error, json_success diff --git a/zerver/views/auth.py b/zerver/views/auth.py index 70f37b4d8d..1ef5e0fc0b 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -17,7 +17,7 @@ from django.shortcuts import redirect, render from django.template.response import SimpleTemplateResponse from django.urls import reverse from django.utils.http import is_safe_url -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_safe from social_django.utils import load_backend, load_strategy diff --git a/zerver/views/camo.py b/zerver/views/camo.py index c082038d92..9739a3da4f 100644 --- a/zerver/views/camo.py +++ b/zerver/views/camo.py @@ -1,7 +1,7 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, HttpResponseNotFound from django.shortcuts import redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.camo import is_camo_url_valid from zerver.lib.thumbnail import generate_thumbnail_url diff --git a/zerver/views/compatibility.py b/zerver/views/compatibility.py index ec69973566..81e171f830 100644 --- a/zerver/views/compatibility.py +++ b/zerver/views/compatibility.py @@ -2,7 +2,7 @@ import re from typing import List, Optional, Tuple from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from version import DESKTOP_MINIMUM_VERSION, DESKTOP_WARNING_VERSION from zerver.lib.response import json_error, json_success diff --git a/zerver/views/custom_profile_fields.py b/zerver/views/custom_profile_fields.py index 006156ad7c..2905164563 100644 --- a/zerver/views/custom_profile_fields.py +++ b/zerver/views/custom_profile_fields.py @@ -4,7 +4,7 @@ import orjson from django.core.exceptions import ValidationError from django.db import IntegrityError from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import human_users_only, require_realm_admin from zerver.lib.actions import ( diff --git a/zerver/views/drafts.py b/zerver/views/drafts.py index 189b8c9b20..8a9d65308e 100644 --- a/zerver/views/drafts.py +++ b/zerver/views/drafts.py @@ -3,7 +3,7 @@ from typing import Any, Dict, List, Set from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.actions import recipient_for_user_profiles from zerver.lib.addressee import get_user_profiles_by_ids diff --git a/zerver/views/events_register.py b/zerver/views/events_register.py index b3a6b1267f..75889f98f5 100644 --- a/zerver/views/events_register.py +++ b/zerver/views/events_register.py @@ -1,7 +1,7 @@ from typing import Dict, Iterable, Optional, Sequence from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.events import do_events_register from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/views/hotspots.py b/zerver/views/hotspots.py index a622a13880..6eb68ecf43 100644 --- a/zerver/views/hotspots.py +++ b/zerver/views/hotspots.py @@ -1,5 +1,5 @@ from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import human_users_only from zerver.lib.actions import do_mark_hotspot_as_read diff --git a/zerver/views/invite.py b/zerver/views/invite.py index 9c759a0605..f5b987c04b 100644 --- a/zerver/views/invite.py +++ b/zerver/views/invite.py @@ -2,7 +2,7 @@ import re from typing import List, Sequence, Set from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_member_or_admin, require_realm_admin from zerver.lib.actions import ( diff --git a/zerver/views/message_edit.py b/zerver/views/message_edit.py index a08ca1a554..a1bd3cf36c 100644 --- a/zerver/views/message_edit.py +++ b/zerver/views/message_edit.py @@ -5,7 +5,7 @@ import orjson from django.db import IntegrityError from django.http import HttpRequest, HttpResponse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables from zerver.lib.actions import ( diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py index 566c175588..4fb29a0b77 100644 --- a/zerver/views/message_fetch.py +++ b/zerver/views/message_fetch.py @@ -8,7 +8,7 @@ from django.core.exceptions import ValidationError from django.db import connection from django.http import HttpRequest, HttpResponse from django.utils.html import escape as escape_html -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from sqlalchemy import func from sqlalchemy.dialects import postgresql from sqlalchemy.engine import Connection, RowProxy diff --git a/zerver/views/message_flags.py b/zerver/views/message_flags.py index f80d974b2a..e7f5c40490 100644 --- a/zerver/views/message_flags.py +++ b/zerver/views/message_flags.py @@ -1,7 +1,7 @@ from typing import List, Optional from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables from zerver.lib.actions import ( diff --git a/zerver/views/message_send.py b/zerver/views/message_send.py index fa6284f130..d57eabc76d 100644 --- a/zerver/views/message_send.py +++ b/zerver/views/message_send.py @@ -6,7 +6,7 @@ from django.core import validators from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables from zerver.lib.actions import ( diff --git a/zerver/views/muting.py b/zerver/views/muting.py index aeeb42a09e..df7cd8b4c1 100644 --- a/zerver/views/muting.py +++ b/zerver/views/muting.py @@ -3,7 +3,7 @@ from typing import Optional from django.http import HttpRequest, HttpResponse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.actions import do_mute_topic, do_mute_user, do_unmute_topic, do_unmute_user from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/views/presence.py b/zerver/views/presence.py index 906318f949..66c48182b3 100644 --- a/zerver/views/presence.py +++ b/zerver/views/presence.py @@ -4,7 +4,7 @@ from typing import Any, Dict, Optional from django.conf import settings from django.http import HttpRequest, HttpResponse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import human_users_only from zerver.lib.actions import do_update_user_status, update_user_presence diff --git a/zerver/views/push_notifications.py b/zerver/views/push_notifications.py index 4c45739c2d..5e420de096 100644 --- a/zerver/views/push_notifications.py +++ b/zerver/views/push_notifications.py @@ -1,6 +1,6 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import human_users_only from zerver.lib.push_notifications import ( diff --git a/zerver/views/reactions.py b/zerver/views/reactions.py index 8d64c22694..5f224d3a71 100644 --- a/zerver/views/reactions.py +++ b/zerver/views/reactions.py @@ -1,7 +1,7 @@ from typing import Optional from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables from zerver.lib.actions import do_add_reaction, do_remove_reaction diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 602e0736e7..01f467076c 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -3,7 +3,7 @@ from typing import Any, Dict, Optional, Union from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.http import require_safe from confirmation.models import Confirmation, ConfirmationKeyException, get_object_from_key diff --git a/zerver/views/realm_domains.py b/zerver/views/realm_domains.py index e09acee1ac..8c8f2ee786 100644 --- a/zerver/views/realm_domains.py +++ b/zerver/views/realm_domains.py @@ -1,6 +1,6 @@ from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_realm_admin from zerver.lib.actions import do_add_realm_domain, do_change_realm_domain, do_remove_realm_domain diff --git a/zerver/views/realm_emoji.py b/zerver/views/realm_emoji.py index a00d0b76b8..5b2b265c6e 100644 --- a/zerver/views/realm_emoji.py +++ b/zerver/views/realm_emoji.py @@ -1,6 +1,6 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_member_or_admin from zerver.lib.actions import check_add_realm_emoji, do_remove_realm_emoji diff --git a/zerver/views/realm_export.py b/zerver/views/realm_export.py index 399aa9471f..ddadb741de 100644 --- a/zerver/views/realm_export.py +++ b/zerver/views/realm_export.py @@ -4,7 +4,7 @@ import orjson from django.conf import settings from django.http import HttpRequest, HttpResponse from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from analytics.models import RealmCount from zerver.decorator import require_realm_admin diff --git a/zerver/views/realm_icon.py b/zerver/views/realm_icon.py index c4b989fa92..171500ef0e 100644 --- a/zerver/views/realm_icon.py +++ b/zerver/views/realm_icon.py @@ -1,7 +1,7 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse from django.shortcuts import redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_realm_admin from zerver.lib.actions import do_change_icon_source diff --git a/zerver/views/realm_linkifiers.py b/zerver/views/realm_linkifiers.py index 1c97ecb01c..2940bd93aa 100644 --- a/zerver/views/realm_linkifiers.py +++ b/zerver/views/realm_linkifiers.py @@ -1,6 +1,6 @@ from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_realm_admin from zerver.lib.actions import do_add_linkifier, do_remove_linkifier diff --git a/zerver/views/realm_logo.py b/zerver/views/realm_logo.py index b73fd5abee..668c8ea7be 100644 --- a/zerver/views/realm_logo.py +++ b/zerver/views/realm_logo.py @@ -1,7 +1,7 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse from django.shortcuts import redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_realm_admin from zerver.lib.actions import do_change_logo_source diff --git a/zerver/views/realm_playgrounds.py b/zerver/views/realm_playgrounds.py index 6e22442e1c..b9678f2daa 100644 --- a/zerver/views/realm_playgrounds.py +++ b/zerver/views/realm_playgrounds.py @@ -2,7 +2,7 @@ import re from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_realm_admin from zerver.lib.actions import do_add_realm_playground, do_remove_realm_playground diff --git a/zerver/views/registration.py b/zerver/views/registration.py index b182a5507b..de68a00f93 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -13,7 +13,7 @@ from django.db.models import Q from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django_auth_ldap.backend import LDAPBackend, _LDAPUser from confirmation import settings as confirmation_settings diff --git a/zerver/views/streams.py b/zerver/views/streams.py index b6d3aad090..df6931b690 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -7,8 +7,8 @@ from django.contrib.auth.models import AnonymousUser from django.core.exceptions import ValidationError from django.db import transaction from django.http import HttpRequest, HttpResponse +from django.utils.translation import gettext as _ from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ from zerver.context_processors import get_valid_realm_from_request from zerver.decorator import ( diff --git a/zerver/views/submessage.py b/zerver/views/submessage.py index f58f8c4653..8e5e7cab3c 100644 --- a/zerver/views/submessage.py +++ b/zerver/views/submessage.py @@ -1,6 +1,6 @@ import orjson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables from zerver.lib.actions import do_add_submessage diff --git a/zerver/views/thumbnail.py b/zerver/views/thumbnail.py index 98c5c33a3a..bb9b474ddd 100644 --- a/zerver/views/thumbnail.py +++ b/zerver/views/thumbnail.py @@ -3,7 +3,7 @@ from typing import Optional from django.http import HttpRequest, HttpResponse, HttpResponseForbidden from django.shortcuts import redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.lib.request import REQ, has_request_variables from zerver.lib.thumbnail import generate_thumbnail_url diff --git a/zerver/views/typing.py b/zerver/views/typing.py index bd4d03384d..c09de7a46d 100644 --- a/zerver/views/typing.py +++ b/zerver/views/typing.py @@ -1,7 +1,7 @@ from typing import List from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables from zerver.lib.actions import check_send_typing_notification diff --git a/zerver/views/upload.py b/zerver/views/upload.py index 8def9e8e32..d0ec8e0ae3 100644 --- a/zerver/views/upload.py +++ b/zerver/views/upload.py @@ -4,7 +4,7 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, HttpResponseNotFound from django.shortcuts import redirect from django.utils.cache import patch_cache_control -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django_sendfile import sendfile from zerver.lib.response import json_error, json_success diff --git a/zerver/views/user_groups.py b/zerver/views/user_groups.py index aac204d347..9015267b69 100644 --- a/zerver/views/user_groups.py +++ b/zerver/views/user_groups.py @@ -1,7 +1,7 @@ from typing import Sequence from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_member_or_admin, require_user_group_edit_permission from zerver.lib.actions import ( diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index 5bdc1f7dab..551a6b8450 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -8,8 +8,8 @@ from django.http import HttpRequest, HttpResponse 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 django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy from confirmation.models import ( Confirmation, @@ -46,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 = 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: diff --git a/zerver/views/users.py b/zerver/views/users.py index cb2ee265fb..613bfc15a6 100644 --- a/zerver/views/users.py +++ b/zerver/views/users.py @@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional, Union from django.conf import settings from django.http import HttpRequest, HttpResponse from django.shortcuts import redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import require_member_or_admin, require_realm_admin from zerver.forms import PASSWORD_TOO_WEAK_ERROR, CreateUserForm diff --git a/zerver/views/video_calls.py b/zerver/views/video_calls.py index fcd91ab7e8..1dc7c5ede7 100644 --- a/zerver/views/video_calls.py +++ b/zerver/views/video_calls.py @@ -14,7 +14,7 @@ from django.http import HttpRequest, HttpResponse from django.middleware import csrf from django.shortcuts import redirect, render from django.utils.crypto import constant_time_compare, salted_hmac -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST diff --git a/zerver/views/zephyr.py b/zerver/views/zephyr.py index f948b0ad28..c5ba8004c1 100644 --- a/zerver/views/zephyr.py +++ b/zerver/views/zephyr.py @@ -8,7 +8,7 @@ from typing import Optional import orjson from django.conf import settings from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import authenticated_json_view from zerver.lib.ccache import make_ccache diff --git a/zerver/webhooks/front/view.py b/zerver/webhooks/front/view.py index c14c3712d7..b328165f67 100644 --- a/zerver/webhooks/front/view.py +++ b/zerver/webhooks/front/view.py @@ -1,7 +1,7 @@ from typing import Any, Dict, Tuple from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/webhooks/ifttt/view.py b/zerver/webhooks/ifttt/view.py index 1cb87e4f07..f6a9be6a0a 100644 --- a/zerver/webhooks/ifttt/view.py +++ b/zerver/webhooks/ifttt/view.py @@ -1,7 +1,7 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/webhooks/librato/view.py b/zerver/webhooks/librato/view.py index 01842ef92a..3065d8059c 100644 --- a/zerver/webhooks/librato/view.py +++ b/zerver/webhooks/librato/view.py @@ -3,7 +3,7 @@ from typing import Any, Callable, Dict, List, Tuple import orjson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/webhooks/newrelic/view.py b/zerver/webhooks/newrelic/view.py index 4385945b38..174e17785a 100644 --- a/zerver/webhooks/newrelic/view.py +++ b/zerver/webhooks/newrelic/view.py @@ -2,7 +2,7 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/webhooks/pivotal/view.py b/zerver/webhooks/pivotal/view.py index 17739e626e..8109449cb2 100644 --- a/zerver/webhooks/pivotal/view.py +++ b/zerver/webhooks/pivotal/view.py @@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Tuple import orjson from defusedxml.ElementTree import fromstring as xml_fromstring from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.exceptions import UnsupportedWebhookEventType diff --git a/zerver/webhooks/slack/view.py b/zerver/webhooks/slack/view.py index b04f5fd2e5..339ceb8409 100644 --- a/zerver/webhooks/slack/view.py +++ b/zerver/webhooks/slack/view.py @@ -1,5 +1,5 @@ from django.http import HttpRequest -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.actions import check_send_stream_message diff --git a/zerver/webhooks/slack_incoming/view.py b/zerver/webhooks/slack_incoming/view.py index 847b39adaa..516d91b8be 100644 --- a/zerver/webhooks/slack_incoming/view.py +++ b/zerver/webhooks/slack_incoming/view.py @@ -4,7 +4,7 @@ from typing import Any, Dict, Optional import orjson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.exceptions import InvalidJSONError diff --git a/zerver/webhooks/wordpress/view.py b/zerver/webhooks/wordpress/view.py index 3ebc034aff..91342ad96c 100644 --- a/zerver/webhooks/wordpress/view.py +++ b/zerver/webhooks/wordpress/view.py @@ -1,6 +1,6 @@ # Webhooks for external integrations. from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/webhooks/zabbix/view.py b/zerver/webhooks/zabbix/view.py index f51f76e21f..c5b9f527aa 100644 --- a/zerver/webhooks/zabbix/view.py +++ b/zerver/webhooks/zabbix/view.py @@ -1,7 +1,7 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import REQ, has_request_variables, webhook_view from zerver.lib.actions import send_rate_limited_pm_notification_to_bot_owner diff --git a/zerver/webhooks/zapier/view.py b/zerver/webhooks/zapier/view.py index 65c854088a..65cc966c70 100644 --- a/zerver/webhooks/zapier/view.py +++ b/zerver/webhooks/zapier/view.py @@ -1,7 +1,7 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from zerver.decorator import webhook_view from zerver.lib.request import REQ, has_request_variables diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index e1965473c7..3a8e6e2e73 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -40,8 +40,8 @@ from django.conf import settings from django.db import connection from django.db.models import F from django.utils.timezone import now as timezone_now +from django.utils.translation import gettext as _ from django.utils.translation import override as override_language -from django.utils.translation import ugettext as _ from sentry_sdk import add_breadcrumb, configure_scope from zulip_bots.lib import extract_query_without_mention diff --git a/zilencer/views.py b/zilencer/views.py index a3a69d0bd2..d9e7272f31 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -7,8 +7,8 @@ from django.core.validators import URLValidator, validate_email from django.db import IntegrityError, transaction from django.http import HttpRequest, HttpResponse from django.utils import timezone -from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext as err_ +from django.utils.translation import gettext as _ +from django.utils.translation import gettext as err_ from django.views.decorators.csrf import csrf_exempt from analytics.lib.counts import COUNT_STATS diff --git a/zproject/backends.py b/zproject/backends.py index 0d88f459a2..68822ae1e8 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -30,7 +30,7 @@ from django.dispatch import Signal, receiver from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.shortcuts import render from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django_auth_ldap.backend import LDAPBackend, LDAPReverseEmailSearch, _LDAPUser, ldap_error from lxml.etree import XMLSyntaxError from onelogin.saml2.errors import OneLogin_Saml2_Error