[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nuxeo-localizer] I really need the SELECTED_LANGUAGE
From: |
Juan David Ibáñez Palomar |
Subject: |
Re: [Nuxeo-localizer] I really need the SELECTED_LANGUAGE |
Date: |
Mon, 04 Mar 2002 12:18:13 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214 |
Garikoitz Araolaza wrote:
Sorry, but I've found that I need information about language
negotiation even with "a priori" non localizable objects.
For example:
- I run an Squishdot site for news. News are not necessarily the same
for two language visitors. So, I created Squishdot subjects with the
ISO code of each language, so that:
<dtml-in "Squishdot()(subject=SELECTED_LANGUAGE)">
would return news of a given language.
So I need to know which is the preferred language of the user, even if
the Squishdot Site isn't a localizable object in my case.
- Launching search to a ZCatalog.
I used the expression:
<dtml-call "REQUEST.set('body_'+SELECTED_LANGUAGE, term)">
<dtml-in Catalog.....)
So that search would be performed in the right index of the catalog.
How could I do it with the new Localizer version? should I use the new
locale folders?
Suppose you use the CVS, and you have a "Localizer" instance in the root of
your web site. Create a Python script within the "Localizer" instance, call
it "selected_language", add it *at the end* of the property
"accept_methods".
The content of the script will be:
request = self.REQUEST
available_languages = container.get_available_languages()
default_language = container.get_default_language()
selected_language =
accept_language.select_language(available_languages) or default_language
request.set('SELECTED_LANGUAGE', selected_language)
This way you will have again SELECTED_LANGUAGE as before, and won't need
to modify your code.
--
J. David Ibáñez, Nuxeo.com
Python programmer (http://www.python.org)