W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2009

2006/unicorn/src/org/w3c/unicorn/language Language.java,1.1.2.4,1.1.2.5

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 12 Aug 2009 17:28:06 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MbHcM-0005cG-P2@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/language
In directory hutz:/tmp/cvs-serv21455/src/org/w3c/unicorn/language

Modified Files:
      Tag: dev2
	Language.java 
Log Message:
language initialization

Index: Language.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/language/Attic/Language.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -d -r1.1.2.4 -r1.1.2.5
--- Language.java	7 Aug 2009 12:03:42 -0000	1.1.2.4
+++ Language.java	12 Aug 2009 17:28:04 -0000	1.1.2.5
@@ -1,36 +1,35 @@
 package org.w3c.unicorn.language;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Enumeration;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Properties;
 import java.util.Set;
 
-import javax.servlet.http.HttpServletRequest;
 import org.apache.velocity.VelocityContext;
 import org.w3c.unicorn.util.Property;
 
 public class Language {
-
+	
 	public Language() {
 		
 	}
 	
-	public static boolean isLocale(String string) {
-		Locale[] locales = Locale.getAvailableLocales();
-		for (Locale loc : locales) {
-			if (loc.getDisplayLanguage().equals(string))
+	public static boolean isISOLanguageCode(String languageCode) {
+		String[] isoCodes = Locale.getISOLanguages();
+		for (String code : isoCodes) {
+			if (code.equals(languageCode))
 				return true;
 		}
 		return false;
 	}
-
-	public static Locale getLocale(HttpServletRequest request) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
+	
 	public static void addToContext(VelocityContext velocityContext, Locale lang) throws Exception {
 		File languageFile = new File(Property.get("PATH_TO_LANGUAGE_FILES") + lang.getLanguage() + ".properties");
 		FileReader fr = new FileReader(languageFile);
@@ -46,4 +45,25 @@
 			velocityContext.put(key, langProps.get(key));
 	    }
 	}
+	
+	public static Locale negociate(String langParameter, Enumeration locales) {
+		// TODO Auto-generated method stub
+		
+		return new Locale("en");
+		
+	}
+	
+	public static void addLanguageFile(File langFile) throws MalformedURLException, IOException {
+		String fileName = langFile.getName();
+		String locale = fileName.split("\\.")[0];
+		if (!isISOLanguageCode(locale)) {
+			return;
+		}
+		//Locale locale = new Locale(localeString);
+		Properties props = new Properties();
+		props.load(langFile.toURI().toURL().openStream());
+		//languages.put(locale, props);
+	}
+	
+	
 }
Received on Wednesday, 12 August 2009 17:28:16 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:38 UTC