JDK-8150841 : Button text are not following Locale change in Alert
  • Type: Bug
  • Component: javafx
  • Sub-Component: localization
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-02-29
  • Updated: 2016-09-20
  • Resolved: 2016-03-04
Related Reports
Duplicate :  
Relates :  
Description
If you show an Alert in Java, the Button text (inside ButtonType.java) are taking the Locale from the JVM at initialization.

But if you switch your Locale inside your application, the button text are left in the previous language. 


Comments
JDK-8088397 is now fixed in 8u82.
04-03-2016

My apologies. This is a duplicate of JDK-8088397, which is only fixed in JDK 9. Kevin, is there a chance for a backport of that one to 8u?
04-03-2016

I just ran your code under JDK 8u73 and I have the button text in French the first time, and still in French the second time. Do you have an extra argument that you give to the JVM?
04-03-2016

You need to create new instances of your Alerts. Test case: import java.util.Locale; import javafx.application.*; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.stage.Stage; public class JDK8150841 extends Application { @Override public void start(Stage primaryStage) { Scene scene = new Scene(new Button("Hello World")); primaryStage.setScene(scene); primaryStage.show(); Platform.runLater(() -> { Locale.setDefault(Locale.FRANCE); new Alert(Alert.AlertType.CONFIRMATION, "OK?").showAndWait(); Locale.setDefault(Locale.GERMANY); new Alert(Alert.AlertType.CONFIRMATION, "OK?").showAndWait(); }); } }
03-03-2016

What do you mean "rebuild the GUI"? You mean killing the JVM and launch another instance? Because if I'm popping an Alert, then closing it, then changing the Locale, then popping an Alert again. The button text are still in the old Locale.
03-03-2016

JavaFX does not support automatically changing translated strings in controls. After changing the default Locale, an application must rebuild the GUI, or at least those parts that contain translated text. See also evaluation for JDK-8149818.
03-03-2016