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


Python i18n.JavaScriptCatalog类代码示例

本文整理汇总了Python中django.views.i18n.JavaScriptCatalog的典型用法代码示例。如果您正苦于以下问题:Python JavaScriptCatalog类的具体用法?Python JavaScriptCatalog怎么用?Python JavaScriptCatalog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JavaScriptCatalog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_javascript_catalog

 def _create_javascript_catalog(self, locale, domain, packages):
     activate(locale)
     if django.VERSION < (2, 0):
         catalog, plural = get_javascript_catalog(locale, domain, packages)
         response = render_javascript_catalog(catalog, plural)
     else:
         catalog = JavaScriptCatalog()
         packages = get_packages(packages)
         # we are passing None as the request, as the request object is
         # currently not used by django
         response = catalog.get(self, None, domain=domain, packages=packages)
     return force_text(response.content)
开发者ID:zyegfryed,项目名称:django-statici18n,代码行数:12,代码来源:compilejsi18n.py

示例2: generate_widget_js

def generate_widget_js(lang):
    code = []
    with language(lang):
        # Provide isolation
        code.append('(function (siteglobals) {\n')
        code.append('var module = {}, exports = {};\n')
        code.append('var lang = "%s";\n' % lang)

        c = JavaScriptCatalog()
        c.translation = DjangoTranslation(lang, domain='djangojs')
        catalog, plural = c.get_catalog(), c.get_plural()

        str_wl = (
            'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su',
            'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
            'September', 'October', 'November', 'December'
        )
        catalog = dict((k, v) for k, v in catalog.items() if k.startswith('widget\u0004') or k in str_wl)
        template = Engine().from_string(js_catalog_template)
        context = Context({
            'catalog_str': indent(json.dumps(
                catalog, sort_keys=True, indent=2)) if catalog else None,
            'formats_str': indent(json.dumps(
                get_formats(), sort_keys=True, indent=2)),
            'plural': plural,
        })
        code.append(template.render(context))

        files = [
            'vuejs/vue.js' if settings.DEBUG else 'vuejs/vue.min.js',
            'vuejs/vue-resize.min.js',
            'pretixpresale/js/widget/docready.js',
            'pretixpresale/js/widget/floatformat.js',
            'pretixpresale/js/widget/widget.js',
        ]
        for fname in files:
            f = finders.find(fname)
            with open(f, 'r') as fp:
                code.append(fp.read())

        if settings.DEBUG:
            code.append('})(this);\n')
        else:
            # Do not expose debugging variables
            code.append('})({});\n')
    return ''.join(code)
开发者ID:,项目名称:,代码行数:46,代码来源:

示例3: create_js_catalog_url

        def create_js_catalog_url():
            packages = ['django_mptt_admin']
            url_pattern = r'^jsi18n/$'

            if django.VERSION[0:2] <= (1, 9):
                return create_url(url_pattern, 'jsi18n', javascript_catalog, kwargs=dict(packages=packages), cacheable=True)
            else:
                return create_url(url_pattern, 'jsi18n', JavaScriptCatalog.as_view(packages=packages), cacheable=True)
开发者ID:raagin,项目名称:django-mptt-admin,代码行数:8,代码来源:admin.py

示例4: i18n_javascript

    def i18n_javascript(self, request, extra_context=None):
        """
        Displays the i18n JavaScript that the Django admin requires.

        `extra_context` is unused but present for consistency with the other
        admin views.
        """
        return JavaScriptCatalog.as_view(packages=['django.contrib.admin'])(request)
开发者ID:AleksejManaev,项目名称:django,代码行数:8,代码来源:sites.py

示例5: test_i18n_unknown_package_error

 def test_i18n_unknown_package_error(self):
     view = JavaScriptCatalog.as_view()
     request = RequestFactory().get('/')
     msg = 'Invalid package(s) provided to JavaScriptCatalog: unknown_package'
     with self.assertRaisesMessage(ValueError, msg):
         view(request, packages='unknown_package')
     msg += ',unknown_package2'
     with self.assertRaisesMessage(ValueError, msg):
         view(request, packages='unknown_package+unknown_package2')
开发者ID:ArielinIChen,项目名称:django,代码行数:9,代码来源:test_i18n.py

示例6: handle

 def handle(self, *args, **options):
     fake_request = HttpRequest()
     fake_request.method = 'GET'
     for lang in settings.AMO_LANGUAGES:
         filename = os.path.join(
             settings.STATICFILES_DIRS[0], 'js', 'i18n', '%s.js' % lang)
         with translation.override(lang):
             response = JavaScriptCatalog.as_view()(fake_request)
             with open(filename, 'w') as f:
                 f.write(force_text(response.content))
开发者ID:diox,项目名称:olympia,代码行数:10,代码来源:generate_jsi18n_files.py

