Java FXML 支持国际化,可以通过以下步骤实现:
messages_en.properties 和 messages_zh.properties。在这些文件中添加需要翻译的文本。例如:# messages_en.properties
hello=Hello
world=World
# messages_zh.properties
hello=你好
world=世界
ResourceBundle 类来加载资源文件。根据需要选择不同的语言版本。例如:import java.util.Locale;
import java.util.ResourceBundle;
public class Internationalization {
    public static void main(String[] args) {
        Locale locale = new Locale("zh"); // 选择中文
        ResourceBundle bundle = ResourceBundle.getBundle("messages", locale);
        System.out.println(bundle.getString("hello") + " " + bundle.getString("world"));
    }
}
fx:include 标签引入 ResourceBundle。例如:   <Label text="%hello" />
   <Label text="%world" />
</AnchorPane>
FXMLLoader 的 setResources() 方法设置 ResourceBundle。例如:import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
public class Controller {
    @FXML
    private void switchLanguage() {
        Locale locale = new Locale("zh"); // 选择中文
        ResourceBundle bundle = ResourceBundle.getBundle("messages", locale);
        FXMLLoader loader = new FXMLLoader(getClass().getResource("your_fxml_file.fxml"), bundle);
        Parent root = null;
        try {
            root = loader.load();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Stage stage = new Stage();
        stage.setScene(new Scene(root));
        stage.show();
    }
}
switchLanguage() 方法即可。例如,可以在按钮的点击事件中调用该方法。这样,就可以实现 Java FXML 的国际化操作了。