This is useful maven plugin which provides build-time validation of localized messages in your java project.
The idea is to use some markers in java code (@Annotations) to provide information about defined localized messages. Then at build time maven plugin will use this information to analyze and check that both code and properties files are in sync.
(here is FullExample):
// Messages.java
@MessageProvider
public enum Messages {
HELLO_WORLD,
@MessageFormatted
HELLO_WORLD_MSG,
@StringFormatted
HELLO_WORLD_STR,
}
# Messages.properties
HELLO_WORLD=Hello World!
HELLO_WORLD_MSG=Hello World! My name is {0}
HELLO_WORLD_STR=Hello World! My name is %s
# Messages_ru.properties
HELLO_WORLD=Привет Мир!
HELLO_WORLD_MSG=Привет Мир! Меня зовут {0}
HELLO_WORLD_STR=Привет Мир! Меня зовут % s
NOT_USED=Тест
[INFO]
[INFO] --- i18n-maven-plugin:1.0.0-SNAPSHOT:i18n (default) @ i18n-demo ---
[INFO] Checking com.googlecode.i18n.demo.Messages
[INFO] Checking Messages.properties
[INFO] Checking Messages_ru.properties
[ERROR] Invalid format [HELLO_WORLD_STR]
Conversion = s, Flags =
[WARNING] found not used keys:
[WARNING] [NOT_USED]
[INFO]
[INFO] Check results:
[INFO] 1 error(s), 1 warning(s)
[INFO] -------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] -------------------------------------------------------------------
For full list of configuration parameters, please, refer to I18nPluginMojo
<!-- pom.xml -->
<build>
<plugins>
<plugin>
<groupId>com.googlecode.i18n-maven-plugin</groupId>
<artifactId>i18n-maven-plugin</artifactId>
<version>${i18n-maven-plugin.version}</version>
<executions>
<!-- You can define either class/source mapped localization check -->
<execution>
<id>classes-check</id>
</execution>
<!-- And/Or plain old properties check -->
<execution>
<id>plain-check</id>
<configuration>
<locales>en,ru</locales>
<baseLocale>en</baseLocale>
<!-- If your properties files looks like "en.properties"
then this path should ends with "/" -->
<plainFilePath>localization/</plainFilePath>
</configuration>
</execution>
</executions>
<configuration>
<locales>ru</locales>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.i18n-maven-plugin</groupId>
<artifactId>i18n-annotations</artifactId>
<version>${i18n-maven-plugin.version}</version>
</dependency>
</dependencies>
Plugin modules are available on Maven Central, through Sonatype OSS hosting.
Added plain properties check mode
First release