【发布时间】:2016-06-28 17:13:54
【问题描述】:
我正在尝试使用 Afterburner.fx (https://github.com/AdamBien/afterburner.fx/) 在 JavaFX 中创建多语言软件。我不明白是否有办法设置或注入 Afterburner 视图使用的资源包,也不知道是否有办法让不同的资源包到不同的视图并在运行时更改资源包。
在普通的 javafx 中,可以为 fxml 视图设置资源包,如下例所示,但是如何使用 afterburner 执行此操作?
private void loadView(Locale locale) {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
// Here, just the resource bundles name is mentioned. You can add support for more languages
// by adding more properties-files with language-specific endings like
// "E_13_Internationalization_fr.properties".
fxmlLoader.setResources(ResourceBundle.getBundle("E_13_Internationalization", locale));
Pane pane = (BorderPane) fxmlLoader.load(this.getClass().getResource("/E_13_Internationalization.fxml").openStream());
borderPane.setCenter(pane);
} catch (IOException ex) {
ex.printStackTrace();
}
}
【问题讨论】:
标签: java javafx resourcebundle