Changed "language-code" to the more commonly used "language code".

This commit is contained in:
Sebastian Sangervasi 2018-02-21 09:30:56 -05:00 committed by Tim Graham
parent 33ac036a6b
commit 5c4c87e55c
3 changed files with 9 additions and 12 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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)