2

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..

  1. does the jre plugin include translations for different languages
  2. 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

  1. The JRE does in fact provide translations for other languages.
  2. 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...

  1. 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.
  2. 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.

stuckless
  • 6,515
  • 2
  • 19
  • 27
  • similair question was asked one - two weeks back (I hope and if I remember correctly) under Swing or AWT tag – mKorbel Jun 20 '12 at 14:49
  • thanks... I searched stackoverflow for `awt.properties` and I got 2 hits... 1 was my my question :) and the other makes reference to the awt.properties, but that's it. http://stackoverflow.com/search?q=awt.properties – stuckless Jun 20 '12 at 14:54
  • [I meaning this one](http://stackoverflow.com/questions/10952130/localized-accelerators-jmenuitem-hotkeys-in-swing) – mKorbel Jun 20 '12 at 15:21
  • Thanks. That simply changes the locale (which I'm doing)... the rest of my app is in German, except for the "CTRL" identifier. Ironically that user is seeing German, but they want English... and I have english but using a German Locale, I still see English :( – stuckless Jun 20 '12 at 15:35

0 Answers0