I am building a JavaFX application with multi language support. So while loading the
fxml file by:
AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("fxml/RealTimeInitialPanel.fxml"),Language.getBundle());
I am passing the resource bundle based on the default
Language class extends ResourceBundle and returns String based on the current Locale. To change language, I just have to call up
Language.setLocale(..). Everything works well.
But say now the user changes the language on the go. How do I signal the fxml or UI to refresh the screen. That way they will again call up
getString(..) and the text gets updated based on the setLocale. In swing, it does refresh periodically. But with fx iam unable to
At per Benefits of FXML, matter no 3:
The content of an FXML file can be localized as the file is read. For example, if an FXML file is loaded using the en_US locale, then it produces the string "First Name" for a label based on the following resource string: If the locale is changed to fr_FR and the FXML file is reloaded, then the label shows "Prénom." ...
So if you are aiming to localize the app through
FXMLLoader then you cannot signal FXML to refresh its bundled texts other than reloading it again, I think.