spoke spoke - 3 months ago 30
Java Question

dialog internationalization in javafx

I fount a problem in my code because it translates some words (in this case a button) according to the language of the os. I've searched for solutions but I didn't find anything to fit my case. As far as I've seen bundles are used to translate strings.

Here is my problem explicitly:
enter image description here

My problem is that instead of cancel it writes "Annuler", the french word.

Here is the code for the dialog:

printerSet.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ChoiceDialog<String> dialog = new ChoiceDialog<>(
"Dummy Printer", choices);
dialog.setTitle("Choice Dialog");
dialog.setHeaderText(null);
dialog.setContentText("Choose the printer you want to use:");

Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String opt = result.get();
System.out.println("Your choice: " + opt);
printerLabel.setText("Selected Printer: " + opt);
}

printButton.setDisable(true);
name.setText("");
code.setText("");
description.setText("");
availability.setText("");
}
});


Does anyone know a solution?

Answer

Try to provide the following JVM arguments at start-up:

java -Duser.language=en -Duser.country=US ...