Infotechie
Infotechie

Reputation: 1653

Supporting i18n in GWT

Till now, our web application supports only English. Now we have to provide support for Italian as well. There is GWT module for some functionality. To support the Italian language I have added below line in the file "APP_Module.gwt.xml"

<extend-property name="locale" values="it"/>

I have also placed "XXX_it.properties" file under the source code where the properties file for en is kept.

Setting the locale in the jsp by following line:

<meta name="gwt:property" content="locale=${locale}">

Now, the issue is how to compile the code. I am debugging the application but it is not hitting the client code of GWT presented under WEB-INF/src.

I am very new to GWT. Please suggest how can I compile the code or there is no need of compilation. It will automatically take the changes done in "APP_Module.gwt.xml" and there is some other issue. How can I see logs of GWT?

Upvotes: 4

Views: 601

Answers (2)

MartinTeeVarga
MartinTeeVarga

Reputation: 10898

To add support for locales to GWT application, you need to do the following in your xxx.gwt.xml:

under <module> add this to include the support:

<inherits name="com.google.gwt.i18n.I18N" />

and this to configure it:

<extend-property name="locale" values="en,it"/>
<set-property-fallback name="locale" value="en"/>

Add all your property files under some package like this:

src/main/resources/foo/bar/client/i18n/MyMessages.properties
src/main/resources/foo/bar/client/i18n/MyMessages_it.properties

Then you need to tell GWT to compile them into classes. This is example from a pom.xml file (if you don't use maven, you will have to use a different way, but you still need to configure it).

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>1.3.1.google</version>
            <executions>
                <execution>
                    <goals>
                        <goal>i18n</goal>
                        <goal>generateAsync</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <i18nMessagesBundles>
                    <resourceBundle>foo.bar.client.i18n.MyMessages</resourceBundle>
                </i18nMessagesBundles>
            </configuration>
        </plugin>

Then you need to recompile the code. In maven mvn compile. And that's all, you will have your messages in generated sources folder ready to use.

Upvotes: 3

jerin john
jerin john

Reputation: 199

For seeing the logs of gwt you can use gradlew gwt also you can use it to compile the code too.

Upvotes: 0

Related Questions