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.7.0</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.7.0</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.