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

2006/unicorn/src/org/w3c/unicorn/util Language.java,1.15,1.16

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 13 Oct 2009 13:31:55 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MxhTn-0001ue-3N@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv7338/src/org/w3c/unicorn/util

Modified Files:
	Language.java 
Log Message:
arguments passed as "string parameters" to evaluate() can be properties keys.

Index: Language.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/Language.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Language.java	13 Oct 2009 11:34:35 -0000	1.15
+++ Language.java	13 Oct 2009 13:31:53 -0000	1.16
@@ -109,7 +109,10 @@
 		if (Framework.getLanguageProperties().get(lang) == null)
 			return messageKey;
 		
-		String message = Framework.getLanguageProperties().get(lang).getProperty(messageKey.replace("$", ""));
+		if (messageKey.startsWith("$"))
+			messageKey = messageKey.replace("$", "");
+		
+		String message = Framework.getLanguageProperties().get(lang).getProperty(messageKey);
 		
 		if (message == null)
 			return messageKey;
@@ -122,7 +125,11 @@
 		if (args == null)
 			return result;
 		for (String str : args) {
-			result = result.replaceAll("%"+i, str);
+			if (str.startsWith("$"))
+				str = str.replace("$", "");
+			
+			String string = Framework.getLanguageProperties().get(lang).getProperty(str) != null ? Framework.getLanguageProperties().get(lang).getProperty(str) : str; 
+			result = result.replaceAll("%"+i, string);
 			i++;
 		}
 		return result;
Received on Tuesday, 13 October 2009 13:31:57 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:39 UTC