Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5db8d617
Kaydet (Commit)
5db8d617
authored
Eyl 03, 2018
tarafından
David
Kaydeden (comit)
Carlton Gibson
Eyl 03, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29713 -- Added check that LANGUAGE_CODE uses standard language id format.
üst
ee52044a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
0 deletions
+80
-0
__init__.py
django/core/checks/__init__.py
+1
-0
registry.py
django/core/checks/registry.py
+1
-0
translation.py
django/core/checks/translation.py
+25
-0
checks.txt
docs/ref/checks.txt
+13
-0
test_translation.py
tests/check_framework/test_translation.py
+39
-0
tests.py
tests/i18n/tests.py
+1
-0
No files found.
django/core/checks/__init__.py
Dosyayı görüntüle @
5db8d617
...
...
@@ -12,6 +12,7 @@ import django.core.checks.security.base # NOQA isort:skip
import
django.core.checks.security.csrf
# NOQA isort:skip
import
django.core.checks.security.sessions
# NOQA isort:skip
import
django.core.checks.templates
# NOQA isort:skip
import
django.core.checks.translation
# NOQA isort:skip
import
django.core.checks.urls
# NOQA isort:skip
...
...
django/core/checks/registry.py
Dosyayı görüntüle @
5db8d617
...
...
@@ -15,6 +15,7 @@ class Tags:
security
=
'security'
signals
=
'signals'
templates
=
'templates'
translation
=
'translation'
urls
=
'urls'
...
...
django/core/checks/translation.py
0 → 100644
Dosyayı görüntüle @
5db8d617
import
re
from
django.conf
import
settings
from
django.utils.translation.trans_real
import
language_code_re
from
.
import
Error
,
Tags
,
register
@register
(
Tags
.
translation
)
def
check_setting_language_code
(
app_configs
,
**
kwargs
):
"""
Errors if language code is in the wrong format. Language codes specification outlined by
https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags
"""
match_result
=
re
.
match
(
language_code_re
,
settings
.
LANGUAGE_CODE
)
errors
=
[]
if
not
match_result
:
errors
.
append
(
Error
(
"LANGUAGE_CODE in settings.py is {}. It should be in the form ll or ll-cc where ll is the language and cc "
"is the country. Examples include: it, de-at, es, pt-br. The full set of language codes specifications is "
"outlined by https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags"
.
format
(
settings
.
LANGUAGE_CODE
),
id
=
"translation.E001"
,
))
return
errors
docs/ref/checks.txt
Dosyayı görüntüle @
5db8d617
...
...
@@ -86,6 +86,7 @@ Django's system checks are organized using the following tags:
* ``staticfiles``: Checks :mod:`django.contrib.staticfiles` configuration.
* ``templates``: Checks template related configuration.
* ``urls``: Checks URL configuration.
* ``translation``: Checks language formats used for translation.
Some checks may be registered with multiple tags.
...
...
@@ -449,6 +450,18 @@ The following checks are performed on your URL configuration:
* **urls.E006**: The :setting:`MEDIA_URL`/ :setting:`STATIC_URL` setting must
end with a slash.
Translation
-----------
The following checks are performed on your translation configuration:
* **translation.E001**: LANGUAGE_CODE in settings.py is ``<language_code>``.
It should be in the form ll or ll-cc where ll is the language and cc is the
country. Examples include: ``it``, ``de-at``, ``es``, ``pt-br``. The full
set of language codes specifications is outlined by
https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags
``contrib`` app checks
======================
...
...
tests/check_framework/test_translation.py
0 → 100644
Dosyayı görüntüle @
5db8d617
from
django.core.checks.translation
import
check_setting_language_code
from
django.test
import
SimpleTestCase
,
override_settings
class
TranslationCheckTests
(
SimpleTestCase
):
@override_settings
(
LANGUAGE_CODE
=
"eu"
)
def
test_valid_language_code_format_ll_only
(
self
):
result
=
check_setting_language_code
(
None
)
self
.
assertEqual
(
len
(
result
),
0
)
@override_settings
(
LANGUAGE_CODE
=
"eü"
)
def
test_invalid_language_code_format_ll_only
(
self
):
result
=
check_setting_language_code
(
None
)
self
.
assertEqual
(
len
(
result
),
1
)
error
=
result
[
0
]
self
.
assertEqual
(
error
.
id
,
'translation.E001'
)
self
.
assertEqual
(
error
.
msg
,
(
"LANGUAGE_CODE in settings.py is eü. It should be in the form ll or ll-cc where ll is the language and cc "
"is the country. Examples include: it, de-at, es, pt-br. The full set of language codes specifications is "
"outlined by https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags"
))
@override_settings
(
LANGUAGE_CODE
=
"en-US"
)
def
test_valid_language_code_format_ll_cc
(
self
):
result
=
check_setting_language_code
(
None
)
self
.
assertEqual
(
len
(
result
),
0
)
@override_settings
(
LANGUAGE_CODE
=
"en_US"
)
def
test_invalid_language_code_format_ll_cc
(
self
):
result
=
check_setting_language_code
(
None
)
self
.
assertEqual
(
len
(
result
),
1
)
error
=
result
[
0
]
self
.
assertEqual
(
error
.
id
,
'translation.E001'
)
self
.
assertEqual
(
error
.
msg
,
(
"LANGUAGE_CODE in settings.py is en_US. It should be in the form ll or ll-cc where ll is the language and "
"cc is the country. Examples include: it, de-at, es, pt-br. The full set of language codes specifications "
"is outlined by https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags"
))
tests/i18n/tests.py
Dosyayı görüntüle @
5db8d617
...
...
@@ -1649,6 +1649,7 @@ class CountrySpecificLanguageTests(SimpleTestCase):
self
.
assertTrue
(
check_for_language
(
'en'
))
self
.
assertTrue
(
check_for_language
(
'en-us'
))
self
.
assertTrue
(
check_for_language
(
'en-US'
))
self
.
assertFalse
(
check_for_language
(
'en_US'
))
self
.
assertTrue
(
check_for_language
(
'be'
))
self
.
assertTrue
(
check_for_language
(
'be@latin'
))
self
.
assertTrue
(
check_for_language
(
'sr-RS@latin'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment