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

2006/unicorn/src/org/w3c/unicorn/action LanguageAction.java,1.15,1.16

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 13 Oct 2009 12:00:15 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Mxg35-0005bc-Jy@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv21534/src/org/w3c/unicorn/action

Modified Files:
	LanguageAction.java 
Log Message:
Displays a warning message in case the translator did not specify his name or mail address. His previous translations are not lost

Index: LanguageAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/LanguageAction.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- LanguageAction.java	12 Oct 2009 16:15:45 -0000	1.15
+++ LanguageAction.java	13 Oct 2009 12:00:13 -0000	1.16
@@ -108,7 +108,12 @@
 					else 
 						messages.add(new Message(Message.INFO, "This translation is complete but you can help us to improve it if needed."));
 				}
-				velocityContext.put("prop", languageProperties.get(langParameter));
+				if (req.getAttribute("submitted_props") != null) {
+					Properties submittedProps = (Properties) req.getAttribute("submitted_props");
+					velocityContext.put("prop", submittedProps);
+				} else {
+					velocityContext.put("prop", languageProperties.get(langParameter));
+				}
 			} else if (Language.isISOLanguageCode(langParameter)) {
 				Locale locale = Language.getLocale(langParameter);
 				if (locale == null) {
@@ -195,24 +200,30 @@
 				return;
 			}
 			
+			if ("".equals(req.getParameter("translator_name")) || "".equals(req.getParameter("translator_mail"))) {
+				MessageList messages = new MessageList();
+				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);
+				doGet(req, resp);
+				return;
+			}
+			
+			contextObjects.put("translator_name", req.getParameter("translator_name"));
+			contextObjects.put("translator_mail", req.getParameter("translator_mail"));
+			contextObjects.put("translator_comments", req.getParameter("translator_comments"));
+			contextObjects.put("language", Language.getLocale(languageParameter).getDisplayLanguage(Locale.ENGLISH));
+			contextObjects.put("changeLog", changeLog);
+			
+			langProps.remove("lang");
+			langProps.remove("language");
+			
 			ByteArrayOutputStream baos = new ByteArrayOutputStream();
 			OutputStreamWriter osw = new OutputStreamWriter(baos, "UTF-8");
 			langProps.store(osw, "Submitted by " + req.getParameter("translator_name") + " <" + req.getParameter("translator_mail") + ">");
 			osw.close();
 			baos.close();
 			contextObjects.put("properties", baos.toString("UTF-8"));
-			contextObjects.put("changeLog", changeLog);
-			
-			if (!"".equals(req.getParameter("translator_name")))
-				contextObjects.put("translator_name", req.getParameter("translator_name"));
-			else
-				contextObjects.put("translator_name", "Anonymous");
-			if (!"".equals(req.getParameter("translator_mail")))
-				contextObjects.put("translator_mail", req.getParameter("translator_mail"));
-			else 
-				contextObjects.put("translator_mail", "Not specified");
-			contextObjects.put("translator_comments", req.getParameter("translator_comments"));
-			contextObjects.put("language", Language.getLocale(languageParameter).getDisplayLanguage(Locale.ENGLISH));
 			
 			MessageList messages = new MessageList();
 			messages.add(new Message(Message.INFO, "Thank you for your submission."));
Received on Tuesday, 13 October 2009 12:00:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:15 GMT