示例7: get_urls

    def get_urls(self):
        """
        Adds a url to move nodes to this admin
        """
        urls = super(TreeAdmin, self).get_urls()

        if django.VERSION < (1, 10):
            from django.views.i18n import javascript_catalog
            jsi18n_url = url(r'^jsi18n/$', javascript_catalog, {'packages': ('treebeard',)})
        else:
            from django.views.i18n import JavaScriptCatalog

            jsi18n_url = url(r'^jsi18n/$',
                JavaScriptCatalog.as_view(packages=['treebeard']),
                name='javascript-catalog'
            )

        new_urls = [
            url('^move/$', self.admin_site.admin_view(self.move_node), ),
            jsi18n_url,
        ]
        return new_urls + urls
开发者ID:tabo,项目名称:django-treebeard,代码行数:22,代码来源:admin.py

示例8: get_urls

    def get_urls(self):
        urls = super(SubscriptionAdmin, self).get_urls()

        my_urls = [
            url(r'^import/$',
                self._wrap(self.subscribers_import),
                name=self._view_name('import')),
            url(r'^import/confirm/$',
                self._wrap(self.subscribers_import_confirm),
                name=self._view_name('import_confirm')),
        ]
        # Translated JS strings - these should be app-wide but are
        # only used in this part of the admin. For now, leave them here.
        if HAS_CBV_JSCAT:
            my_urls.append(url(r'^jsi18n/$',
                JavaScriptCatalog.as_view(packages=('newsletter',)),
                name='newsletter_js18n'))
        else:
            my_urls.append(url(r'^jsi18n/$',
                javascript_catalog,
                {'packages': ('newsletter',)},
                name='newsletter_js18n'))

        return my_urls + urls
开发者ID:sha-red,项目名称:django-newsletter,代码行数:24,代码来源:admin.py

示例9: url

from django.conf.urls import url
from django.views.i18n import JavaScriptCatalog

from . import admin_views
from . import fiber_admin

urlpatterns = [
    url(r'^page/(?P<id>\d+)/move_up/$', admin_views.page_move_up, name='fiber_page_move_up'),
    url(r'^page/(?P<id>\d+)/move_down/$', admin_views.page_move_down, name='fiber_page_move_down'),
    url(r'^login/$', admin_views.fiber_login, name='fiber_login'),
    url(r'^pages.json$', admin_views.pages_json, name='pages_json'),
    url(r'^fiber_admin/', fiber_admin.site.urls),
    url(r'^jsi18n/$', JavaScriptCatalog.as_view(), {'packages': 'fiber'}, name='fiber_i18n'),
]
开发者ID:ridethepony,项目名称:django-fiber,代码行数:14,代码来源:admin_urls.py

示例10: path

from kirppu.views import index, MobileRedirect

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

js_packages = (
    'kirppu',
)

last_modified_date = timezone.now()

urlpatterns = [
    path('', index, name='home'),
    path(r'kirppu/', include('kirppu.urls', namespace="kirppu")),
    path(r'accounts/', include('kirppuauth.urls', namespace="kirppuauth")),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    path(r'admin/', admin.site.urls),
    path(r'i18n/', include('django.conf.urls.i18n')),
    path(r'jsi18n/', last_modified(lambda req, **kw: last_modified_date)(
        JavaScriptCatalog.as_view(packages=js_packages)),
        name="javascript-catalog"),
    re_path(r'^m/?$', MobileRedirect.as_view()),
    path('', include('kompassi_oauth2.urls')),
]
开发者ID:jlaunonen,项目名称:kirppu,代码行数:29,代码来源:urls.py

示例11: url

import django
from django.conf.urls import url

try:
    from django.views.i18n import JavaScriptCatalog
    javascript_catalog = JavaScriptCatalog.as_view()
except ImportError:  # Django < 2.0
    from django.views.i18n import javascript_catalog

from jet.views import add_bookmark_view, remove_bookmark_view, toggle_application_pin_view, model_lookup_view


app_name = 'jet'

