Fork me on GitHub
NOTICE There is a new plugin (archetypes and eclipse integration), a fresh start that correctly support multi-module projects, it is not version-bounded with GWT, support multiples GWT versions and other fixes, improvements and best practices. This plugin is now considered the legacy GWT maven plugin (aka mojo GWT maven plugin) and the new one is considered the new generation GWT maven plugin (aka tbroyer GWT maven plugin). The legacy maven plugin is still supported but it is strongly encouraged to use the new one for new projects.

Generate i18n interfaces for message bundles

About

GWT uses standard java message bundles for internationalization (i18n), but use the compile-time multiple-permutation strategy to create a JavaScript output file per supported language. On client-side code, developers use Message interface to read String from the bundle. Such interfaces can be generated by a SDK tool.

If you're not familiar with this please review i18n interfaces generator documentation.

gwt-maven-plugin i18n goal

The plugin can be used to generate such Message interface. Just add the required goal and configuration to plugin execution :

<project>
  [...]
  <build>
    <plugins>
      [...]
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.8.1</version>
        <executions>
          <execution>
            <goals>
              <goal>i18n</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <resourceBundle>com.mycompany.gwt.Bundle</resourceBundle>
        </configuration>
      </plugin>
      [...]
    </plugins>
  </build>
  [...]
</project>

Declare resource bundles

The resourceBundle parameter is used to declare your application bundle for i18n processing. If your application uses more than one bundle, you can nest multiple resourceBundle elements :

<project>
  [...]
  <build>
    <plugins>
      [...]
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.8.1</version>
        <executions>
          <execution>
            <goals>
              <goal>i18n</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <resourceBundles>
            <resourceBundle>com.mycompany.gwt.Bundle1</resourceBundle>
            <resourceBundle>com.mycompany.gwt.Bundle2</resourceBundle>
            <resourceBundle>...</resourceBundle>
          </resourceBundles>
        </configuration>
      </plugin>
      [...]
    </plugins>
  </build>
  [...]
</project>

Choose the message API to be generated

By default, the i18nCreator is configured to generate interface based on the Messages interface.

If you prefer to use the Constants class as base class, set the messages parameter to false.

You can also configure the plugin using the constantsWithLookup parameter to use ConstantsWithLookup interface.

For more information on distinctions between those interfaces, please review the GWT i18n documentation.