正如上面的评论中提到的,这只是我过去翻译的一个例子。这不会在FXML中进行翻译。
FXML代码段(frmCalendar.FXML)
<Label fx:id="lblTitle" text="Title"/>
控制器类代码段(CalendarController.java)
if (!Locale.getDefault().getLanguage().equals("en")) {
lblTitle.setText(TranslationManager.translate("en", Locale.getDefault().getLanguage(), lblTitle.getText());
}
翻译管理器java代码段
public class TranslationManager {
public static String translate(String langFrom, String langTo, String text){
//Here is where you would read your excel file and return the text in the desired language.
}
}
这里有一个很棒的
question about reading excel files
如果你不熟悉这个过程。