I've just started writing my first JavaFX 2 application after learning the basics and would like to internationalize it.
I notice that in JavaFX 1.x, the scripting language allowed for very simple internationalization of strings. Are there any similar features in JavaFX 2?
Basically: what is the best practice for internationalizing a JavaFX 2 application?
Best Answer
The basic steps (among others) of a java app internationalizing, are
Locale
lizing and resource bundling. In JavaFX, you can useFXMLLoader#setResources()
for that purposes. Here a SSCCE demo to demonstrate it. The codes are self-descriptive.Demo package structure:
MyBundle_en.properties
MyBundle_kg.properties
MyView.fxml
MyController.java
BundleDemo.java
Screenshot:
If your internationalized text needs to be rendered in a font that might be on the user's target system, then you can either:
OR
If the required font is not available, then the internationalized text might be displayed as unintelligible gibberish, even though everything else about the setup is fine.