コード例 #1
0
def javascript_catalog_all(request, domain='djangojs'):
    """
    Get JavaScript message catalog for all apps in `INSTALLED_APPS`.
    """
    all_apps = [x.name for x in apps.get_app_configs()]
    from django.views.i18n import JavaScriptCatalog
    js_catalog = JavaScriptCatalog(packages=all_apps, domain=domain)
    return js_catalog.get(request)
コード例 #2
0
 def _create_javascript_catalog(self, locale, domain, packages):
     activate(locale)
     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_str(response.content)
コード例 #3
0
 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)
コード例 #4
0
 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)