- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 01 Sep 2009 13:39:43 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv18414/src/org/w3c/unicorn
Modified Files:
Framework.java
Log Message:
added languages merging
+ messages on index
Index: Framework.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Framework.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Framework.java 31 Aug 2009 12:00:31 -0000 1.5
+++ Framework.java 1 Sep 2009 13:39:41 -0000 1.6
@@ -35,7 +35,6 @@
import org.w3c.unicorn.contract.WADLUnmarshallerXPath;
import org.w3c.unicorn.exceptions.InitializationFailedException;
import org.w3c.unicorn.exceptions.UnknownParserException;
-import org.w3c.unicorn.language.Language;
import org.w3c.unicorn.response.parser.ResponseParser;
import org.w3c.unicorn.tasklist.RDFUnmarshaller;
import org.w3c.unicorn.tasklist.RDFUnmarshallerJena;
@@ -43,6 +42,7 @@
import org.w3c.unicorn.tasklist.TaskListUnmarshallerBeans;
import org.w3c.unicorn.tasklist.Tasklist;
import org.w3c.unicorn.tasklist.TasksListUnmarshaller;
+import org.w3c.unicorn.util.Language;
import org.w3c.unicorn.util.ListFiles;
import org.w3c.unicorn.util.Property;
import org.w3c.unicorn.util.UCNProperties;
@@ -420,14 +420,48 @@
}
File defaultLanguageFile = new File(Property.get("PATH_TO_LANGUAGE_FILES", "DEFAULT_LANGUAGE") + ".properties");
- if (!defaultLanguageFile.exists()) {
- throw new InitializationFailedException("Default language file does not exists: " + Property.get("PATH_TO_LANGUAGE_FILES", "DEFAULT_LANGUAGE") + ".properties");
+ Properties defaultProps = new Properties();
+
+ try {
+ defaultProps = Language.load(defaultLanguageFile);
+ logger.debug("> Found language (default): " + defaultProps.getProperty("lang") + " - " + defaultProps.getProperty("language"));
+ defaultProps.put("complete", "true");
+ languageProperties.put(Property.get("DEFAULT_LANGUAGE"), defaultProps);
+ } catch (IllegalArgumentException e) {
+ logger.warn(e.getMessage());
+ } catch (FileNotFoundException e) {
+ throw new InitializationFailedException("Default language file does not exists: " + defaultLanguageFile.getPath());
+ } catch (IOException e) {
+ throw new InitializationFailedException("Unable to read default language file. " + defaultLanguageFile.getPath());
}
- File[] languageFiles = ListFiles.listFiles(Property
- .get("PATH_TO_LANGUAGE_FILES"), "\\.properties$");
+
+ File[] languageFiles = ListFiles.listFiles(Property.get("PATH_TO_LANGUAGE_FILES"), "\\.properties$");
for (File langFile : languageFiles) {
+ if (langFile.equals(defaultLanguageFile))
+ continue;
+
+ try {
+ Properties props = Language.load(langFile);
+ logger.debug("> Found language: " + props.getProperty("lang") + " - " + props.getProperty("language"));
+ Language.complete(props, defaultProps);
+ languageProperties.put(props.getProperty("lang"), props);
+ } catch (IllegalArgumentException e) {
+ logger.warn(e.getMessage());
+ } catch (FileNotFoundException e) {
+ // Should not happen
+ logger.error(e.getMessage(), e);
+ } catch (IOException e) {
+ logger.error("Unable to read language file. " + langFile + ". This file will be skiped.");
+ }
+
+ }
+
+ /*for (File langFile : languageFiles) {
+ if (langFile == defaultLanguageFile)
+ continue;
+
String localeString = langFile.getName().split("\\.")[0];
if (!Language.isISOLanguageCode(localeString))
logger.warn("Invalid language file: " + langFile.getName() + "" +
@@ -439,7 +473,8 @@
Properties props = new Properties();
props.load(isr);
props.put("lang", localeString);
- props.put("tasklist", mapOfTask);
+ //props.put("tasklist", mapOfTask);
+ //Language.complete(props);
languageProperties.put(localeString, props);
String s;
if (localeString.equals(Property.get("DEFAULT_LANGUAGE")))
@@ -463,7 +498,8 @@
}
}
}
- }
+ }*/
+
if (languageProperties.size() == 0) {
throw new InitializationFailedException("No language have been loaded. Check language files in: " + Property.get("PATH_TO_LANGUAGE_FILES"));
} else {
Received on Tuesday, 1 September 2009 13:39:54 UTC