urlpatterns = [
    url(
        r'^add_bookmark/$',
        add_bookmark_view,
        name='add_bookmark'
    ),
    url(
        r'^remove_bookmark/$',
        remove_bookmark_view,
        name='remove_bookmark'
    ),
    url(
        r'^toggle_application_pin/$',
        toggle_application_pin_view,
        name='toggle_application_pin'
    ),
    url(
开发者ID:urosn74,项目名称:django-jet,代码行数:31,代码来源:urls.py

示例12: i18n_javascript

 def i18n_javascript(self, request):
     """
     Displays the i18n JavaScript that the Django admin requires.
     """
     return JavaScriptCatalog.as_view(packages=["django.contrib.admin"])(request)
开发者ID:homberger,项目名称:django,代码行数:5,代码来源:sites.py

示例13: url

router.register(r'softwares', SoftwareViewSet)
router.register(r'hardwares', HardwareViewSet)
router.register(r'installations', InstallationViewSet)

admin.autodiscover()

urlpatterns = [
    url(r'^$', views.home, name="home"),
    url(r'^api/', include(router.urls)),
    url(r'^report$', views.generic_report, name='generic_report'),
    url(r'^create-event/$', views.create_event, name="create_event"),
    url(r'^events/', include('manager.urls.events'), name='events'),
    url(r'^tags/', include('manager.urls.event_tags'), name='event_tags'),
    url(r'^admin/', include(admin.site.urls), name='admin'),
    url(r'^forms/', include(forms_builder.forms.urls)),
    url(r'^ckeditor/', include('ckeditor_uploader.urls'), name='ckeditor'),
    url(r'^accounts/profile/',
        TemplateView.as_view(template_name='account/profile.html'),
        name="user_profile"),
    url(r'^accounts/', include('allauth.urls')),
    url(r'^captcha/', include('captcha.urls')),
    url(r'^jsi18n/$', JavaScriptCatalog.as_view(),
        {'domain': 'djangojs', 'packages': None}, name='javascript-catalog'),
    url(r'^i18n/', include('django.conf.urls.i18n')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls))]
开发者ID:GNUtn,项目名称:eventoL,代码行数:30,代码来源:urls.py

示例14: url

    url(r"^dashboard/", include((dashboard_urls, "dashboard"), namespace="dashboard")),
    url(r"^graphql/", csrf_exempt(GraphQLView.as_view(schema=schema)), name="api"),
    url(
        r"^sitemap\.xml$",
        sitemap,
        {"sitemaps": sitemaps},
        name="django.contrib.sitemaps.views.sitemap",
    ),
    url(r"^i18n/$", set_language, name="set_language"),
    url("", include("social_django.urls", namespace="social")),
]

translatable_urlpatterns = [
    url(r"^", include(core_urls)),
    url(r"^checkout/", include((checkout_urls, "checkout"), namespace="checkout")),
    url(r"^jsi18n/$", JavaScriptCatalog.as_view(), name="javascript-catalog"),
    url(r"^order/", include((order_urls, "order"), namespace="order")),
    url(r"^page/", include((page_urls, "page"), namespace="page")),
    url(r"^products/", include((product_urls, "product"), namespace="product")),
    url(r"^account/", include((account_urls, "account"), namespace="account")),
    url(r"^feeds/", include((feed_urls, "data_feeds"), namespace="data_feeds")),
    url(r"^search/", include((search_urls, "search"), namespace="search")),
]

urlpatterns = non_translatable_urlpatterns + i18n_patterns(*translatable_urlpatterns)

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += [
        url(r"^__debug__/", include(debug_toolbar.urls)),
开发者ID:mirumee,项目名称:saleor,代码行数:31,代码来源:urls.py

示例15: url

from django.views import defaults
from django.views.generic import RedirectView
from django.views.i18n import JavaScriptCatalog
from django.contrib.staticfiles import views as static_views

# pylint suggests importing analytics_dashboard.core, which causes errors in our AMI
# pylint: disable=relative-import
from core import views


admin.autodiscover()

urlpatterns = [
    url(r'^$', views.LandingView.as_view(), name='landing'),
    url(r'^api-auth/', include('rest_framework.urls')),
    url(r'^jsi18n/$', JavaScriptCatalog.as_view(packages=['core', 'courses']), name='javascript-catalog'),
    url(r'^status/$', views.status, name='status'),
    url(r'^health/$', views.health, name='health'),
    url(r'^courses/', include('courses.urls')),
    url(r'^admin/', admin.site.urls),
    # TODO: the namespace arg is deprecated, but python-social-auth urls.py doesn't specify app_name so we are stuck
    # using namespace. Once python-social-auth is updated to fix that, remove the namespace arg.
    url('', include('social_django.urls', namespace='social')),
    url(r'^accounts/login/$',
        RedirectView.as_view(url=reverse_lazy('social:begin', args=['edx-oidc']), permanent=False, query_string=True),
        name='login'),
    url(r'^accounts/logout/$', views.InsightsLogoutView.as_view(), name='logout'),
    url(r'^accounts/logout_then_login/$', views.insights_logout_then_login, name='logout_then_login'),
    url(r'^test/auto_auth/$', views.AutoAuth.as_view(), name='auto_auth'),
    url(r'^announcements/', include('pinax.announcements.urls', namespace='pinax_announcements')),
]
开发者ID:edx,项目名称:edx-analytics-dashboard,代码行数:31,代码来源:urls.py


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