Extending Locale4jBundle
import java.io.FileInputStream;
import net.sf.locale4j.bundle.Locale4jBundle;
import net.sf.locale4j.format.Tmx20;
public class MyBundle extends Locale4jBundle {
protected void loadBundle() {
try {
FileInputStream istream = new FileInputStream("translations.xml");
Tmx20 tmx = new Tmx20();
this.setStore(tmx.read(istream));
istream.close();
} catch (Exception e) {
System.out.println("Failed to load translation data. Reason: " + e.toString());
}
}
}
import java.util.Locale;
public class MyBundle_en extends MyBundle {
protected Object[][] getContents() {
return getContents(new Locale("en"));
}
}
import java.util.Locale;
public class MyBundle_fr extends MyBundle {
protected Object[][] getContents() {
return getContents(new Locale("fr"));
}
}