Customizing language negotiation

2 Messages Forum Options Options
Embed this topic
Permalink
Mikel Larreategi
Customizing language negotiation
Reply Threaded MoreMore options
Print post
Permalink
Hi:

For a project in which I'm using Plone 2.5.3, I need to customize the
language negotiation scheme, to provide content in the default language
of my portal in case the user has not the cookie or isn't requesting a
specific language using the path.

Looking at PloneLanguageTool/LanguageTool.py file, I found that there is
a language preference registry in PTS, so I've written a new negotiator
that returns the default language when it's needed and registered it
with a higher priority than the one registered by LanguageTool.py.
Although the registration seems to be OK, my negotiator is called, when
requesting the portal root without any cookie or path language, Plone is
presented in the languages set in my browser preferences. To understand
clearer:

Plone languages: eu, es, en.
Default Language: eu
Browser languages (in order of preference): en, es, fr, eu
I want to present the portal in Default Language (eu) in case the user
has not the language cookie.

I know that this is not very smart, but this is a customer requirement,
you know ;)

Later, once the user has selected his preferred language, the cookie is
set for a very long term (currently PloneLanguageTool sets a session
cookie).

Previously, I've worked with Localizer, and things like this were done
there using accept_methods property inside Localizer object. I don't
know whether the way I took registering a new Negotiator using PTS's
_langPrefsRegistry is the way, but that's the only way I found to add a
new negotiation scheme.

Any hint will be appreciated.


Mikel Larreategi

--
Mikel Larreategi
mlarreategi@...

CodeSyntax
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Plone-i18n mailing list
Plone-i18n@...
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Mikel Larreategi
Re: Customizing language negotiation
Reply Threaded MoreMore options
Print post
Permalink
Mikel Larreategi(e)k dio:
> Any hint will be appreciated.
>

Well, it was as easy as to deactivate the use of browser request
negotiation... and I got it working the way I wanted.

But what if I wanted to create a new negotiator? How should I register it?


Mikel

--
Mikel Larreategi
mlarreategi@...

CodeSyntax
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Plone-i18n mailing list
Plone-i18n@...
https://lists.sourceforge.net/lists/listinfo/plone-i18n