Author: tchemit Date: 2012-08-29 22:18:09 +0200 (Wed, 29 Aug 2012) New Revision: 1974 Url: http://nuiton.org/repositories/revision/i18n/1974 Log: refs #2290: Introduce a simple struts2 jsp parser Modified: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserStruts2Mojo.java Modified: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserStruts2Mojo.java =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserStruts2Mojo.java 2012-08-29 20:13:39 UTC (rev 1973) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserStruts2Mojo.java 2012-08-29 20:18:09 UTC (rev 1974) @@ -43,7 +43,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; -import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -132,14 +131,11 @@ /** * Pattern used to detect i18n keys. * - * @since 2.3 + * @since 2.5 */ protected final Pattern i18nPattern = - Pattern.compile("(?:%\\{getText\\(\\\"|text name=\\\"|key=\\\")(.*?)\""); + Pattern.compile("(?:%\\{getText\\(\\\"|text name=\\\"|key=\\\")(.*?)\"|(?:text\\s*name='|key=')(.*?)'"); - protected final Pattern i18nPattern2 = - Pattern.compile("(?:text\\s*name='|key=')(.*?)'"); - public Struts2JspFileParser(Log log, String encoding, SortedProperties oldParser, @@ -178,34 +174,17 @@ Matcher matcher = i18nPattern.matcher(line); - boolean match = false; while (matcher.find()) { - match = true; String key = matcher.group(1); + if (key == null) { + key = matcher.group(2); + } if (getLog().isDebugEnabled()) { getLog().debug(file.getName() + " detected key = " + key); } // register key registerKey(key); } - - if (!match) { - - // try with second pattern - matcher = i18nPattern2.matcher(line); - - while (matcher.find()) { - String key = matcher.group(1); - if (getLog().isDebugEnabled()) { - getLog().debug(file.getName() + " detected key = " + key); - } -// // one key found in file, so file is marked as touched -// setTouched(true); - - // register key - registerKey(key); - } - } } }