whitespace fixups
[jSite2.git] / src / net / pterodactylus / jsite / i18n / I18n.java
index 90df053..4647ddc 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.Properties;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.swing.KeyStroke;
@@ -40,9 +41,8 @@ import net.pterodactylus.util.logging.Logging;
 
 /**
  * Class that handles i18n.
- * 
+ *
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- * @version $Id$
  */
 public class I18n {
 
@@ -78,7 +78,7 @@ public class I18n {
        /**
         * Returns the translated value for a key. The translated values may contain
         * placeholders that are replaced with the given parameters.
-        * 
+        *
         * @see MessageFormat
         * @param key
         *            The key to get
@@ -92,7 +92,7 @@ public class I18n {
                String value = null;
                value = currentLanguage.getProperty(key);
                if (value == null) {
-                       logger.warning("please fix “" + key + "”!");
+                       logger.log(Level.WARNING, "please fix “" + key + "”!", new Throwable());
                        /* TODO - replace with value when done! */
                        return null;
                }
@@ -106,7 +106,7 @@ public class I18n {
         * Returns the keycode from the value of the given key. You can specify the
         * constants in {@link KeyEvent} in the properties file, e.g. VK_S for the
         * keycode ‘s’ when used for mnemonics.
-        * 
+        *
         * @param key
         *            The key under which the keycode is stored
         * @return The keycode
@@ -133,7 +133,7 @@ public class I18n {
 
        /**
         * Returns a key stroke for use with swing accelerators.
-        * 
+        *
         * @param key
         *            The key of the key stroke
         * @return The key stroke, or <code>null</code> if no key stroke could be
@@ -156,6 +156,9 @@ public class I18n {
                                modifierMask |= InputEvent.SHIFT_DOWN_MASK;
                        } else {
                                if (keyToken.startsWith("VK_")) {
+                                       if (keyToken.equals("VK_UNDEFINED")) {
+                                               return null;
+                                       }
                                        try {
                                                Field field = KeyEvent.class.getField(keyToken);
                                                return KeyStroke.getKeyStroke(field.getInt(null), modifierMask);
@@ -177,7 +180,7 @@ public class I18n {
 
        /**
         * Sets the current locale.
-        * 
+        *
         * @param newLocale
         *            The new locale to use
         */
@@ -187,7 +190,7 @@ public class I18n {
 
        /**
         * Sets the current locale.
-        * 
+        *
         * @param newLocale
         *            The new locale to use
         * @param notify
@@ -223,7 +226,7 @@ public class I18n {
 
        /**
         * Returns the current locale.
-        * 
+        *
         * @return The current locale
         */
        public static Locale getLocale() {
@@ -232,7 +235,7 @@ public class I18n {
 
        /**
         * Finds all available locales.
-        * 
+        *
         * @return All available locales
         */
        public static List<Locale> findAvailableLanguages() {
@@ -244,7 +247,7 @@ public class I18n {
 
        /**
         * Registers the given I18nable to be updated when the language is changed.
-        * 
+        *
         * @param i18nable
         *            The i18nable to register
         */
@@ -255,7 +258,7 @@ public class I18n {
        /**
         * Deregisters the given I18nable to be updated when the language is
         * changed.
-        * 
+        *
         * @param i18nable
         *            The i18nable to register
         */
@@ -271,7 +274,7 @@ public class I18n {
         * Notifies all registered {@link I18nable}s that the language was changed.
         */
        private static void notifyI18nables() {
-               for (I18nable i18nable: i18nables) {
+               for (I18nable i18nable : i18nables) {
                        i18nable.updateI18n();
                }
        }