- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 06 Oct 2009 08:16:04 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util In directory hutz:/tmp/cvs-serv21432/src/org/w3c/unicorn/util Modified Files: Language.java XHTMLize.java Log Message: working on language strings Index: Language.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/Language.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Language.java 2 Oct 2009 16:51:05 -0000 1.6 +++ Language.java 6 Oct 2009 08:16:02 -0000 1.7 @@ -9,7 +9,6 @@ import java.util.Enumeration; import java.util.Locale; import java.util.Properties; - import org.apache.velocity.VelocityContext; import org.w3c.unicorn.Framework; @@ -61,7 +60,7 @@ } } - public static Properties load(File langFile) throws IllegalArgumentException, FileNotFoundException, IOException { + public static UCNProperties load(File langFile) throws IllegalArgumentException, FileNotFoundException, IOException { String localeString = langFile.getName().split("\\.")[0]; if (!Language.isISOLanguageCode(localeString)) @@ -71,7 +70,7 @@ InputStreamReader isr; try { isr = new InputStreamReader(fis, "UTF-8"); - Properties props = new Properties(); + UCNProperties props = new UCNProperties(); props.load(isr); props.put("lang", localeString); return props; @@ -97,4 +96,18 @@ return testedProps.get("complete").equals("true"); } + public static String evaluate(String lang, String messageKey, String... args) { + if (Framework.getLanguageProperties().get(lang) == null) + return messageKey; + + String message = Framework.getLanguageProperties().get(lang).getProperty(messageKey.replace("$", "")); + String result = message; + int i = 1; + for (String str : args) { + result = result.replaceAll("%"+i, str); + i++; + } + return result; + } + } Index: XHTMLize.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/XHTMLize.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XHTMLize.java 14 Sep 2009 15:50:15 -0000 1.5 +++ XHTMLize.java 6 Oct 2009 08:16:02 -0000 1.6 @@ -43,7 +43,7 @@ Code code = (Code) oValue; return insertCode(code); } - if (sReference.startsWith("$noEscape_")) + if (sReference.startsWith("$ucn.evaluate")) return oValue.toString(); else return StringEscapeUtils.escapeHtml(oValue.toString());
Received on Tuesday, 6 October 2009 08:16:10 UTC