Localization in GWT via cookie

If you’ll search for the term “Localization in GWT” – you’ll find numerous articles about using META tag with gwt:property name, like <meta name=”gwt:property” content=”locale=de”>
But sometimes it’s not very convenient. For example we have an iframe with reference to some another GWT module and this module bypasses META tag written for the parent document. In this case cookie is the easiest choice.

So in the combo selecting the language you specify a cookie with any name you like, for example in JavaScript:

$.cookie("gwtLanguage", 'be', {path: '/'});

And after writing the following code in the gwt.xml file of your module, you’ll make GWT analyzing this cookie value and use it as the default locale:

<set-configuration-property name="locale.cookie" value="gwtLanguage"/>

In some cases this approach can make your life easier.