2006/unicorn/src/org/w3c/unicorn/action Action.java,1.13,1.14

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv24339/src/org/w3c/unicorn/action

Modified Files:
	Action.java 
Log Message:
only one language related message is displayed
+ added logger

Index: Action.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Action.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Action.java	30 Sep 2009 13:35:32 -0000	1.13
+++ Action.java	30 Sep 2009 15:02:41 -0000	1.14
@@ -6,6 +6,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Locale;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -13,6 +14,8 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.unicorn.Framework;
 import org.w3c.unicorn.util.Language;
 import org.w3c.unicorn.util.Message;
@@ -22,6 +25,8 @@
 	
 	private static final long serialVersionUID = -7503310240481494239L;
 	
+	private static Log logger = LogFactory.getLog(Action.class);
+	
 	@Override
 	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
 			throws ServletException, IOException {
@@ -60,13 +65,6 @@
 		String lang;
 		if (langParameter == null || !Framework.getLanguageProperties().containsKey(langParameter)) {
 			lang = Language.negociate(req.getLocales());
-			if (langParameter != null && !Framework.getLanguageProperties().containsKey(langParameter)) {
-				if (Language.isISOLanguageCode(langParameter)) {
-					messages.add(new Message(Message.Level.INFO, "$message_unavailable_requested_language (" + langParameter + ")", null));
-				} else {
-					messages.add(new Message(Message.Level.INFO, "$message_invalid_requested_language (" + langParameter + ")", null));
-				}
-			}
 		} else
 			lang = langParameter;
 		
@@ -77,6 +75,16 @@
 			messages.add(new Message(Message.Level.INFO, "$message_incomplete_language. $message_translation", null));
 		else if (!Framework.getLanguageProperties().containsKey(req.getLocale().getLanguage()) && Property.get("SHOW_LANGUAGE_UNAVAILABLE_MESSAGE").equals("true"))
 			messages.add(new Message(Message.Level.INFO, "$message_unavailable_language (" + req.getLocale().getDisplayLanguage(req.getLocale()) + "). $message_translation", null));
+		else if (langParameter != null && !Framework.getLanguageProperties().containsKey(langParameter)) {
+			if (Language.isISOLanguageCode(langParameter)) {
+				Locale locale = Language.getLocale(langParameter);
+				if (locale == null)
+					logger.warn("Missing locale: " + langParameter + ". This locale should be installed on the system in order to translate Unicorn in this language.");
+				messages.add(new Message(Message.Level.INFO, "$message_unavailable_requested_language (" + locale.getDisplayLanguage(locale) + "). $message_translation", null));
+			} else {
+				messages.add(new Message(Message.Level.INFO, "$message_invalid_requested_language (" + langParameter + ")", null));
+			}
+		}
 		
 		return lang;
 	}

Received on Wednesday, 30 September 2009 15:02:45 UTC