本文整理汇总了Python中django.utils.translation.get_language_info方法的典型用法代码示例。如果您正苦于以下问题:Python translation.get_language_info方法的具体用法?Python translation.get_language_info怎么用?Python translation.get_language_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.translation
的用法示例。
在下文中一共展示了translation.get_language_info方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_get_language_info
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def do_get_language_info(parser, token):
"""
This will store the language information dictionary for the given language
code in a context variable.
Usage::
{% get_language_info for LANGUAGE_CODE as l %}
{{ l.code }}
{{ l.name }}
{{ l.name_local }}
{{ l.bidi|yesno:"bi-directional,uni-directional" }}
"""
args = token.split_contents()
if len(args) != 5 or args[1] != 'for' or args[3] != 'as':
raise TemplateSyntaxError("'%s' requires 'for string as variable' (got %r)" % (args[0], args[1:]))
return GetLanguageInfoNode(parser.compile_filter(args[2]), args[4])
示例2: do_get_language_info
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def do_get_language_info(parser, token):
"""
This will store the language information dictionary for the given language
code in a context variable.
Usage::
{% get_language_info for LANGUAGE_CODE as l %}
{{ l.code }}
{{ l.name }}
{{ l.name_translated }}
{{ l.name_local }}
{{ l.bidi|yesno:"bi-directional,uni-directional" }}
"""
args = token.split_contents()
if len(args) != 5 or args[1] != 'for' or args[3] != 'as':
raise TemplateSyntaxError("'%s' requires 'for string as variable' (got %r)" % (args[0], args[1:]))
return GetLanguageInfoNode(parser.compile_filter(args[2]), args[4])
示例3: do_get_language_info
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def do_get_language_info(parser, token):
"""
Store the language information dictionary for the given language code in a
context variable.
Usage::
{% get_language_info for LANGUAGE_CODE as l %}
{{ l.code }}
{{ l.name }}
{{ l.name_translated }}
{{ l.name_local }}
{{ l.bidi|yesno:"bi-directional,uni-directional" }}
"""
args = token.split_contents()
if len(args) != 5 or args[1] != 'for' or args[3] != 'as':
raise TemplateSyntaxError("'%s' requires 'for string as variable' (got %r)" % (args[0], args[1:]))
return GetLanguageInfoNode(parser.compile_filter(args[2]), args[4])
示例4: do_get_language_info
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def do_get_language_info(parser, token):
"""
This will store the language information dictionary for the given language
code in a context variable.
Usage::
{% get_language_info for LANGUAGE_CODE as l %}
{{ l.code }}
{{ l.name }}
{{ l.name_local }}
{{ l.bidi|yesno:"bi-directional,uni-directional" }}
"""
args = token.contents.split()
if len(args) != 5 or args[1] != 'for' or args[3] != 'as':
raise TemplateSyntaxError("'%s' requires 'for string as variable' (got %r)" % (args[0], args[1:]))
return GetLanguageInfoNode(args[2], args[4])
示例5: render
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def render(self, context):
lang_code = self.lang_code.resolve(context)
context[self.variable] = translation.get_language_info(lang_code)
return ''
示例6: get_language_info
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def get_language_info(self, 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))
示例7: language_name
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def language_name(lang_code):
return translation.get_language_info(lang_code)['name']
示例8: language_bidi
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def language_bidi(lang_code):
return translation.get_language_info(lang_code)['bidi']
示例9: language_name_local
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def language_name_local(lang_code):
return translation.get_language_info(lang_code)['name_local']
示例10: get_language_info
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
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))
示例11: get_language_info_list
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_info [as 别名]
def get_language_info_list(langs):
return [get_language_info(lang) for lang in langs]