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

2006/unicorn/src/org/w3c/unicorn/language Language.java,1.1.2.6,1.1.2.7

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 13 Aug 2009 17:28:36 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Mbe6O-0003tB-Aj@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/language
In directory hutz:/tmp/cvs-serv14852/src/org/w3c/unicorn/language

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

Index: Language.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/language/Attic/Language.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- Language.java	13 Aug 2009 13:42:42 -0000	1.1.2.6
+++ Language.java	13 Aug 2009 17:28:34 -0000	1.1.2.7
@@ -19,10 +19,6 @@
 
 public class Language {
 	
-	public Language() {
-		
-	}
-	
 	public static boolean isISOLanguageCode(String languageCode) {
 		String[] isoCodes = Locale.getISOLanguages();
 		for (String code : isoCodes) {
@@ -62,11 +58,14 @@
 	    }
 	}
 	
-	public static Locale negociate(String langParameter, Enumeration locales) {
-		// TODO Auto-generated method stub
-		
-		return new Locale("en");
-		
+	public static String negociate(Enumeration locales) {
+		while (locales.hasMoreElements()) {
+			Locale loc = (Locale) locales.nextElement();
+			if (Framework.getLanguageProperties().containsKey(loc.getLanguage())) {
+				return loc.getLanguage();
+			}
+		}
+		return Property.get("DEFAULT_LANGUAGE");
 	}
 	
 	public static void addLanguageFile(File langFile) throws MalformedURLException, IOException {
@@ -82,13 +81,11 @@
 	}
 
 	public static VelocityContext getContext(String langParameter) {
-		if (langParameter == null)
-			return Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE"));
-		if (Framework.getLanguageContexts().containsKey(langParameter))
+		System.out.println(langParameter);
+		if (langParameter != null && Framework.getLanguageContexts().containsKey(langParameter))
 			return Framework.getLanguageContexts().get(langParameter);
 		else
 			return Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE"));
 	}
 	
-	
 }
Received on Thursday, 13 August 2009 17:28:46 UTC

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