You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kjetil Kjernsmo <Kj...@computas.com> on 2009/01/26 17:37:03 UTC
{language} sitemap parameters
All,
I've been using LocaleAction for a while, but it hasn't worked very well, and
now I needed to resolve some bugs in the application in the language
handling. Basically, all I want to do is turn off the feature that looks in
the Accept-Language header (since it doesn't do a full language negotiation
process as specified in HTTP) and set the default locale to Norwegian
language. This should be trivially configureable, but I have never gotten it
working, so eventually, I had to realise that I simply don't understand how
LocaleAction works.
So, I started to read the code, and I forked it to add more debug information
and to hardcode our desired locale whenever possible. What I found was that
the configuration method of the code does run OK and all the correct
parameters are set.
In my sitemap, which can be found at
https://submarine.computas.com/sublima/trunk/blocks/sublima-app/src/main/resources/COB-INF/sitemap.xmap
I have sections like
<map:match pattern="resource/*.*">
<map:act type="locale">
<map:call function="com.computas.sublima.app.fascade.SearchFascade">
<map:parameter name="mode" value="resource"/>
<map:parameter name="name" value="{../1}"/>
<map:parameter name="format" value="{../2}"/>
<map:parameter name="interface-language" value="{language}"/>
</map:call>
</map:act>
</map:match>
So, I set the interface-language parameter to {language}. So the critical
issue here is how {language} is set. LocaleAction seems to be the right way
to do this.
With my slightly modified LocaleAction this is what I see in my logs when it
is enabled:
http-8180-Processor25 DEBUG action.LocaleAction - will set values in request
http-8180-Processor25 DEBUG action.LocaleAction - won't create session
http-8180-Processor25 DEBUG action.LocaleAction - won't set values in session
http-8180-Processor25 DEBUG action.LocaleAction - won't set values in cookies
http-8180-Processor25 DEBUG action.LocaleAction - Locale attribute name is
locale
http-8180-Processor25 DEBUG action.LocaleAction - won't use request locale
http-8180-Processor25 DEBUG action.LocaleAction - default locale no_NO
http-8180-Processor25 TRACE controller.SearchController - SearchController:
Language from sitemap is en
So, everything looks fine up to the final line. The final line stems from the
controller, which uses the interface-language parameter. I have confirmed
that this language is set to the Accept-Languages header, regardless of the
default locale and regardless of that I have explicitly disabled it.
Furthermore, the interesting thing is what is not in the logs: There's nothing
from the act method, so it appears that act is actually never run.
However, if I send a locale query parameter, things look much better, e.g. if
I send ?locale=sv, I get:
http-8180-Processor25 DEBUG action.LocaleAction - won't use request locale
http-8180-Processor25 DEBUG action.LocaleAction - default locale no_NO
http-8180-Processor25 TRACE controller.SearchController - SearchController:
Language from sitemap is sv
i.e. it works as intended.
So, the problem is only that the Accept-Languages header override the default
even if disabled, it works nicely if a query parameter is used.
Now, I did another interesting exercise: I commented out the LocaleAction
matcher.
The log now confirms that LocaleAction is not run at all. To my great
surprise, it has exactly the same behaviour as before. I.e. query params
work, but the Accept-Languages header is still what is used.
I haven't seen this behaviour documented anywhere. I thought that LocaleAction
was required to even use the {languages} variable, but now it appears that
there is something in Cocoon core that does this.
So, is there any way I can disable Accept-Languages and hard-code a default
that is used whenever a locale query parameter is not given?
Kind regards
Kjetil Kjernsmo
--
Senior Knowledge Engineer
Mobile: +47 986 48 234
Email: kjetil.kjernsmo@computas.com
Web: http://www.computas.com/
| SHARE YOUR KNOWLEDGE |
Computas AS PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | Fax:+47 6783
1001
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org