summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorSebastian Sangervasi <s.ebastian.sangervasi@gmail.com>2017-06-27 16:50:26 -0700
committerTim Graham <timograham@gmail.com>2018-02-23 14:49:00 -0500
commit7905815510fb1eae99010ccc0039249d981a121c (patch)
treeea3dbc6433091d66e87f5007ad3ab61f687ec895 /docs/ref
parent5033999153f7303a18d94ea2f08ed78545c0f3df (diff)
Fixed #27449 -- Added django.utils.translation.get_supported_language_variant().
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/utils.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index d6127e3fed..581156b5d8 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -1092,6 +1092,23 @@ functions without the ``u``.
for whether its path begins with a language code listed in the
:setting:`LANGUAGES` setting.
+.. function:: get_supported_language_variant(lang_code, strict=False)
+
+ .. versionadded:: 2.1
+
+ Returns ``lang_code`` if it's in the :setting:`LANGUAGES` setting, possibly
+ selecting a more generic variant. For example, ``'es'`` is returned if
+ ``lang_code`` is ``'es-ar'`` and ``'es'`` is in :setting:`LANGUAGES` but
+ ``'es-ar'`` isn't.
+
+ If ``strict`` is ``False`` (the default), a country-specific variant may
+ be returned when neither the language code nor its generic variant is found.
+ For example, if only ``'es-co'`` is in :setting:`LANGUAGES`, that's
+ returned for ``lang_code``\s like ``'es'`` and ``'es-ar'``. Those matches
+ aren't returned if ``strict=True``.
+
+ Raises :exc:`LookupError` if nothing is found.
+
.. function:: to_locale(language)
Turns a language name (en-us) into a locale name (en_US).