浏览代码

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

Sebastian Sangervasi 7 年之前
父节点
当前提交
5c4c87e55c
共有 3 个文件被更改,包括 9 次插入12 次删除
  1. 6 7
      django/utils/translation/trans_real.py
  2. 2 2
      docs/topics/i18n/translation.txt
  3. 1 3
      tests/i18n/patterns/tests.py

+ 6 - 7
django/utils/translation/trans_real.py

@@ -416,11 +416,11 @@ def get_languages():
 @functools.lru_cache(maxsize=1000)
 @functools.lru_cache(maxsize=1000)
 def get_supported_language_variant(lang_code, strict=False):
 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.
     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,
     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
     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):
 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)
     regex_match = language_code_prefix_re.match(path)
     if not regex_match:
     if not regex_match:

+ 2 - 2
docs/topics/i18n/translation.txt

@@ -1410,8 +1410,8 @@ function will return the URL in the active language. Example::
 
 
 .. warning::
 .. 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
     :func:`~django.conf.urls.i18n.i18n_patterns`), to avoid the possibility
     that a carelessly translated URL causes a collision with a non-translated
     that a carelessly translated URL causes a collision with a non-translated
     URL pattern.
     URL pattern.

+ 1 - 3
tests/i18n/patterns/tests.py

@@ -293,9 +293,7 @@ class URLRedirectWithoutTrailingSlashSettingTests(URLTestCaseBase):
 
 
 
 
 class URLResponseTests(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):
     def test_not_prefixed_with_prefix(self):
         response = self.client.get('/en/not-prefixed/')
         response = self.client.get('/en/not-prefixed/')
         self.assertEqual(response.status_code, 404)
         self.assertEqual(response.status_code, 404)