Python django.conf.settings 模块,LANGUAGES_BIDI 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.conf.settings.LANGUAGES_BIDI

项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def lang_data(LANGUAGE_CODE, **kwargs):
    # These are needed for i18n
    from django.http import HttpRequest
    from django.views.i18n import javascript_catalog

    LANGUAGE_BIDI = LANGUAGE_CODE.split('-')[0] in \
        settings.LANGUAGES_BIDI

    request = HttpRequest()
    request.GET['language'] = LANGUAGE_CODE

    # Add some JavaScript data
    content = 'var LANGUAGE_CODE = "%s";\n' % LANGUAGE_CODE
    content += 'var LANGUAGE_BIDI = ' + \
        (LANGUAGE_BIDI and 'true' or 'false') + ';\n'
    content += javascript_catalog(request,
        packages=settings.INSTALLED_APPS).content

    # The hgettext() function just calls gettext() internally, but
    # it won't get indexed by makemessages.
    content += '\nwindow.hgettext = function(text) { return gettext(text); };\n'
    # Add a similar hngettext() function
    content += 'window.hngettext = function(singular, plural, count) { return ngettext(singular, plural, count); };\n'

    return content