Esempio n. 1
0
    def test_translations_create(self, client):
        root = Node.root()

        n = root.add(langslugs=dict(en="en", nl="nl", fr="fr"))
        t_nl = Type1(node=n, language="nl", title="NL").save()
        t_en = Type1(node=n, language="en", title="EN").save()


        request = create_request("GET", "/create", data=dict(type="sometype"))

        translation.activate("en")
        toolbar = Toolbar(n, request, "create")
        translations = toolbar.translations()

        assert translations['active']['id'] == 'en'

        import urllib2

        ## Do some matching magic using endswith to work around language / base prefixing.
        ## We're mosly interested in create/view/edit actions anyway
        assert len(translations['translated']) == 0
        assert len(translations['untranslated']) == 3  ## all languages incl 'any', active lang excluded

        for ut in translations['untranslated']:
            l = ut['id']
            assert l in ('nl', 'fr', 'en', 'any')
            assert ut['action_url'].endswith('switch_admin_language?path='+n.tree_path + '&switchto=' + l + '&rest=' + urllib2.quote('create?type=sometype'))
Esempio n. 2
0
    def test_translations_list(self, client):
        root = Node.root()

        n = root.add(langslugs=dict(en="en", nl="nl", fr="fr"))
        t_nl = Type1(node=n, language="nl", title="NL").save()
        t_en = Type1(node=n, language="en", title="EN").save()


        request = create_request("GET", "/")

        translation.activate("en")
        toolbar = Toolbar(n, request, "list")
        translations = toolbar.translations()

        assert translations['active']['id'] == 'en'

        ## Do some matching magic using endswith to work around language / base prefixing.
        ## We're mosly interested in create/view/edit actions anyway
        assert translations['translated'][0]['id'] == "nl"
        assert translations['translated'][0]['action_url'].endswith('switch_admin_language?path='+n.tree_path + '&switchto=nl&rest=list')
        assert translations['untranslated'][0]['id'] == 'fr'
        assert translations['untranslated'][0]['action_url'].endswith('switch_admin_language?path='+n.tree_path + '&switchto=fr&rest=list')