MCPcopy
hub / github.com/django/django / get_select2_language

Function get_select2_language

django/contrib/admin/widgets.py:504–514  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

502
503
504def get_select2_language():
505 lang_code = get_language()
506 supported_code = SELECT2_TRANSLATIONS.get(lang_code)
507 if supported_code is None and lang_code is not None:
508 # If 'zh-hant-tw' is not supported, try subsequent language codes i.e.
509 # 'zh-hant' and 'zh'.
510 i = None
511 while (i := lang_code.rfind("-", 0, i)) > -1:
512 if supported_code := SELECT2_TRANSLATIONS.get(lang_code[:i]):
513 return supported_code
514 return supported_code
515
516
517class AutocompleteMixin:

Callers 1

__init__Method · 0.85

Calls 2

get_languageFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected