Exemplo n.º 1
0
    def languages(self):
        languages_info = super(gwLanguageSelectorForRoot, self).languages()
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path
                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url(),
                    **query_extras
                )
            else:  # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Exemplo n.º 2
0
    def languages(self):
        languages_info = super(gwLanguageSelectorForRoot, self).languages()
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path
                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url(),
                    **query_extras
                )
            else: # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Exemplo n.º 3
0
    def languages(self):
        languages_info = super(gwLanguageSelectorViewlet, self).languages()

        google_translated = self.get_google_translated_langs()
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        uuid = IUUID(self.context)
        if uuid is None:
            uuid = 'nouuid'

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            # if google_translated.get(data['code']):
            #     data['google_translated'] = True
            #     google_query_string = dict(sl=self.tool.getPreferredLanguage(),
            #                                tl=data['code'],
            #                                u=quote(self.context.absolute_url())
            #                                )

            #     data['url'] = 'http://translate.google.com/translate?hl={sl}&sl={sl}&tl={tl}&u={u}'.format(**google_query_string)
            # else:
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path

                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url().rstrip("/") +
                    "/@@goto/%s/%s" % (
                        uuid,
                        lang_info['code']
                    ),
                    **query_extras
                )
            else: # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Exemplo n.º 4
0
    def languages(self):
        languages_info = super(gwLanguageSelectorViewlet, self).languages()

        google_translated = self.get_google_translated_langs()  # noqa
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        uuid = IUUID(self.context)
        if uuid is None:
            uuid = 'nouuid'

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            # if google_translated.get(data['code']):
            #     data['google_translated'] = True
            #     google_query_string = dict(sl=self.tool.getPreferredLanguage(),
            #                                tl=data['code'],
            #                                u=quote(self.context.absolute_url())
            #                                )

            #     data['url'] = 'http://translate.google.com/translate?hl={sl}&sl={sl}&tl={tl}&u={u}'.format(**google_query_string)
            # else:
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path

                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url().rstrip('/') +
                    '/@@goto/%s/%s' % (
                        uuid,
                        lang_info['code']
                    ),
                    **query_extras
                )
            else:  # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Exemplo n.º 5
0
    def get_selected_lang(self, languages):
        # Show all languages in language selector
        all_languages = super(gwLanguageSelectorBase, self).languages()

        if self.context.REQUEST.form.get('set_language'):
            idiomes_publicats = genweb_config().idiomes_publicats

        return [lang for lang in all_languages if lang['selected']][0]
Exemplo n.º 6
0
    def get_selected_lang(self, languages):
        # Show all languages in language selector
        all_languages = super(gwLanguageSelectorBase, self).languages()

        if self.context.REQUEST.form.get('set_language'):
            idiomes_publicats = genweb_config().idiomes_publicats  # noqa

        return [lang for lang in all_languages if lang['selected']][0]
Exemplo n.º 7
0
    def lang_published(self):
        # show if the selected lang is published or not in language selector
        lang = dict(getToolByName(self, 'portal_languages').listAvailableLanguages())
        published_lang = genweb_config().idiomes_publicats
        params_lang = self.context.REQUEST.form.get('set_language')
        cookie_lang =  getToolByName(self, 'portal_languages').getPreferredLanguage()

        if params_lang:
            if params_lang not in lang:
                return _(u"not a valid language", default=u"${results} not a valid language", mapping={ u"results" : params_lang})
            if params_lang not in published_lang:
                return _(u"Not published")
        else:
            if cookie_lang not in published_lang:
                return _(u"Not published")
Exemplo n.º 8
0
    def lang_published(self):
        # show if the selected lang is published or not in language selector
        lang = dict(getToolByName(self, 'portal_languages').listAvailableLanguages())
        published_lang = genweb_config().idiomes_publicats
        params_lang = self.context.REQUEST.form.get('set_language')
        cookie_lang = getToolByName(self, 'portal_languages').getPreferredLanguage()

        if params_lang:
            if params_lang not in lang:
                return _(u'not a valid language', default=u'${results} not a valid language', mapping={u'results': params_lang})
            if params_lang not in published_lang:
                return _(u'Not published')
        else:
            if cookie_lang not in published_lang:
                return _(u'Not published')
Exemplo n.º 9
0
 def genweb_config(self):
     return genweb_config()
Exemplo n.º 10
0
 def render(self):
     return genweb_config()
Exemplo n.º 11
0
 def update(self):
     self.especific1 = genweb_config().especific1
     self.especific2 = genweb_config().especific2
Exemplo n.º 12
0
 def render(self):
     return genweb_config()
Exemplo n.º 13
0
 def update(self):
     self.especific1 = genweb_config().especific1
     self.especific2 = genweb_config().especific2
Exemplo n.º 14
0
 def genweb_config(self):
     return genweb_config()
Exemplo n.º 15
0
 def getContactPersonalized (self):
     not_customized = not genweb_config().contacte_BBDD_or_page
     return not_customized