Localizing an application can mean several things:
There are tools that assist you with localizing Java Swing GUIs. jME3 applications do not typically have a Swing GUI, so those tools are not of much help. Just stick to the normal Java rules about using Bundle Properties:
Tip: The jMonkeyPlatform supports opening and editing Bundle.properties files. Also note the Tools > Localization menu.
To prepare the application for localization, you have to first identify all hard-coded messages.
System.out.print("Hello World!"); UiText.setText("Score: "+score);
Bundle.properties
in each directory where there are Java file that contain messages.Bundle.properties
file: First specify a unique key that identifies this string; then an equal sign; and the literal string itself. greeting=Hello World! score.display=Score:
ResourceBundle.getBundle("Bundle").getString("greeting")); UiText.setText(ResourceBundle.getBundle("Bundle").getString("score.display")+score);
The language used in the Bundle.properties files will be the default language for your game.
Each additional language comes in a set of files that is marked with a (usually) two-letter suffix. Common locales are de for German, en for English, fr for French, ja for Japanese, pt for Portuguese, etc.
To translate the messages to another language, for example, German:
Bundle.properties
files.Bundle_de.properties
for German. Note the added suffix _de.Bundle_de.properties
to German.greeting=Hallo Welt! score.display=Spielstand:
Important: Do not modify any of the keys (text to the left of the equal sign)!
-Duser.language=de
. Note the parameter de
.Tip: In the jMonkeyPlatform, you set this VM Option in the Project properties under Run. Here you can also save individual run configuraions for each language you want to test.
To get the full list of language suffixes use
Locale.getISOLanguages()));
Important: In the Bundle.properties file, do not include any strings that are asset paths, node or geometry names, input mappings, or material layers.
mat.setTexture("ColorMap", tex);
teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
Geometry thing=new Geometry("A thing", mesh); Node vehicle = new Node("Vehicle");
inputManager.addMapping("Shoot", trigger); inputManager.addListener(actionListener, "Shoot");
Only localize messages and UI text!
Typical problems include: