Rajin Das
Rajin Das

Reputation: 11

GWT Internationalization, using multiple locale at the same time

Is it possible in GWT to read from constants file by specifying the locale manually. I am working on an application which is multi-lingual, the user can choose a primary language and secondary language for the application.

Which the user have logged in his primary language (say English) i need to show some labels in secondary language (say french) and it happens vise-verse when the user have logged in with secondary language.

In core java we could use Resource bundle to specify which locale and load the properties files accordingly, in GWT as we are not specifying locale while constants are loaded how can we achieve this?

Upvotes: 0

Views: 608

Answers (2)

user1258245
user1258245

Reputation: 3639

  1. Hermes Server side code.

    MyMessages i18n = Hermes.get(MyMessages.class, "en");
    MyMessages i18n_ja = Hermes.get(MyMessages.class, "ja");
    

    public interface MyMessages extends com.google.gwt.i18n.client.Messages {...}

  2. Use Dynamic String Internationalization

For example see:

GWT Internationalization for dynamically generated content

GWT dynamic internationalization

http://www.gwtproject.org/doc/latest/DevGuideI18n.html#DevGuideDynamicStringInternationalization

Upvotes: 1

Patrick
Patrick

Reputation: 1631

The natural architecture that comes to my mind would be to use static string internationalization for the primary locale -- i.e., the standard way. Then, for the secondary locale, call server for the corresponding translation map or Constants. On the server side, you can use whatever you want that does the job. I like Hermes because it offers the same interface as GWT and is simple to use; your server could very easily return to client an instance of your Constants in the secondary locale.

This being said, I am not a GWT expert and I cannot promise it is the best way.

Upvotes: 0

Related Questions