In a Java Plugin, I'm displaying KeyEvent.getKeyText(VK_CTRL)
in an Action
, but I want it to be shown in different Languages, depending on the Locale of the user. For example, in English, it's CTRL
, but in German it is Strg
. In reading the documentation for getKeyText it says
Returns a String describing the modifier key(s), such as "Shift", or "Ctrl+Shift". These strings can be localized by changing the awt.properties file.
My questions are..
- does the jre plugin include translations for different languages
- if I need to provide translations, how do I include them in my plugin. Do I simply add an
awt_de.properties
to the root of jar? Does it need to put somewhere else.
In searching for awt.properties
I can find very little except for references to it in books and javadoc, and some references about updating it in your home directory, which I cannot do, since this is a plugin.
ANSWER
- The JRE does in fact provide translations for other languages.
- I still don't know where "awt.properties" is found, but it doesn't matter, since the Plugin has translations.
The issue for me is 2 fold...
- You cannot use Locale.setDefault() from an applet, and while JComponent.setDefaultLocale() does set the Locale for most things, there are still some things like KeyEvent.getKeyText that uses Locale.getDefault.
- Applets Ignore the browsers locale and use the OS locale.
So the fix, is that the end user must set their OS locale to German (in this case) which, you would expect that would already be the case for a German user.