コード例 #1
0
def i18n(request):
    from djangocg.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
コード例 #2
0
ファイル: widgets.py プロジェクト: timothyclemans/djangocg
from djangocg.forms.widgets import Textarea
from djangocg.template import loader, Context
from djangocg.templatetags.static import static
from djangocg.utils import six
from djangocg.utils import translation

from djangocg.contrib.gis.gdal import OGRException
from djangocg.contrib.gis.geos import GEOSGeometry, GEOSException, fromstr

# Creating a template context that contains Django settings
# values needed by admin map templates.
geo_context = Context({'LANGUAGE_BIDI' : translation.get_language_bidi()})

class OpenLayersWidget(Textarea):
    """
    Renders an OpenLayers map using the WKT of the geometry.
    """
    def render(self, name, value, attrs=None):
        # Update the template parameters with any attributes passed in.
        if attrs: self.params.update(attrs)

        # Defaulting the WKT value to a blank string -- this
        # will be tested in the JavaScript and the appropriate
        # interface will be constructed.
        self.params['wkt'] = ''

        # If a string reaches here (via a validation error on another
        # field) then just reconstruct the Geometry.
        if isinstance(value, six.string_types):
            try:
                value = GEOSGeometry(value)
コード例 #3
0
ファイル: i18n.py プロジェクト: timothyclemans/djangocg
 def render(self, context):
     context[self.variable] = translation.get_language_bidi()
     return ''