- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 13 Oct 2009 15:10:43 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action In directory hutz:/tmp/cvs-serv3816/src/org/w3c/unicorn/action Modified Files: LanguageAction.java Log Message: name, mail, and comments are kept in case of an error + the translated properties file is alphabetically ordered + $native_lang added to context Index: LanguageAction.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/LanguageAction.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- LanguageAction.java 13 Oct 2009 12:57:46 -0000 1.18 +++ LanguageAction.java 13 Oct 2009 15:10:41 -0000 1.19 @@ -37,6 +37,7 @@ import org.w3c.unicorn.util.Property; import org.w3c.unicorn.util.Templates; import org.w3c.unicorn.util.Mail; +import org.w3c.unicorn.util.UCNProperties; /** * Servlet implementation class LanguageServlet @@ -82,13 +83,15 @@ velocityContext.put("messages", messages); velocityContext.put("baseUri", "./"); velocityContext.put("availableLocales", availableLocales); - + velocityContext.put("native_lang", req.getLocale().getLanguage()); + velocityContext.put("translator_name", req.getAttribute("translator_name")); + velocityContext.put("translator_mail", req.getAttribute("translator_mail")); + velocityContext.put("translator_comments", req.getAttribute("translator_comments")); Hashtable<String, String> languages = new Hashtable<String, String>(); languages.put(defaultLang, defaultProperties.get("language")); velocityContext.put("languages", languages); - languageProperties.remove(defaultLang); velocityContext.put("languageProps", languageProperties); velocityContext.put("defaultProps", defaultProperties); @@ -161,7 +164,7 @@ doGet(req, resp); return; } else { - Properties langProps; + UCNProperties langProps; if (languageProperties.get(languageParameter) == null) { langProps = createProperties(languageParameter); contextObjects.put("new_translation", true); @@ -170,7 +173,7 @@ return; } } else - langProps = (Properties) languageProperties.get(languageParameter).clone(); + langProps = (UCNProperties) languageProperties.get(languageParameter).clone(); StringBuilder changeLog = new StringBuilder(); boolean changed = false; @@ -198,6 +201,9 @@ MessageList messages = new MessageList(); messages.add(new Message(Message.WARNING, "You haven't made any changes.")); req.setAttribute("messages", messages); + req.setAttribute("translator_name", req.getParameter("translator_name")); + req.setAttribute("translator_mail", req.getParameter("translator_mail")); + req.setAttribute("translator_comments", req.getParameter("translator_comments")); doGet(req, resp); return; } @@ -207,6 +213,9 @@ messages.add(new Message(Message.WARNING, "Please enter your name and your email address so we can contact you.")); req.setAttribute("messages", messages); req.setAttribute("submitted_props", langProps); + req.setAttribute("translator_name", req.getParameter("translator_name")); + req.setAttribute("translator_mail", req.getParameter("translator_mail")); + req.setAttribute("translator_comments", req.getParameter("translator_comments")); doGet(req, resp); return; } @@ -219,6 +228,9 @@ messages.add(new Message(Message.WARNING, "The email address you entered is invalid.")); req.setAttribute("messages", messages); req.setAttribute("submitted_props", langProps); + req.setAttribute("translator_name", req.getParameter("translator_name")); + req.setAttribute("translator_mail", req.getParameter("translator_mail")); + req.setAttribute("translator_comments", req.getParameter("translator_comments")); doGet(req, resp); return; } @@ -264,8 +276,8 @@ } } - private Properties createProperties(String langParameter) { - Properties props = new Properties(); + private UCNProperties createProperties(String langParameter) { + UCNProperties props = new UCNProperties(); Locale locale = Language.getLocale(langParameter); if (locale == null) return null; @@ -275,7 +287,8 @@ } public static void addLanguageProperties(Properties props) { - languageProperties.put(props.getProperty("lang"), (Properties) props.clone()); + if (!props.getProperty("lang").equals(Property.get("DEFAULT_LANGUAGE"))) + languageProperties.put(props.getProperty("lang"), (Properties) props.clone()); } public static TreeMap<String, Properties> getLanguageProperties() {
Received on Tuesday, 13 October 2009 15:10:45 UTC