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

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 UTC