plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
255 stars 191 forks source link

Zope-level language negotiation #2161

Open malthe opened 7 years ago

malthe commented 7 years ago

The z3c.pt package relies on Zope's language negotiation utility zope.i18n.INegotiator but plone.i18n does not register such a utility, instead relying on Zope's own negotiation logic which is not the same as plone.i18n.

The result is that different languages may be used on the same page.

For example, the following simply uses the Plone-negotiated language:

from zope.interface import implements
from zope.i18n.interfaces import INegotiator

class Negotiator(object):
    implements(INegotiator)

    def getLanguage(self, langs, env):
        """Return the language that's already set up by Plone."""

        return env.get('LANGUAGE', 'en')

negotiator = Negotiator()
jensens commented 7 years ago

would be an enhancement of plone.i18n - PRs welcome.