1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #18149 -- Changed language codes for Chinese

Language codes for Chinese are zh_Hans (Simplified) and zh_Hant (Traditional).
Added support for browsers that still send the deprecated language codes.

Thanks to Olli Wang for the report.
This commit is contained in:
Bouke Haarsma
2013-11-04 18:31:34 +01:00
parent cb2c3ce154
commit c0a2388a1c
17 changed files with 2593 additions and 2 deletions

View File

@@ -127,6 +127,8 @@ LANGUAGES = (
('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')),
)

View File

@@ -485,6 +485,18 @@ LANG_INFO = {
'name': 'Simplified Chinese',
'name_local': '简体中文',
},
'zh-hans': {
'bidi': False,
'code': 'zh-hans',
'name': 'Simplified Chinese',
'name_local': '简体中文',
},
'zh-hant': {
'bidi': False,
'code': 'zh-hant',
'name': 'Traditional Chinese',
'name_local': '繁體中文',
},
'zh-tw': {
'bidi': False,
'code': 'zh-tw',

View File

@@ -1,5 +1,8 @@
# This file is distributed under the same license as the Django package.
#
# This is the *old* Simplified Chinese translation of Django
# For future updates please use the translation in the "zh_Hans" directory.
#
# Translators:
# Jannis Leidel <jannis@leidel.info>, 2011.
# Kevin Shi <leiarix@gmail.com>, 2012.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

View File

@@ -0,0 +1,24 @@
# -*- 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 =
# TIME_FORMAT =
# DATETIME_FORMAT =
# YEAR_MONTH_FORMAT =
# MONTH_DAY_FORMAT =
# SHORT_DATE_FORMAT =
# SHORT_DATETIME_FORMAT =
# FIRST_DAY_OF_WEEK =
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
# DATE_INPUT_FORMATS =
# TIME_INPUT_FORMATS =
# DATETIME_INPUT_FORMATS =
# DECIMAL_SEPARATOR =
# THOUSAND_SEPARATOR =
# NUMBER_GROUPING =

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

View File

@@ -0,0 +1,24 @@
# -*- 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 =
# TIME_FORMAT =
# DATETIME_FORMAT =
# YEAR_MONTH_FORMAT =
# MONTH_DAY_FORMAT =
# SHORT_DATE_FORMAT =
# SHORT_DATETIME_FORMAT =
# FIRST_DAY_OF_WEEK =
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
# DATE_INPUT_FORMATS =
# TIME_INPUT_FORMATS =
# DATETIME_INPUT_FORMATS =
# DECIMAL_SEPARATOR =
# THOUSAND_SEPARATOR =
# NUMBER_GROUPING =

View File

@@ -1,5 +1,8 @@
# This file is distributed under the same license as the Django package.
#
# This is the *old* Traditional Chinese translation of Django
# For future updates please use the translation in the "zh_Hant" directory.
#
# Translators:
# <ilay@ilay.tw>, 2012.
# Jannis Leidel <jannis@leidel.info>, 2011.

View File

@@ -202,6 +202,17 @@ def activate(language):
language and installs it as the current translation object for the current
thread.
"""
if isinstance(language, basestring):
if language == 'zh-cn':
warnings.warn(
"The use of the language code 'zh-cn' is deprecated. "
"Please use the 'zh-hans' translation instead.",
PendingDeprecationWarning, stacklevel=2)
elif language == 'zh-tw':
warnings.warn(
"The use of the language code 'zh-tw' is deprecated. "
"Please use the 'zh-hant' translation instead.",
PendingDeprecationWarning, stacklevel=2)
_active.value = translation(language)
@@ -399,6 +410,12 @@ def get_supported_language_variant(lang_code, supported=None, strict=False):
If `strict` is False (the default), the function will look for an alternative
country-specific variant when the currently checked is not found.
"""
# some browsers use deprecated language codes -- #18419
if lang_code == 'zh-cn' and 'zh-hans' in supported:
return 'zh-hans'
elif lang_code == 'zh-tw' and 'zh-hant' in supported:
return 'zh-hant'
if supported is None:
from django.conf import settings
supported = OrderedDict(settings.LANGUAGES)