i18n:target does not work

Bug #142771 reported by Bug Importer
0
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Wishlist
Unassigned

Bug Description

ZPTInternationalizationSupport

Specifying a target language (i18n:target="string:es") does not work. 'None' is always passed in to the translation service which causes the translation service to negotiate a language based on the browser.

It does not look like the target language is passed in TALInterpreter.py.

Tags: bug zope
Revision history for this message
Jean-François Doyon (jdoyon) wrote :

Still doesn't work in Zope 2.10 :(

Here's a nasty monkey patch:

-----------------------------------------------------------------

# $Id: i18ntargetpatch.py 1325 2006-10-19 15:30:59Z jdoyon $

from Products.PageTemplates.Expressions import ZopeContext
from Products.PageTemplates.GlobalTranslationService import getGlobalTranslationService
from zope.tal.talinterpreter import TALInterpreter

def zopecontexttranslate(self, msgid, domain=None, mapping=None, default=None,
                         target_language=None):
    context = self.contexts.get('context')
    return getGlobalTranslationService().translate(
        domain, msgid, mapping=mapping,
        context=context, target_language=target_language, default=default)

ZopeContext.translate = zopecontexttranslate

def talinterpretertranslate(self, msgid, default=None, i18ndict=None,
                            obj=None, domain=None):
    if default is None:
        default = getattr(msgid, 'default', unicode(msgid))
    if i18ndict is None:
        i18ndict = {}
    if domain is None:
        domain = getattr(msgid, 'domain', self.i18nContext.domain)
    if obj:
        i18ndict.update(obj)
    if not self.i18nInterpolate:
        return msgid
    # TODO: We need to pass in one of context or target_language
    return self.engine.translate(msgid, self.i18nContext.domain,
                                 i18ndict, default=default,
                                 target_language=self.i18nContext.target)

TALInterpreter.translate = talinterpretertranslate

----------------------------------------------------------------

NOTE: The value of i18n:target using this patch is the language itself, and not a TALES. So use i18n:target="fr" instead of i18n:target="string:fr".

Revision history for this message
Jean-François Doyon (jdoyon) wrote :

Uploaded: i18ntargetpatch.py

Find attached an updated version of the monkey patch which actually implements i18n:target as documented (Where the content of the attribute is a TALES). This code depends on CMF for convenience however.

Revision history for this message
Philipp von Weitershausen (philikon) wrote :

Thanks for looking into this. I would just like to note that it's unlikely anyone will look into this unless you:

- provide a unified diff against the *trunk* of Zope (you're introducing a new feature). That means no monkey patch.

- get rid of the CMF dependency.

- provide tests for the new feature.

Revision history for this message
Jean-François Doyon (jdoyon) wrote :

Uploaded: i18ntargetpatch-v2.py

A new version of the monkey patch without the CMF dependency.

Revision history for this message
Jean-François Doyon (jdoyon) wrote :

Some of the functionality depends on Zope 3.

I've opened a bug and added a patch here:

http://www.zope.org/Collectors/Zope3-dev/763

Changed in zope2:
importance: Medium → Wishlist
Revision history for this message
Hanno Schlichting (hannosch) wrote :

There's no Zope2 change required anymore, making https://bugs.launchpad.net/zope3/+bug/98490 the real feature request.

Changed in zope2:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.