Author: fred
Date: 2007-09-16 13:34:18 +0000 (Sun, 16 Sep 2007)
New Revision: 15202
Modified:
trunk/plugins/Echo/src/plugins/echo/Echo.java
trunk/plugins/Echo/src/plugins/echo/editor/StaticPage.java
trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java
Log:
FIX : NPE caused by the class loader
Modified: trunk/plugins/Echo/src/plugins/echo/Echo.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Echo.java 2007-09-16 11:13:26 UTC
(rev 15201)
+++ trunk/plugins/Echo/src/plugins/echo/Echo.java 2007-09-16 13:34:18 UTC
(rev 15202)
@@ -78,11 +78,11 @@
if(!BASE_DIR.exists())
BASE_DIR.mkdirs();
- i18n = new I18n("en");
+ I18n.setLanguage("en");
parser = new Builder();
- Document styleSheet =
parser.build(getClass().getResourceAsStream("/xml/edit2.xsl"));
+ Document styleSheet =
parser.build(getClass().getResourceAsStream("/xml/edit.xsl"));
i18n.translateXML(styleSheet);
transform = new XSLTransform(styleSheet);
Modified: trunk/plugins/Echo/src/plugins/echo/editor/StaticPage.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/editor/StaticPage.java 2007-09-16
11:13:26 UTC (rev 15201)
+++ trunk/plugins/Echo/src/plugins/echo/editor/StaticPage.java 2007-09-16
13:34:18 UTC (rev 15202)
@@ -30,7 +30,7 @@
try {
Builder parser = new Builder();
- Document doc =
parser.build(ClassLoader.getSystemClassLoader().getResourceAsStream("/xml/" +
fileName));
+ Document doc =
parser.build(page.getClass().getResourceAsStream("/xml/" + fileName));
I18n.translateXML(doc);
page.appendContent(doc.getRootElement().copy());
Modified: trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java 2007-09-16 11:13:26 UTC
(rev 15201)
+++ trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java 2007-09-16 13:34:18 UTC
(rev 15202)
@@ -25,15 +25,14 @@
public static final String SUFFIX = ".properties";
private static String selectedLanguage;
- private static Properties translation;
+ private static Properties translation = new Properties();
private static Properties defaultTranslation = null;
- public I18n(String language) throws MissingResourceException {
+
+ private static final I18n INSTANCE = new I18n();
- translation = new Properties();
- setLanguage(language);
+ private I18n() {}
- }
/**
* Set the language
@@ -60,7 +59,7 @@
if(props == null)
props = new Properties();
try {
-
props.load(ClassLoader.getSystemClassLoader().getResourceAsStream("/i18n/" +
PREFIX + language + SUFFIX));
+
props.load(INSTANCE.getClass().getResourceAsStream("/i18n/" + PREFIX + language
+ SUFFIX));
} catch (IOException ioe) {
Logger.error("I18n", "IOException while accessing the "
+ language +"file" + ioe.getMessage(), ioe);
throw new MissingResourceException("Unable to load the
translation file for " + language, "i18n", language);
@@ -91,7 +90,6 @@
return key;
}
}
-
}
/**