Beispiel #1
0
 def _create_json_catalog(self, locale, domain, packages):
     activate(locale)
     catalog = JSONCatalog()
     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)
 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)
 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)
    def _create_json_catalog(self, locale, domain, packages):
        activate(locale)
        if django.VERSION < (2, 0):
            catalog, plural = get_javascript_catalog(locale, domain, packages)
            data = {
                'catalog': catalog,
                'formats': get_formats(),
                'plural': plural,
            }

            return force_text(json.dumps(data, ensure_ascii=False))
        else:
            catalog = JSONCatalog()
            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)
    def _create_json_catalog(self, locale, domain, packages):
        activate(locale)
        if django.VERSION < (2, 0):
            catalog, plural = get_javascript_catalog(locale, domain, packages)
            data = {
                'catalog': catalog,
                'formats': get_formats(),
                'plural': plural,
            }

            return force_text(json.dumps(data, ensure_ascii=False))
        else:
            catalog = JSONCatalog()
            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)
Beispiel #6
0
def test_get_packages_None():
    assert utils.get_packages('django.conf') is None
Beispiel #7
0
def test_get_packages(packages):
    assert utils.get_packages(packages) == 'mypackage1+mypackage2'