當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。