Python django.utils.translation.get_language_bidi() Examples
The following are 24
code examples of django.utils.translation.get_language_bidi().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.utils.translation
, or try the search function
.
Example #1
Source File: context_processors.py From course-discovery with GNU Affero General Public License v3.0 | 5 votes |
def core(_request): """ Site-wide context processor. """ return { 'platform_name': settings.PLATFORM_NAME, 'language_bidi': get_language_bidi() }
Example #2
Source File: context_processors.py From missioncontrol with Mozilla Public License 2.0 | 5 votes |
def i18n(request): return { 'LANGUAGES': django_settings.LANGUAGES, 'LANG': translation.get_language(), 'DIR': 'rtl' if translation.get_language_bidi() else 'ltr', }
Example #3
Source File: context_processors.py From python2017 with MIT License | 5 votes |
def i18n(request): from django.utils import translation return { 'LANGUAGES': settings.LANGUAGES, 'LANGUAGE_CODE': translation.get_language(), 'LANGUAGE_BIDI': translation.get_language_bidi(), }
Example #4
Source File: i18n.py From python2017 with MIT License | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #5
Source File: widgets.py From openhgsenti with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: context_processors.py From openhgsenti with Apache License 2.0 | 5 votes |
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
Example #7
Source File: i18n.py From openhgsenti with Apache License 2.0 | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #8
Source File: context_processors.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
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
Example #9
Source File: i18n.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #10
Source File: context_processors.py From feedthefox with Mozilla Public License 2.0 | 5 votes |
def i18n(request): return { 'LANGUAGES': django_settings.LANGUAGES, 'LANG': translation.get_language(), 'DIR': 'rtl' if translation.get_language_bidi() else 'ltr', }
Example #11
Source File: context_processors.py From python with Apache License 2.0 | 5 votes |
def i18n(request): from django.utils import translation return { 'LANGUAGES': settings.LANGUAGES, 'LANGUAGE_CODE': translation.get_language(), 'LANGUAGE_BIDI': translation.get_language_bidi(), }
Example #12
Source File: i18n.py From python with Apache License 2.0 | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #13
Source File: i18n.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #14
Source File: context_processors.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def i18n(request): from django.utils import translation return { 'LANGUAGES': settings.LANGUAGES, 'LANGUAGE_CODE': translation.get_language(), 'LANGUAGE_BIDI': translation.get_language_bidi(), }
Example #15
Source File: i18n.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #16
Source File: override.py From zing with GNU General Public License v3.0 | 5 votes |
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
Example #17
Source File: override.py From zing with GNU General Public License v3.0 | 5 votes |
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"
Example #18
Source File: views.py From django-ra-erp with GNU Affero General Public License v3.0 | 5 votes |
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
Example #19
Source File: widgets.py From bioforum with MIT License | 5 votes |
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
Example #20
Source File: context_processors.py From bioforum with MIT License | 5 votes |
def i18n(request): from django.utils import translation return { 'LANGUAGES': settings.LANGUAGES, 'LANGUAGE_CODE': translation.get_language(), 'LANGUAGE_BIDI': translation.get_language_bidi(), }
Example #21
Source File: i18n.py From bioforum with MIT License | 5 votes |
def render(self, context): context[self.variable] = translation.get_language_bidi() return ''
Example #22
Source File: context_processors.py From sugardough with Apache License 2.0 | 5 votes |
def i18n(request): return { 'LANGUAGES': django_settings.LANGUAGES, 'LANG': translation.get_language(), 'DIR': 'rtl' if translation.get_language_bidi() else 'ltr', }
Example #23
Source File: widgets.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
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)
Example #24
Source File: context_processors.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
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