You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Marilen Corciovei <le...@nemesisit.rdsnet.ro> on 2005/05/01 19:27:25 UTC

Strange behaviour with Localization

I am experiencing some strange behaviour while trying to develop a
Localized application. I was under the impression that the default
engine locale is the default java locale but instead I am getting very
strange results.

Case 1. I am starting the application with default system locale
(en_US). The strings for ValidFields are in english. The pages are in
english.

Case 2. I am changing -Duser.language=fr -Duser.region=FR. The strings
for ValidFields are in french but the pages are still in english. (THE
PROBLEM).

I did some research in the code and I found that the Engine has the
Locale returned by ApplicationServlet.getLocaleFromRequest(). This in my
opinion detects the locale from the "Accept-Language: en-us,en;q=0.5"
information provided by the browser.

Case 3. I changed: 

    protected Locale getLocaleFromRequest(RequestContext context) throws
ServletException {
        Cookie cookie = context.getCookie(LOCALE_COOKIE_NAME);

        if (cookie != null)
            return Tapestry.getLocale(cookie.getValue());

        return Locale.getDefault();
    }

and the behaivour seems to be as expected. 

However I am unable to explain how the ValidField was finding the french
locale before in case 2.

Am I missing something?

Thank you, Len