summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-05 12:45:08 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-14 17:50:04 +0100
commit52a238ddf2ceb5211daa2ab23c626473685729b5 (patch)
tree86e5c395fe022ad89faf7ed3e815a77d7606838d
parent810f037b29402f848a766f6900b4ebfbaf64cc88 (diff)
Refs #30165 -- Removed ugettext(), ugettext_lazy(), ugettext_noop(), ungettext(), and ungettext_lazy() per deprecation timeline.
-rw-r--r--django/core/management/commands/makemessages.py3
-rw-r--r--django/utils/translation/__init__.py69
-rw-r--r--docs/releases/4.0.txt3
-rw-r--r--tests/i18n/tests.py44
4 files changed, 4 insertions, 115 deletions
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 7aa184b02d..04bb6c958b 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -550,9 +550,6 @@ class Command(BaseCommand):
'--keyword=gettext_noop',
'--keyword=gettext_lazy',
'--keyword=ngettext_lazy:1,2',
- '--keyword=ugettext_noop',
- '--keyword=ugettext_lazy',
- '--keyword=ungettext_lazy:1,2',
'--keyword=pgettext:1c,2',
'--keyword=npgettext:1c,2,3',
'--keyword=pgettext_lazy:1c,2',
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 0dd2503cee..8e6b8ec0f8 100644
--- a/django/utils/translation/__init__.py
+++ b/django/utils/translation/__init__.py
@@ -1,12 +1,10 @@
"""
Internationalization support.
"""
-import warnings
from contextlib import ContextDecorator
from decimal import ROUND_UP, Decimal
from django.utils.autoreload import autoreload_started, file_changed
-from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.functional import lazy
from django.utils.regex_helper import _lazy_re_compile
@@ -16,9 +14,7 @@ __all__ = [
'get_language_info', 'get_language_bidi',
'check_for_language', 'to_language', 'to_locale', 'templatize',
'gettext', 'gettext_lazy', 'gettext_noop',
- 'ugettext', 'ugettext_lazy', 'ugettext_noop',
'ngettext', 'ngettext_lazy',
- 'ungettext', 'ungettext_lazy',
'pgettext', 'pgettext_lazy',
'npgettext', 'npgettext_lazy',
'LANGUAGE_SESSION_KEY',
@@ -77,53 +73,14 @@ def gettext_noop(message):
return _trans.gettext_noop(message)
-def ugettext_noop(message):
- """
- A legacy compatibility wrapper for Unicode handling on Python 2.
- Alias of gettext_noop() since Django 2.0.
- """
- warnings.warn(
- 'django.utils.translation.ugettext_noop() is deprecated in favor of '
- 'django.utils.translation.gettext_noop().',
- RemovedInDjango40Warning, stacklevel=2,
- )
- return gettext_noop(message)
-
-
def gettext(message):
return _trans.gettext(message)
-def ugettext(message):
- """
- A legacy compatibility wrapper for Unicode handling on Python 2.
- Alias of gettext() since Django 2.0.
- """
- warnings.warn(
- 'django.utils.translation.ugettext() is deprecated in favor of '
- 'django.utils.translation.gettext().',
- RemovedInDjango40Warning, stacklevel=2,
- )
- return gettext(message)
-
-
def ngettext(singular, plural, number):
return _trans.ngettext(singular, plural, number)
-def ungettext(singular, plural, number):
- """
- A legacy compatibility wrapper for Unicode handling on Python 2.
- Alias of ngettext() since Django 2.0.
- """
- warnings.warn(
- 'django.utils.translation.ungettext() is deprecated in favor of '
- 'django.utils.translation.ngettext().',
- RemovedInDjango40Warning, stacklevel=2,
- )
- return ngettext(singular, plural, number)
-
-
def pgettext(context, message):
return _trans.pgettext(context, message)
@@ -136,19 +93,6 @@ gettext_lazy = lazy(gettext, str)
pgettext_lazy = lazy(pgettext, str)
-def ugettext_lazy(message):
- """
- A legacy compatibility wrapper for Unicode handling on Python 2. Has been
- Alias of gettext_lazy since Django 2.0.
- """
- warnings.warn(
- 'django.utils.translation.ugettext_lazy() is deprecated in favor of '
- 'django.utils.translation.gettext_lazy().',
- RemovedInDjango40Warning, stacklevel=2,
- )
- return gettext_lazy(message)
-
-
def lazy_number(func, resultclass, number=None, **kwargs):
if isinstance(number, int):
kwargs['number'] = number
@@ -204,19 +148,6 @@ def ngettext_lazy(singular, plural, number=None):
return lazy_number(ngettext, str, singular=singular, plural=plural, number=number)
-def ungettext_lazy(singular, plural, number=None):
- """
- A legacy compatibility wrapper for Unicode handling on Python 2.
- An alias of ungettext_lazy() since Django 2.0.
- """
- warnings.warn(
- 'django.utils.translation.ungettext_lazy() is deprecated in favor of '
- 'django.utils.translation.ngettext_lazy().',
- RemovedInDjango40Warning, stacklevel=2,
- )
- return ngettext_lazy(singular, plural, number)
-
-
def npgettext_lazy(context, singular, plural, number=None):
return lazy_number(npgettext, str, context=context, singular=singular, plural=plural, number=number)
diff --git a/docs/releases/4.0.txt b/docs/releases/4.0.txt
index 9865f59d6e..b5b4d343aa 100644
--- a/docs/releases/4.0.txt
+++ b/docs/releases/4.0.txt
@@ -251,6 +251,9 @@ to remove usage of these features.
* ``django.utils.encoding.force_text()`` and ``smart_text()`` are removed.
+* ``django.utils.translation.ugettext()``, ``ugettext_lazy()``,
+ ``ugettext_noop()``, ``ungettext()``, and ``ungettext_lazy()`` are removed.
+
See :ref:`deprecated-features-3.1` for details on these changes, including how
to remove usage of these features.
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 99e6febb28..9498103585 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -22,7 +22,6 @@ from django.test import (
RequestFactory, SimpleTestCase, TestCase, override_settings,
)
from django.utils import translation
-from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.formats import (
date_format, get_format, get_format_modules, iter_format_modules, localize,
localize_input, reset_format_cache, sanitize_separators, time_format,
@@ -34,8 +33,7 @@ from django.utils.translation import (
get_language, get_language_bidi, get_language_from_request,
get_language_info, gettext, gettext_lazy, ngettext, ngettext_lazy,
npgettext, npgettext_lazy, pgettext, round_away_from_one, to_language,
- to_locale, trans_null, trans_real, ugettext, ugettext_lazy, ugettext_noop,
- ungettext, ungettext_lazy,
+ to_locale, trans_null, trans_real,
)
from django.utils.translation.reloader import (
translation_file_changed, watch_for_translation_changes,
@@ -69,46 +67,6 @@ def patch_formats(lang, **settings):
class TranslationTests(SimpleTestCase):
-
- @translation.override('de')
- def test_legacy_aliases(self):
- """
- Pre-Django 2.0 aliases with u prefix are still available.
- """
- msg = (
- 'django.utils.translation.ugettext_noop() is deprecated in favor '
- 'of django.utils.translation.gettext_noop().'
- )
- with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
- self.assertEqual(ugettext_noop("Image"), "Image")
- msg = (
- 'django.utils.translation.ugettext() is deprecated in favor of '
- 'django.utils.translation.gettext().'
- )
- with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
- self.assertEqual(ugettext("Image"), "Bild")
- msg = (
- 'django.utils.translation.ugettext_lazy() is deprecated in favor '
- 'of django.utils.translation.gettext_lazy().'
- )
- with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
- self.assertEqual(ugettext_lazy("Image"), gettext_lazy("Image"))
- msg = (
- 'django.utils.translation.ungettext() is deprecated in favor of '
- 'django.utils.translation.ngettext().'
- )
- with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
- self.assertEqual(ungettext("%d year", "%d years", 0) % 0, "0 Jahre")
- msg = (
- 'django.utils.translation.ungettext_lazy() is deprecated in favor '
- 'of django.utils.translation.ngettext_lazy().'
- )
- with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
- self.assertEqual(
- ungettext_lazy("%d year", "%d years", 0) % 0,
- ngettext_lazy("%d year", "%d years", 0) % 0,
- )
-
@translation.override('fr')
def test_plural(self):
"""