- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 02 Oct 2009 16:50:53 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action In directory hutz:/tmp/cvs-serv24701/src/org/w3c/unicorn/action Added Files: LanguageAction.java Log Message: improved isComplete method --- NEW FILE: LanguageAction.java --- package org.w3c.unicorn.action; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Hashtable; import java.util.Properties; import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.velocity.VelocityContext; import org.w3c.unicorn.Framework; import org.w3c.unicorn.util.Language; import org.w3c.unicorn.util.Message; import org.w3c.unicorn.util.Property; import org.w3c.unicorn.util.Templates; /** * Servlet implementation class LanguageServlet */ public class LanguageAction extends Action { private static final long serialVersionUID = 1L; private static TreeMap<String, Properties> languageProperties; /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (!Framework.isUcnInitialized) { Framework.init(); if (!Framework.isUcnInitialized) { resp.sendError(500, "Unicorn is not initialized properly. Check logs."); return; } } String defaultLang = Property.get("DEFAULT_LANGUAGE"); ArrayList<Message> messages = new ArrayList<Message>(); resp.setContentType("text/html; charset=UTF-8"); VelocityContext velocityContext = new VelocityContext(Language.getContext(defaultLang)); velocityContext.put("queryString", "./"); velocityContext.put("messages", messages); velocityContext.put("baseUri", "./"); Hashtable<String, String> languages = new Hashtable<String, String>(); languages.put(defaultLang, languageProperties.get(defaultLang).getProperty("language")); velocityContext.put("languages", languages); velocityContext.put("languageProps", languageProperties); velocityContext.put("defaultProps", languageProperties.get(defaultLang)); PrintWriter writer = resp.getWriter(); Templates.write("language.vm", velocityContext, writer); //writer.println(languageProperties); //writer.println(languages); writer.close(); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } public static void addLanguageProperties(Properties props) { languageProperties.put(props.getProperty("lang"), (Properties) props.clone()); } public static TreeMap<String, Properties> getLanguageProperties() { return languageProperties; } public static void setLanguageProperties(TreeMap<String, Properties> languageProperties) { LanguageAction.languageProperties = languageProperties; } }
Received on Friday, 2 October 2009 16:50:54 UTC