JavaFX provides an easy way to internationalize your user interfaces. While creating a view from an FXML file you can provide the FXMLLoader
with a resource bundle:
Locale locale = new Locale("en", "UK");
ResourceBundle bundle = ResourceBundle.getBundle("strings", locale);
Parent root = FXMLLoader.load(getClass().getClassLoader()
.getResource("ui/main.fxml"), bundle);
This provided bundle is automatically used to translate all texts in your FXML file that start with a %
.
Lets say your properties file strings_en_UK.properties
contains the following line:
ui.button.text=I'm a Button
If you have a button definition in your FXML like this:
<Button text="%ui.button.text"/>
It will automatically receive the translation for the key ui.button.text
.