本文整理汇总了Python中django.utils.translation.get_language_bidi方法的典型用法代码示例。如果您正苦于以下问题:Python translation.get_language_bidi方法的具体用法?Python translation.get_language_bidi怎么用?Python translation.get_language_bidi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.translation
的用法示例。
在下文中一共展示了translation.get_language_bidi方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def render(self, context):
context[self.variable] = translation.get_language_bidi()
return ''
示例2: i18n
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def i18n(request):
from django.utils import translation
context_extras = {}
context_extras['LANGUAGES'] = settings.LANGUAGES
context_extras['LANGUAGE_CODE'] = translation.get_language()
context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()
return context_extras
示例3: render
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def render(self, name, value, attrs=None):
# If a string reaches here (via a validation error on another
# field) then just reconstruct the Geometry.
if isinstance(value, six.string_types):
value = self.deserialize(value)
if value:
# Check that srid of value and map match
if value.srid != self.map_srid:
try:
ogr = value.ogr
ogr.transform(self.map_srid)
value = ogr
except gdal.GDALException as err:
logger.error(
"Error transforming geometry from srid '%s' to srid '%s' (%s)" % (
value.srid, self.map_srid, err)
)
context = self.build_attrs(
attrs,
name=name,
module='geodjango_%s' % name.replace('-', '_'), # JS-safe
serialized=self.serialize(value),
geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
STATIC_URL=settings.STATIC_URL,
LANGUAGE_BIDI=translation.get_language_bidi(),
)
return loader.render_to_string(self.template_name, context)
示例4: i18n
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def i18n(request):
return {
'LANGUAGES': django_settings.LANGUAGES,
'LANG': translation.get_language(),
'DIR': 'rtl' if translation.get_language_bidi() else 'ltr',
}
示例5: i18n
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def i18n(request):
from django.utils import translation
return {
'LANGUAGES': settings.LANGUAGES,
'LANGUAGE_CODE': translation.get_language(),
'LANGUAGE_BIDI': translation.get_language_bidi(),
}
示例6: get_context
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
# If a string reaches here (via a validation error on another
# field) then just reconstruct the Geometry.
if value and isinstance(value, str):
value = self.deserialize(value)
if value:
# Check that srid of value and map match
if value.srid and value.srid != self.map_srid:
try:
ogr = value.ogr
ogr.transform(self.map_srid)
value = ogr
except gdal.GDALException as err:
logger.error(
"Error transforming geometry from srid '%s' to srid '%s' (%s)",
value.srid, self.map_srid, err
)
if attrs is None:
attrs = {}
build_attrs_kwargs = {
'name': name,
'module': 'geodjango_%s' % name.replace('-', '_'), # JS-safe
'serialized': self.serialize(value),
'geom_type': gdal.OGRGeomType(self.attrs['geom_type']),
'STATIC_URL': settings.STATIC_URL,
'LANGUAGE_BIDI': translation.get_language_bidi(),
}
build_attrs_kwargs.update(attrs)
context.update(self.build_attrs(self.attrs, build_attrs_kwargs))
return context
示例7: get_meta_data
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def get_meta_data(self):
model = registry.get_ra_model_by_name(self.kwargs['base_model'])
verbose_name = model._meta.verbose_name
verbose_name_plural = model._meta.verbose_name_plural
is_bidi = get_language_bidi()
if is_bidi:
page_title = '%s %s' % (ugettext('reports'), model._meta.verbose_name_plural)
else:
page_title = '%s %s' % (model._meta.verbose_name_plural, ugettext('reports'))
opts = model._meta
return verbose_name, verbose_name_plural, page_title, opts
示例8: get_language_bidi
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def get_language_bidi():
"""Override for Django's get_language_bidi that's aware of more RTL
languages.
"""
return gettext.language_dir(translation.get_language()) == "rtl"
示例9: hijack_translation
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def hijack_translation():
"""Sabotage Django's fascist linguistical regime."""
# Override functions that check if language is known to Django
translation.check_for_language = lambda lang_code: True
trans_real.check_for_language = lambda lang_code: True
translation.get_language_from_request = get_language_from_request
# Override django's inadequate bidi detection
translation.get_language_bidi = get_language_bidi
示例10: core
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import get_language_bidi [as 别名]
def core(_request):
""" Site-wide context processor. """
return {
'platform_name': settings.PLATFORM_NAME,
'language_bidi': get_language_bidi()
}