Normally, I write my internationalisation (i18n) files in UTF-8 format. This means that they are human readable.

Java i18n files however must be ISO-8859-1. If you don't process them using something like native2ascii, accented and multibyte characters will return gobbledegook at best.

You can manually convert a single file manually using this command:


native2ascii -encoding utf-8 ./src/main/resources/i18n.properties ./target/classes/i18n.properties

That's tedious, so why not automate the process during the build?

Using native2ascii-maven-plugin

Luckily, there's a maven plugin called native2ascii-maven-plugin. Its old, but does the job.

For Atlassian SDK p2 add-ons, use something like this:


<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<id>native2ascii-utf8-properties</id>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<src>src/main/resources</src>
<includes>*.properties</includes>
<encoding>UTF8</encoding>
<dest>target/classes</dest>
</configuration>
</execution>
</executions>

<!-- For Java 7+ compilation: -->
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</build>

Your source files will be in sweet UTF-8 format and your target files will be mangled into ISO-8859-1 as Java requires.

How do you do this? Please add a comment below with details.


Update: Maven resource filtering can mess with the working of this plugin, so try with no resource filtering first ;)