diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index 9593746ef186947f06e3b0e98122a951403ae4ea..32acd96591d93e840b23c901388d7c3a201ff0ed 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -22,7 +22,6 @@ import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.gui.MainPanel; import de.hhu.ba.yoshikoWrapper.gui.SolutionsPanel; - public class CyActivator extends AbstractCyActivator { public CyActivator() { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java index ec76cf412ef6fafcd3507cb0d6f22c77fed6ce75..99807cbdf1befbcfc8a0b61a7fe06f4196d838ec 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java @@ -5,11 +5,21 @@ import java.util.HashMap; import java.util.Locale; import java.util.ResourceBundle; +/** Static collection of functions and states representing the current locale and providing access to localized strings + * This class should never be initialized + */ public class LocalizationManager { + /** + * Default constructor, hidden to prevent invocation + */ + private LocalizationManager() {}; + //Locales + static private final Locale usEnglish = new Locale("en","US"); static private final Locale german = new Locale("de","DE"); + //Map static private final HashMap<String, Locale> locales; static @@ -24,10 +34,28 @@ public class LocalizationManager { static private Locale currentLocale = usEnglish; + + private static void updateBundle() { + currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLocale); + CyCore.cm.getProperties().setProperty( + "locale", + currentLocale.getLanguage()+currentLocale.getCountry() + ); + } + + + //SETTER/GETTER methods + static public Collection<Locale> getLocales(){ return locales.values(); } + /** + * Returns the localized string corresponding to the given key. + * This is the main method that should be used for accessing strings and is preferable to any use of constant strings. + * @param key The key for the string (refer to YoshikoStrings.properties for all possible keys) + * @return The localized string + */ static public String get(String key) { if (currentBundle == null) { currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLocale); @@ -45,14 +73,6 @@ public class LocalizationManager { currentLocale = locales.get(key); updateBundle(); } - - private static void updateBundle() { - currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLocale); - CyCore.cm.getProperties().setProperty( - "locale", - currentLocale.getLanguage()+currentLocale.getCountry() - ); - } public static Locale getCurrentLocale() { return currentLocale;