- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 13 Aug 2009 13:42:44 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/language In directory hutz:/tmp/cvs-serv2554/src/org/w3c/unicorn/language Modified Files: Tag: dev2 Language.java Log Message: more actions in Framework + IndexAction + language negociation structure Index: Language.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/language/Attic/Language.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- Language.java 12 Aug 2009 17:28:04 -0000 1.1.2.5 +++ Language.java 13 Aug 2009 13:42:42 -0000 1.1.2.6 @@ -9,11 +9,13 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Locale; +import java.util.Map; import java.util.Properties; import java.util.Set; import org.apache.velocity.VelocityContext; import org.w3c.unicorn.util.Property; +import org.w3c.unicorn.Framework; public class Language { @@ -46,6 +48,20 @@ } } + public static void addToContext(Properties langProps, VelocityContext context) throws Exception { + Set<Object> keys = langProps.keySet(); + Iterator<Object> itr = keys.iterator(); + String key; + while (itr.hasNext()) { + key = itr.next().toString(); + context.put(key, langProps.get(key)); + } + + for (Object keyss : langProps.keySet()) { + context.put((String) keyss, langProps.get(keyss)); + } + } + public static Locale negociate(String langParameter, Enumeration locales) { // TODO Auto-generated method stub @@ -64,6 +80,15 @@ props.load(langFile.toURI().toURL().openStream()); //languages.put(locale, props); } + + public static VelocityContext getContext(String langParameter) { + if (langParameter == null) + return Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE")); + if (Framework.getLanguageContexts().containsKey(langParameter)) + return Framework.getLanguageContexts().get(langParameter); + else + return Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE")); + } }
Received on Thursday, 13 August 2009 13:42:57 UTC