diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java index b99952d..a0bc583 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java @@ -1,13 +1,17 @@ package application; import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Paths; import java.util.Locale; +import java.util.Properties; import java.util.ResourceBundle; +import com.sun.tools.javac.Main; + /*********************************************************************** * * @@ -15,10 +19,11 @@ public class ApplicationLanguage { private Locale locale = null; private ResourceBundle resBundle = null; + private Properties properties = null; private static ApplicationLanguage instance = null; - private final static String RESOURCE_PATH = ".\\resources\\locales"; + private final static String RESOURCE_PATH = "resources/locales/"; public final static String JP = "ja"; public final static String EN = "en"; @@ -52,21 +57,31 @@ * */ public void setLocaleLanguage(final String language) { - File dicDirectory = Paths.get(RESOURCE_PATH).toFile(); - URLClassLoader urlLoader = null; + URL resURL = null; try { - urlLoader = new URLClassLoader(new URL[] { dicDirectory.toURI().toURL() }); + File resDir = Paths.get(RESOURCE_PATH).toFile(); // for Eclipse project + resURL = resDir.toURI().toURL(); } catch (MalformedURLException e) { - return; + e.printStackTrace(); } - +// resURL = Main.class.getClassLoader().getResource(RESOURCE_PATH); // for executable jar + URLClassLoader urlLoader = new URLClassLoader(new URL[] { resURL }); this.resBundle = ResourceBundle.getBundle(language, this.locale, urlLoader); + +// // Another method. +// properties = new Properties(); +// try { +// properties.load(Main.class.getClassLoader().getResourceAsStream(RESOURCE_PATH + language + ".properties")); +// } catch (IOException e) { +// return; +// } } /*********************************************************************** * */ public String getOptionByPropName(final String propName) { +// return properties.getProperty(propName); return this.resBundle.getString(propName); } }