In order to improve the user experience for MacOS users, I use the "native" menubar, but the native/default menu items remain in English when I change the default locale.
I set System.setProperty("apple.laf.useScreenMenuBar", "true");
Further, I use System.setProperty("com.apple.mrj.application.apple.menu.about.name", "My app name);
. I also use desktop.setQuitHandler(...)
and desktop.setPreferenceHandler(...)
.
If I change the default Locale of my app to fr_FR for instance (Locale.setDefault(new Locale("fr", "FR"));
), all my JMenu and JMenuItem are correctly translated in French (using a ResourceBundle for instance), but the "native" menu items ("About", "Quit", "Settings...") remain in English.
Is there a way to display these "native" menu items using another locale ?
In order to improve the user experience for MacOS users, I use the "native" menubar, but the native/default menu items remain in English when I change the default locale.
I set System.setProperty("apple.laf.useScreenMenuBar", "true");
Further, I use System.setProperty("com.apple.mrj.application.apple.menu.about.name", "My app name);
. I also use desktop.setQuitHandler(...)
and desktop.setPreferenceHandler(...)
.
If I change the default Locale of my app to fr_FR for instance (Locale.setDefault(new Locale("fr", "FR"));
), all my JMenu and JMenuItem are correctly translated in French (using a ResourceBundle for instance), but the "native" menu items ("About", "Quit", "Settings...") remain in English.
Is there a way to display these "native" menu items using another locale ?
Share Improve this question asked Jan 31 at 17:52 Bart JourquinBart Jourquin 401 bronze badge 4 |1 Answer
Reset to default 0In trying to narrow down the problem, I realized that there's probably a problem with Java and the (latest? version of) MacOS. Indeed, the following snippet seems to indicate that not all Locale's work. In this case, Locale.FRANCE doesn't work (the “Cancel”, “No”, “Yes” buttons remain in English), whereas Locale.GERMANY does. The initial problem I described may be related to this.
import java.util.Locale;
import javax.swing.JOptionPane;
public class Test {
public static void main(String[] args) {
//Locale.setDefault(Locale.FRANCE); // Doesn't work
Locale.setDefault(Locale.GERMANY); // Works !
JOptionPane.showConfirmDialog(null, "Message");
}
}
LANG
orLC_ALL
environment variable set. You may also have success by setting theuser.language
anduser.country
system properties on the command line. (I do not understand the downvotes for this question. It’s a perfectly legitimate application design goal, and it clearly describes attempts to address the issue.) – VGR Commented Feb 1 at 14:22