Removed deprecated Chinese language codes; refs #18149.

This commit is contained in:
Tim Graham 2015-01-09 15:08:16 -05:00
parent b845951fd4
commit f0a1df0b01
13 changed files with 12 additions and 2913 deletions

View File

@ -130,10 +130,8 @@ LANGUAGES = (
('uk', gettext_noop('Ukrainian')),
('ur', gettext_noop('Urdu')),
('vi', gettext_noop('Vietnamese')),
('zh-cn', gettext_noop('Simplified Chinese')),
('zh-hans', gettext_noop('Simplified Chinese')),
('zh-hant', gettext_noop('Traditional Chinese')),
('zh-tw', gettext_noop('Traditional Chinese')),
)
# Languages using BiDi (right-to-left) layout

View File

@ -511,10 +511,6 @@ LANG_INFO = {
},
'zh-cn': {
'fallback': ['zh-hans'],
'bidi': False,
'code': 'zh-cn',
'name': 'Simplified Chinese',
'name_local': '简体中文',
},
'zh-hans': {
'bidi': False,
@ -542,9 +538,5 @@ LANG_INFO = {
},
'zh-tw': {
'fallback': ['zh-hant'],
'bidi': False,
'code': 'zh-tw',
'name': 'Traditional Chinese',
'name_local': '繁體中文',
},
}

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'Y年n月j日' # 2016年9月5日
TIME_FORMAT = 'H:i' # 20:45
DATETIME_FORMAT = 'Y年n月j日 H:i' # 2016年9月5日 20:45
YEAR_MONTH_FORMAT = 'Y年n月' # 2016年9月
MONTH_DAY_FORMAT = 'm月j日' # 9月5日
SHORT_DATE_FORMAT = 'Y年n月j日' # 2016年9月5日
SHORT_DATETIME_FORMAT = 'Y年n月j日 H:i' # 2016年9月5日 20:45
FIRST_DAY_OF_WEEK = 1 # 星期一 (Monday)
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
DATE_INPUT_FORMATS = (
'%Y/%m/%d', # '2016/09/05'
'%Y-%m-%d', # '2016-09-05'
'%Y年%n月%j日', # '2016年9月5日'
)
TIME_INPUT_FORMATS = (
'%H:%M', # '20:45'
'%H:%M:%S', # '20:45:29'
'%H:%M:%S.%f', # '20:45:29.000200'
)
DATETIME_INPUT_FORMATS = (
'%Y/%m/%d %H:%M', # '2016/09/05 20:45'
'%Y-%m-%d %H:%M', # '2016-09-05 20:45'
'%Y年%n月%j日 %H:%M', # '2016年9月5日 14:45'
'%Y/%m/%d %H:%M:%S', # '2016/09/05 20:45:29'
'%Y-%m-%d %H:%M:%S', # '2016-09-05 20:45:29'
'%Y年%n月%j日 %H:%M:%S', # '2016年9月5日 20:45:29'
'%Y/%m/%d %H:%M:%S.%f', # '2016/09/05 20:45:29.000200'
'%Y-%m-%d %H:%M:%S.%f', # '2016-09-05 20:45:29.000200'
'%Y年%n月%j日 %H:%n:%S.%f', # '2016年9月5日 20:45:29.000200'
)
DECIMAL_SEPARATOR = '.'
THOUSAND_SEPARATOR = ''
NUMBER_GROUPING = 4

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'Y年n月j日' # 2016年9月5日
TIME_FORMAT = 'H:i' # 20:45
DATETIME_FORMAT = 'Y年n月j日 H:i' # 2016年9月5日 20:45
YEAR_MONTH_FORMAT = 'Y年n月' # 2016年9月
MONTH_DAY_FORMAT = 'm月j日' # 9月5日
SHORT_DATE_FORMAT = 'Y年n月j日' # 2016年9月5日
SHORT_DATETIME_FORMAT = 'Y年n月j日 H:i' # 2016年9月5日 20:45
FIRST_DAY_OF_WEEK = 1 # 星期一 (Monday)
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
DATE_INPUT_FORMATS = (
'%Y/%m/%d', # '2016/09/05'
'%Y-%m-%d', # '2016-09-05'
'%Y年%n月%j日', # '2016年9月5日'
)
TIME_INPUT_FORMATS = (
'%H:%M', # '20:45'
'%H:%M:%S', # '20:45:29'
'%H:%M:%S.%f', # '20:45:29.000200'
)
DATETIME_INPUT_FORMATS = (
'%Y/%m/%d %H:%M', # '2016/09/05 20:45'
'%Y-%m-%d %H:%M', # '2016-09-05 20:45'
'%Y年%n月%j日 %H:%M', # '2016年9月5日 14:45'
'%Y/%m/%d %H:%M:%S', # '2016/09/05 20:45:29'
'%Y-%m-%d %H:%M:%S', # '2016-09-05 20:45:29'
'%Y年%n月%j日 %H:%M:%S', # '2016年9月5日 20:45:29'
'%Y/%m/%d %H:%M:%S.%f', # '2016/09/05 20:45:29.000200'
'%Y-%m-%d %H:%M:%S.%f', # '2016-09-05 20:45:29.000200'
'%Y年%n月%j日 %H:%n:%S.%f', # '2016年9月5日 20:45:29.000200'
)
DECIMAL_SEPARATOR = '.'
THOUSAND_SEPARATOR = ''
NUMBER_GROUPING = 4

