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:
@@ -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')),
|
||||
)
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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.
|
||||
|
||||
BIN
django/conf/locale/zh_Hans/LC_MESSAGES/django.mo
Normal file
BIN
django/conf/locale/zh_Hans/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
1224
django/conf/locale/zh_Hans/LC_MESSAGES/django.po
Normal file
1224
django/conf/locale/zh_Hans/LC_MESSAGES/django.po
Normal file
File diff suppressed because it is too large
Load Diff
0
django/conf/locale/zh_Hans/__init__.py
Normal file
0
django/conf/locale/zh_Hans/__init__.py
Normal file
24
django/conf/locale/zh_Hans/formats.py
Normal file
24
django/conf/locale/zh_Hans/formats.py
Normal 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 =
|
||||
BIN
django/conf/locale/zh_Hant/LC_MESSAGES/django.mo
Normal file
BIN
django/conf/locale/zh_Hant/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
1227
django/conf/locale/zh_Hant/LC_MESSAGES/django.po
Normal file
1227
django/conf/locale/zh_Hant/LC_MESSAGES/django.po
Normal file
File diff suppressed because it is too large
Load Diff
0
django/conf/locale/zh_Hant/__init__.py
Normal file
0
django/conf/locale/zh_Hant/__init__.py
Normal file
24
django/conf/locale/zh_Hant/formats.py
Normal file
24
django/conf/locale/zh_Hant/formats.py
Normal 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 =
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user