From 83adffedad14d80a2790dd7df2f6ff1c53e7898f Mon Sep 17 00:00:00 2001 From: Philipp Spohr <spohr.philipp@web.de> Date: Sun, 20 Aug 2017 01:42:15 +0200 Subject: [PATCH] Added some javadoc --- .../de/hhu/ba/yoshikoWrapper/CyActivator.java | 1 - .../core/LocalizationManager.java | 36 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index 9593746..32acd96 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 ec76cf4..99807cb 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; -- GitLab