当前位置: 首页>>代码示例>>Python>>正文


Python translation.get_language_bidi方法代码示例

本文整理汇总了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 '' 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:5,代码来源:i18n.py

示例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 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:11,代码来源:context_processors.py

示例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) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:31,代码来源:widgets.py

示例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',
    } 
开发者ID:mozilla,项目名称:sugardough,代码行数:8,代码来源:context_processors.py

示例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(),
    } 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:9,代码来源:context_processors.py

示例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 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:36,代码来源:widgets.py

示例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 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:13,代码来源:views.py

示例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" 
开发者ID:evernote,项目名称:zing,代码行数:7,代码来源:override.py

示例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 
开发者ID:evernote,项目名称:zing,代码行数:11,代码来源:override.py

示例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()
    } 
开发者ID:edx,项目名称:course-discovery,代码行数:8,代码来源:context_processors.py


注:本文中的django.utils.translation.get_language_bidi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。