Oh crap, I missed the javadoc about the *default *locale being queried
as well... Well spotted Bob.
I use click-page.properties as the mother of all click-page properties
files, so I have set up the ant target that builds my war file to copy
the base file to the _en file, so I have both. That works by the way :)
Thanks for the fast response (as always :) ).
Cheers,
WarnerJan
On 03/31/2010 12:42 PM, Bob Schellink wrote:
Hi WarnerJan,
I think the issue is that you have not defined an explicit english
locale click-page_en.properties. If you look at Java's ResourceBundle
algorithm[1] you'll notice that it uses *two* locales to lookup
messages. First is the specified locale (english) and then the default
(dutch).
Since the server default is Dutch the lookup goes like this:
click-page_en.properties - this property file does not exist, move to
next variant
click-page_nl.properties - this property file *does* exist and message
is found
So click-page.properties is never used. If you rename
click-page.properties to click-page_en.properties that should resolve
the issue. The click-page.properties is really just a fallback in case
neither the locales could satisfy the request.
Let me know if that doesn't actually work though :)
kind regards
bob
[1]:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,
java.util.Locale, java.lang.ClassLoader)
On 31/03/2010 8:09 PM, WarnerJan Veldhuis wrote:
I have this wierd problem with Click running on Windows and using the
wrong Locale.
- When the user enters the welcome page (index.htm), Click reads the
locale from the request, which is the browser setting, in my case "nl"
(Dutch).
- As the user logs in, his application settings are read form the
database and the user's preferred language is retrieved, which is set to
"en" (English)
- The Locale is saved on the context directly after the login:
getContext().setLocale( user.getPreferredLocale() ). Under the hood this
sets a session attribute.
- When the login process is complete, the login method redirects to
HomePage.class
- When the homepage is rendered, it is in "nl" and not in "en".
I have done some testing and the reason it is "nl" is that it is the
Windows box regional setting on the server. Which is very strange since
I have explicitly set a Locale on the Context. Still Click chooses "nl".
When I set the Windows regional settings on the server to "en", the
pages will show up in English.
I have entered all my captions in English in click-page.properties. Then
I made variations like click-page_nl.properties,
click-page_se.properties, you know, following the standard
ResourceBundle strategy. So I would think that even if Click fails to
find click-page_en.properties, it would fall back to
click-page.properties. But it doesn't. It chooses the
click-page_nl.properties because the regional settings are Dutch.
Can anyone shed some light on this?
Cheers,
WarnerJan