On 19 mar, 15:34, Mamadou Alimou DIALLO <
malim...@gmail.com> wrote:
> Hello group,
>
> I develop big entreprise application using GWT. My application is
> multilanguage (FR, EN, GB). I would like to change dynamically the
> application language automaticaly. For example when I lunch application, I
> would like to detect the client language and automatically load a good
> propertie file. For example when your browser is in French, I would like to
> load my application in French. Please do you have an idea about this problem
> ?
We have the very same need, and the way we're going to do it is to use
content negotiation on the server.
In other words, duplicate the HTML host page in each 4 languages
(
index.html.fr, index.html. en, index.html. de, index.html. es) with
the corresponding <meta name="gwt:property" content="locale=XX"> and
let Apache choose the appropriate file.
That's kind of a "poor man"'s approach, but I know I won't get into
tricky things: it is known to work and it "just works".
(the GWT-Incubator includes some server-side Java code to do content-
negotiation from within a servlet/jsp/etc. and allows you to keep a
single HTML host page and generate the appropriate <meta> within it
using conneg against the locales your application do support; we won't
use this approach as a) the app is served straight from Apache and b)
our HTML host page contains some localizable text: "loading",
"JavaScript support is mandatory; enable JavaScript or use a browser
that supports it", you know those kind of things)
> The other think I would like to do is, when I click for example on a button
> to change language, I would like to change language without reloading all of
> my application (just the current context). How can I do this please ?
We won't go this road as I don't think it is compelling enough for the
implied additional work (and performance downgrade). If you do want to
explore this scenario, here are some notes:
- do not use GWT's I18N support (the "locale" property, Constants,
Messages, etc.), you'd have to build your own.
- each and every localizable widget would have to register for a
global "locale changed" event that you'd fire when the user wants to
switch from e.g. French to English. This has serious performance
impacts if you have many such widgets.
- beware of other locale peculiarities: RTL, some changes needed in
styles so your widgets align properly (text don't wrap, etc.) and/or
you don't offense or misguide your users (colors have different
"meanings" depending on countries/cultures). That's true even if you
use GWT's I18N, but it becomes trickier when you change the locale
dynamically as you might have to re-layout your page "on the go")