View File

@ -15,7 +15,6 @@ from django.conf.locale import LANG_INFO
from django.core.exceptions import AppRegistryNotReady
from django.core.signals import setting_changed
from django.dispatch import receiver
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_text
from django.utils._os import upath
from django.utils.safestring import mark_safe, SafeData
@ -46,12 +45,6 @@ language_code_re = re.compile(r'^[a-z]{1,8}(?:-[a-z0-9]{1,8})*$', re.IGNORECASE)
language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)')
# some browsers use deprecated locales. refs #18419
_DJANGO_DEPRECATED_LOCALES = {
'zh-cn': 'zh-hans',
'zh-tw': 'zh-hant',
}
@receiver(setting_changed)
def reset_cache(**kwargs):
@ -213,11 +206,6 @@ def activate(language):
"""
if not language:
return
if language in _DJANGO_DEPRECATED_LOCALES:
msg = ("The use of the language code '%s' is deprecated. "
"Please use the '%s' translation instead.")
warnings.warn(msg % (language, _DJANGO_DEPRECATED_LOCALES[language]),
RemovedInDjango19Warning, stacklevel=2)
_active.value = translation(language)

View File

@ -4,9 +4,9 @@ import os
import unittest
import warnings
from django.test import SimpleTestCase, override_settings
from django.test import SimpleTestCase
from django.test.utils import reset_warning_registry
from django.utils import six, translation
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.encoding import force_text
@ -175,24 +175,6 @@ class RenameMethodsTests(SimpleTestCase):
])
@override_settings(USE_I18N=True)
class DeprecatedChineseLanguageCodes(SimpleTestCase):
def test_deprecation_warning(self):
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter('always')
with translation.override('zh-cn'):
pass
with translation.override('zh-tw'):
pass
msgs = [str(warning.message) for warning in recorded]
self.assertEqual(msgs, [
"The use of the language code 'zh-cn' is deprecated. "
"Please use the 'zh-hans' translation instead.",
"The use of the language code 'zh-tw' is deprecated. "
"Please use the 'zh-hant' translation instead.",
])
class DeprecatingSimpleTestCaseUrls(unittest.TestCase):
def test_deprecation(self):

View File

@ -972,11 +972,11 @@ class MiscTests(TestCase):
self.assertEqual(g(r), 'es')
# This tests the following scenario: there isn't a main language (zh)
# translation of Django but there is a translation to variation (zh_CN)
# the user sets zh-cn as the preferred language, it should be selected
# translation of Django but there is a translation to variation (zh-hans)
# the user sets zh-hans as the preferred language, it should be selected
# by Django without falling back nor ignoring it.
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,de'}
self.assertEqual(g(r), 'zh-cn')
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-hans,de'}
self.assertEqual(g(r), 'zh-hans')
r.META = {'HTTP_ACCEPT_LANGUAGE': 'NL'}
self.assertEqual('nl', g(r))
@ -1022,32 +1022,6 @@ class MiscTests(TestCase):
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-tw,en'}
self.assertEqual(g(r), 'zh-hant')
@override_settings(
LANGUAGES=(
('en', 'English'),
('zh-cn', 'Simplified Chinese'),
('zh-hans', 'Simplified Chinese'),
('zh-hant', 'Traditional Chinese'),
('zh-tw', 'Traditional Chinese'),
)
)
def test_backwards_compatibility(self):
"""
While the old chinese language codes are being deprecated, they should
still work as before the new language codes were introduced.
refs #18419 -- this is explicitly for backwards compatibility and
should be removed in Django 1.9
"""
g = get_language_from_request
r = self.rf.get('/')
r.COOKIES = {}
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,en'}
self.assertEqual(g(r), 'zh-cn')
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-tw,en'}
self.assertEqual(g(r), 'zh-tw')
def test_special_fallback_language(self):
"""
Some languages may have special fallbacks that don't follow the simple
@ -1085,12 +1059,12 @@ class MiscTests(TestCase):
self.assertEqual(g(r), 'es')
# This tests the following scenario: there isn't a main language (zh)
# translation of Django but there is a translation to variation (zh_CN)
# the user sets zh-cn as the preferred language, it should be selected
# translation of Django but there is a translation to variation (zh-hans)
# the user sets zh-hans as the preferred language, it should be selected
# by Django without falling back nor ignoring it.
r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'zh-cn'}
r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'zh-hans'}
r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'}
self.assertEqual(g(r), 'zh-cn')
self.assertEqual(g(r), 'zh-hans')
def test_get_language_from_path_real(self):
g = trans_real.get_language_from_path
@ -1238,8 +1212,8 @@ class TestLanguageInfo(TestCase):
"""
li = get_language_info('zh-my')
self.assertEqual(li['code'], 'zh-hans')
li = get_language_info('zh-cn')
self.assertEqual(li['code'], 'zh-cn')
li = get_language_info('zh-hans')
self.assertEqual(li['code'], 'zh-hans')
class MultipleLocaleActivationTests(TestCase):