NDOJ/judge/jinja2/language.py

19 lines
535 B
Python
Raw Normal View History

2020-01-21 06:35:58 +00:00
from django.utils import translation
from . import registry
2022-05-14 17:57:27 +00:00
@registry.function("language_info")
2020-01-21 06:35:58 +00:00
def get_language_info(language):
# ``language`` is either a language code string or a sequence
# with the language code as its first item
if len(language[0]) > 1:
return translation.get_language_info(language[0])
else:
return translation.get_language_info(str(language))
2022-05-14 17:57:27 +00:00
@registry.function("language_info_list")
2020-01-21 06:35:58 +00:00
def get_language_info_list(langs):
return [get_language_info(lang) for lang in langs]