|
@@ -15,26 +15,32 @@ Localizing an application can mean several things:
|
|
|
* At minimum you translate all messages and dialogs in the user interface to your target languages.
|
|
* At minimum you translate all messages and dialogs in the user interface to your target languages.
|
|
|
* You should also translate the “read me, help, and other documentation.
|
|
* You should also translate the “read me, help, and other documentation.
|
|
|
* Also translating web content related to the application makes sure international users find out about your localized game.
|
|
* Also translating web content related to the application makes sure international users find out about your localized game.
|
|
|
-* If you go the whole way of internationalization, you also “translate metaphors in icons or symbols used. +E.g. For localizations to right-to-left languages, you must also adjust the whole flow of the UI (order of menus and buttons).
|
|
|
|
|
|
|
+* If you go the whole way of internationalization, you also “translate metaphors in icons or symbols used. +
|
|
|
|
|
+E.g. For localizations to right-to-left languages, you must also adjust the whole flow of the UI (order of menus and buttons).
|
|
|
|
|
|
|
|
There are tools that assist you with localizing Java Swing GUIs. jME3 applications do not typically have a Swing +++<abbr title="Graphical User Interface">GUI</abbr>+++, so those tools are not of much help. Just stick to the normal Java rules about using Bundle Properties:
|
|
There are tools that assist you with localizing Java Swing GUIs. jME3 applications do not typically have a Swing +++<abbr title="Graphical User Interface">GUI</abbr>+++, so those tools are not of much help. Just stick to the normal Java rules about using Bundle Properties:
|
|
|
|
|
|
|
|
|
|
|
|
|
== Preparing the Localization
|
|
== Preparing the Localization
|
|
|
|
|
|
|
|
-*Tip:* The jMonkeyEngine SDK supports opening and editing Bundle.properties files. Also note the Tools > Localization menu.
|
|
|
|
|
|
|
+[TIP]
|
|
|
|
|
+====
|
|
|
|
|
+The jMonkeyEngine SDK 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.
|
|
To prepare the application for localization, you have to first identify all hard-coded messages.
|
|
|
|
|
|
|
|
-. Find every line in your jME3 game where you hard-coded message strings, e.g. +
|
|
|
|
|
|
|
+. Find every line in your jME3 game where you hard-coded message strings, e.g.
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
System.out.print("Hello World!");
|
|
System.out.print("Hello World!");
|
|
|
-UiText.setText("Score: "+score);
|
|
|
|
|
|
|
+UiText.setText("Score: " + score);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
. Create one file named `Bundle.properties` in each directory where there are Java file that contain messages.
|
|
. Create one file named `Bundle.properties` in each directory where there are Java file that contain messages.
|
|
|
-. For every hard-coded message, you add one line to the `Bundle.properties` file: First specify a unique key that identifies this string; then an equal sign; and the literal string itself. +
|
|
|
|
|
|
|
+. For every hard-coded message, you add one line to the `Bundle.properties` file: First specify a unique key that identifies this string; then an equal sign; and the literal string itself.
|
|
|
|
|
++
|
|
|
[source]
|
|
[source]
|
|
|
----
|
|
----
|
|
|
greeting=Hello World!
|
|
greeting=Hello World!
|
|
@@ -42,10 +48,11 @@ score.display=Score:
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
. In the source code, replace every occurence of a hard-coded message with the appropriate Resource Bundle call to its unique key:
|
|
. In the source code, replace every occurence of a hard-coded message with the appropriate Resource Bundle call to its unique key:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
System.out.print(ResourceBundle.getBundle("Bundle").getString("greeting"));
|
|
System.out.print(ResourceBundle.getBundle("Bundle").getString("greeting"));
|
|
|
-UiText.setText(ResourceBundle.getBundle("Bundle").getString("score.display")+score);
|
|
|
|
|
|
|
+UiText.setText(ResourceBundle.getBundle("Bundle").getString("score.display") + score);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
@@ -61,17 +68,24 @@ To translate the messages to another language, for example, German:
|
|
|
. Make a copy of the `Bundle.properties` files.
|
|
. Make a copy of the `Bundle.properties` files.
|
|
|
. Name the copy `Bundle_de.properties` for German. Note the added suffix _de.
|
|
. Name the copy `Bundle_de.properties` for German. Note the added suffix _de.
|
|
|
. Translate all strings (text on the right side of the equal sign) in the `Bundle_de.properties` to German.
|
|
. Translate all strings (text on the right side of the equal sign) in the `Bundle_de.properties` to German.
|
|
|
|
|
++
|
|
|
[source]
|
|
[source]
|
|
|
----
|
|
----
|
|
|
greeting=Hallo Welt!
|
|
greeting=Hallo Welt!
|
|
|
score.display=Spielstand:
|
|
score.display=Spielstand:
|
|
|
----
|
|
----
|
|
|
-
|
|
|
|
|
- *Important:* Do not modify any of the keys (text to the left of the equal sign)!
|
|
|
|
|
|
|
++
|
|
|
|
|
+[IMPORTANT]
|
|
|
|
|
+====
|
|
|
|
|
+Do not modify any of the keys (text to the left of the equal sign)!
|
|
|
|
|
+====
|
|
|
|
|
|
|
|
. To test the German localization, start the application from the command line with `-Duser.language=de`. Note the parameter `de`.
|
|
. To test the German localization, start the application from the command line with `-Duser.language=de`. Note the parameter `de`.
|
|
|
-
|
|
|
|
|
-*Tip:* In the jMonkeyEngine SDK, 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.
|
|
|
|
|
|
|
++
|
|
|
|
|
+[TIP]
|
|
|
|
|
+====
|
|
|
|
|
+In the jMonkeyEngine SDK, 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
|
|
To get the full list of language suffixes use
|
|
|
|
|
|
|
@@ -83,21 +97,27 @@ System.out.println(Arrays.toString(Locale.getISOLanguages()));
|
|
|
|
|
|
|
|
== Which Strings Not to Translate
|
|
== Which Strings Not to Translate
|
|
|
|
|
|
|
|
-*Important:* In the Bundle.properties file, do not include any strings that are asset paths, node or geometry names, input mappings, or material layers.
|
|
|
|
|
|
|
+[IMPORTANT]
|
|
|
|
|
+====
|
|
|
|
|
+In the Bundle.properties file, do not include any strings that are asset paths, node or geometry names, input mappings, or material layers.
|
|
|
|
|
+====
|
|
|
|
|
|
|
|
* Keep material layers:
|
|
* Keep material layers:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
mat.setTexture("ColorMap", tex);
|
|
mat.setTexture("ColorMap", tex);
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
* Keep paths:
|
|
* Keep paths:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
|
|
teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
* Keep geometry and node names:
|
|
* Keep geometry and node names:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
Geometry thing=new Geometry("A thing", mesh);
|
|
Geometry thing=new Geometry("A thing", mesh);
|
|
@@ -105,6 +125,7 @@ Node vehicle = new Node("Vehicle");
|
|
|
----
|
|
----
|
|
|
|
|
|
|
|
* Keep mappings:
|
|
* Keep mappings:
|
|
|
|
|
++
|
|
|
[source,java]
|
|
[source,java]
|
|
|
----
|
|
----
|
|
|
inputManager.addMapping("Shoot", trigger);
|
|
inputManager.addMapping("Shoot", trigger);
|