From 86ba75b0904ec4cba2945881f48a628c66b9d0c5 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 2 Apr 2011 08:41:51 +0000 Subject: [PATCH] Advanced deprecations in django.utils.translation. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15987 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/translation/__init__.py | 2 +- django/utils/translation/trans_null.py | 18 ---------- django/utils/translation/trans_real.py | 48 -------------------------- 3 files changed, 1 insertion(+), 67 deletions(-) diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py index 992e1c9664..9433ad897f 100644 --- a/django/utils/translation/__init__.py +++ b/django/utils/translation/__init__.py @@ -55,7 +55,7 @@ class Trans(object): warnings.warn("Translations in the project directory " "aren't supported anymore. Use the " "LOCALE_PATHS setting instead.", - PendingDeprecationWarning) + DeprecationWarning) else: from django.utils.translation import trans_null as trans setattr(self, real_name, getattr(trans, real_name)) diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py index a8bebad942..5622c03f55 100644 --- a/django/utils/translation/trans_null.py +++ b/django/utils/translation/trans_null.py @@ -58,21 +58,3 @@ def to_locale(language): def get_language_from_request(request): return settings.LANGUAGE_CODE - -# get_date_formats and get_partial_date_formats aren't used anymore by Django -# but are kept for backward compatibility. -def get_date_formats(): - warnings.warn( - '`django.utils.translation.get_date_formats` is deprecated. ' - 'Please update your code to use the new i18n aware formatting.', - DeprecationWarning - ) - return settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT - -def get_partial_date_formats(): - warnings.warn( - '`django.utils.translation.get_partial_date_formats` is deprecated. ' - 'Please update your code to use the new i18n aware formatting.', - DeprecationWarning - ) - return settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index f17eaf802b..34bd7d0f46 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -551,51 +551,3 @@ def parse_accept_lang_header(lang_string): result.append((lang, priority)) result.sort(key=lambda k: k[1], reverse=True) return result - -# get_date_formats and get_partial_date_formats aren't used anymore by Django -# and are kept for backward compatibility. -# Note, it's also important to keep format names marked for translation. -# For compatibility we still want to have formats on translation catalogs. -# That makes template code like {{ my_date|date:_('DATE_FORMAT') }} still work -def get_date_formats(): - """ - Checks whether translation files provide a translation for some technical - message ID to store date and time formats. If it doesn't contain one, the - formats provided in the settings will be used. - """ - warnings.warn( - "'django.utils.translation.get_date_formats' is deprecated. " - "Please update your code to use the new i18n aware formatting.", - DeprecationWarning - ) - from django.conf import settings - date_format = ugettext('DATE_FORMAT') - datetime_format = ugettext('DATETIME_FORMAT') - time_format = ugettext('TIME_FORMAT') - if date_format == 'DATE_FORMAT': - date_format = settings.DATE_FORMAT - if datetime_format == 'DATETIME_FORMAT': - datetime_format = settings.DATETIME_FORMAT - if time_format == 'TIME_FORMAT': - time_format = settings.TIME_FORMAT - return date_format, datetime_format, time_format - -def get_partial_date_formats(): - """ - Checks whether translation files provide a translation for some technical - message ID to store partial date formats. If it doesn't contain one, the - formats provided in the settings will be used. - """ - warnings.warn( - "'django.utils.translation.get_partial_date_formats' is deprecated. " - "Please update your code to use the new i18n aware formatting.", - DeprecationWarning - ) - from django.conf import settings - year_month_format = ugettext('YEAR_MONTH_FORMAT') - month_day_format = ugettext('MONTH_DAY_FORMAT') - if year_month_format == 'YEAR_MONTH_FORMAT': - year_month_format = settings.YEAR_MONTH_FORMAT - if month_day_format == 'MONTH_DAY_FORMAT': - month_day_format = settings.MONTH_DAY_FORMAT - return year_month_format, month_day_format