Honouring Browser Locale

7 views
Skip to first unread message

francescoNemesi

unread,
Aug 23, 2008, 5:07:18 AM8/23/08
to Google Web Toolkit
Hi There,

in my GWT application I am using GWT Constants and Messages to im
plement localisation... I know it si possible to change the the
locale by passing it to the URL or with a property in the html, but I
was wondering if there is a way for the application to honour the
user's browser locale, like "standard J2EE applications would do".

I'd really like to stick to the standard GWT localisation
implementation for its very fast response.

Thanks for any help

Francesco

Thomas Broyer

unread,
Aug 23, 2008, 3:28:47 PM8/23/08
to Google Web Toolkit
Unfotunately, there's no reliable way to obtain the equivalent of the
Accept-Languages request header in JavaScript (IE has
navigator.userLanguage, Opera has navigator.language, but Firefox's
navigator.language is the browser's locale, not the ones you set in
the preferences).

AFAICT, you should be able to override the property-provider for
locale in your module's *.gwt.xml to use those properties if you like,
but you'd better do content-negotiation on the server-side to return a
different <meta>, or eventually redirect to the ?locale=, depending on
the Accept-Languages request header (when there's no ?locale=XX
already).

francescoNemesi

unread,
Aug 25, 2008, 3:19:57 AM8/25/08
to Google Web Toolkit
Thank You for this... I'll look for some workaround...
Reply all
Reply to author
Forward
0 new messages