How can this be achieved? I have the ff. test code:
javax.swing.JOptionPane.showMessageDialog(null, "Hello, world!");
Running it with, say, -Duser.language=zh
and -Duser.country=TW
doesn't work. I.e., the OK button is still labeled "OK". In Windows, for example, it is replaced with the Traditional Chinese equivalent.
Prioritize the corresponding language in System Preferences > International.
Aqua is used if the LAF isn't specified. It doesn't respect the default locale probably because it's very much integrated into the OS.
If a cross-platform LAF is used (e.g., Metal), the problem is not observed.