Monday, July 28, 2014

How to access “locale” value (of an Internationalization App) in server side in GWT?

Ok, I am developing an app that supports Internationalization. I am using Static String Internationalization method for my app.

Let say my app can have English & German version, so -1st, I created which has all message texts written in English. Then I created an MyMessages_ge which is almost the same as except that the text written in German

-2nd, in MyProject.html i have <meta http-equiv="content-type" content="text/html; charset=UTF-8"> to make sure it will support all languages

-3rd, in MyProject.gwt.xml I have <extend-property name="locale" values="ge"/>

Now I run my app in eclipse http://localhost:8888/MyProject.html?gwt.codesvr= & it shows all the German text as I expected.

However, I have a need to know that my app is German At Server Side. That means whenever my GWT Gui in German version then my server will know that languageCode=1 if it is in English so server will use the default language languageCode=0

Here is what I did. At

@Override  public void prepareFromRequest(PlaceRequest request){      super.prepareFromRequest(request);      String locale=request.getParameter("locale", "");      setLanguage(locale); // servercall back here  }  

so when my app run first time it should let server to know which language the Gwt app is using

@Override  public SetLanguageResult execute(SetLanguage action, ExecutionContext context)          throws ActionException {      String locale=action.getLocale();      if("ge".equals(locale)){          Data.languageType=1;      }      return null;  }  

However, it doesn't seem work When I go to orderPage the url will be http://localhost:8888/MyProject.html?gwt.codesvr=!orderPage it not in the form http://localhost:8888/MyProject.html?gwt.codesvr=!orderPage;locale=ge that is why server couldn't capture the locale value.

I think I misunderstood something here. I'm quite confusing.

So How to access "locale" value (of an Internationalization App) in server side in GWT?

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment