summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Sangervasi <s.ebastian.sangervasi@gmail.com>2018-02-21 09:30:56 -0500
committerTim Graham <timograham@gmail.com>2018-02-21 09:31:05 -0500
commit5c4c87e55c096f093a2323bf05b57cc06d93a257 (patch)
tree9a0c1303650fb44a7e527a056b97ea9332ee2d53
parent33ac036a6bcab64ef93d0185f7b55eb57e559d6e (diff)
Changed "language-code" to the more commonly used "language code".
-rw-r--r--django/utils/translation/trans_real.py13
-rw-r--r--docs/topics/i18n/translation.txt4
-rw-r--r--tests/i18n/patterns/tests.py4
3 files changed, 9 insertions, 12 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 5ced5a73c1..7d6ef125b5 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -416,11 +416,11 @@ def get_languages():
@functools.lru_cache(maxsize=1000)
def get_supported_language_variant(lang_code, strict=False):
"""
- Return the language-code that's listed in supported languages, possibly
+ Return the language code that's listed in supported languages, possibly
selecting a more generic variant. Raise LookupError if nothing is found.
- If `strict` is False (the default), look for an alternative
- country-specific variant when the currently checked is not found.
+ If `strict` is False (the default), look for a country-specific variant
+ when neither the language code nor its generic variant is found.
lru_cache should have a maxsize to prevent from memory exhaustion attacks,
as the provided language codes are taken from the HTTP request. See also
@@ -450,11 +450,10 @@ def get_supported_language_variant(lang_code, strict=False):
def get_language_from_path(path, strict=False):
"""
- Return the language-code if there is a valid language-code
- found in the `path`.
+ Return the language code if there's a valid language code found in `path`.
- If `strict` is False (the default), the function will look for an alternative
- country-specific variant when the currently checked is not found.
+ If `strict` is False (the default), look for a country-specific variant
+ when neither the language code nor its generic variant is found.
"""
regex_match = language_code_prefix_re.match(path)
if not regex_match:
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
index 6f890dbbaa..31ee71a05e 100644
--- a/docs/topics/i18n/translation.txt
+++ b/docs/topics/i18n/translation.txt
@@ -1410,8 +1410,8 @@ function will return the URL in the active language. Example::
.. warning::
- In most cases, it's best to use translated URLs only within a
- language-code-prefixed block of patterns (using
+ In most cases, it's best to use translated URLs only within a language code
+ prefixed block of patterns (using
:func:`~django.conf.urls.i18n.i18n_patterns`), to avoid the possibility
that a carelessly translated URL causes a collision with a non-translated
URL pattern.
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index 2423614f08..6ed2c4ffeb 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -293,9 +293,7 @@ class URLRedirectWithoutTrailingSlashSettingTests(URLTestCaseBase):
class URLResponseTests(URLTestCaseBase):
- """
- Tests if the response has the right language-code.
- """
+ """Tests if the response has the correct language code."""
def test_not_prefixed_with_prefix(self):
response = self.client.get('/en/not-prefixed/')
self.assertEqual(response.status_code, 404)