DateField locale problem


I have a translation problem with Vaadin DateField when I set a date format and a locale.

In my date format I want to display the day of week but it’s not translated correctly.

Here’s my code snippet:

        DateField df = new DateField("A datefield");
        Locale locale = new Locale("fr", "CA");

        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
        if (dateFormat instanceof SimpleDateFormat)
            String pattern = ((SimpleDateFormat) dateFormat).toPattern();

Here’s the result:

Wednesday 29 décembre 2010

The month is translated correctly in french but the day of week is still in english.

Does this happen also when the browser locale is fr_CA and when it isn’t.
For the case where the browser locale does not match the locate you set, I see com.vaadin.terminal.gwt.client.DateTimeService has to use some tricks for month names and might not take days of week into account. If the locales match, it might work with the default GWT date and time handling - I’m not sure about that.

In any case, please
create a ticket
about this with the sample code and post the ticket number here to help others find it.

I think that Vaadin should always obey the explicitly set Java locales and formats, and should support changing on the fly – change the locale and refresh().

In this city, most people are bilingual or trilingual, but not perfectly so, and will feel the need to switch languages in the middle of a session (the French text is perhaps easier to understand to a native speaker, but every once in a while the official bureaucratic French word will be obscure, and there will be a need to switch to English to double-check with everyday colloquial usage).

The browser preferences should only ever be used for selecting the default language if no cookie is set. Support for switching locales on the fly and remembering with a cookie would be a nice addition to the various navigation or foundation frameworks.

The problem is when the browser locale does not match the used locale. Created ticket #6207 for it.