W3C home > Mailing lists > Public > www-validator-cvs@w3.org > March 2010

2006/unicorn/src/org/w3c/unicorn/util Language.java,1.16,1.17

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 03 Mar 2010 17:20:45 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1NmsFZ-0006VF-UM@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv24967/src/org/w3c/unicorn/util

Modified Files:
	Language.java 
Log Message:
Cleans any unexisting property from a language file before using it

Index: Language.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/Language.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Language.java	13 Oct 2009 13:31:53 -0000	1.16
+++ Language.java	3 Mar 2010 17:20:43 -0000	1.17
@@ -6,6 +6,7 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Locale;
 import java.util.Properties;
@@ -66,6 +67,18 @@
 		}
 	}
 	
+	public static void clean(UCNProperties props, UCNProperties defaultProps) {
+		ArrayList<String> keys = new ArrayList<String>();
+		for (Object key : props.keySet()) {
+			if (!defaultProps.containsKey(key)) {
+				keys.add((String) key);
+				Framework.logger.error(">> Unexisting property in " + props.getProperty("lang") + ".properties for key: \"" + (String) key + "\". This property should be removed manually from the language file."); 
+			}
+		}
+		for (String key : keys)
+			props.remove(key);
+	}
+	
 	public static UCNProperties load(File langFile) throws IllegalArgumentException, FileNotFoundException, IOException {
 
 		String localeString = langFile.getName().split("\\.")[0];
Received on Wednesday, 3 March 2010 17:20:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:19 GMT