I18n-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
January 2011
- 4 participants
- 41 discussions
19 Jan '11
Author: tchemit
Date: 2011-01-19 23:02:10 +0100 (Wed, 19 Jan 2011)
New Revision: 1845
Url: http://nuiton.org/repositories/revision/i18n/1845
Log:
fix svn-keywords
Modified:
trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java
Property changes on: trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
r1844 - in trunk/nuiton-i18n/src: main/java/org/nuiton/i18n main/java/org/nuiton/i18n/bundle main/java/org/nuiton/i18n/init main/java/org/nuiton/util test/java/org/nuiton/i18n test/java/org/nuiton/util test/java/org/nuiton/util/converter test/resources/META-INF
by tchemit@users.nuiton.org 19 Jan '11
by tchemit@users.nuiton.org 19 Jan '11
19 Jan '11
Author: tchemit
Date: 2011-01-19 22:38:53 +0100 (Wed, 19 Jan 2011)
New Revision: 1844
Url: http://nuiton.org/repositories/revision/i18n/1844
Log:
Evolution #1210: Remove deprecated api
Evolution #1208: Be able to force locale for translation (add some tests)
Added:
trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java
trunk/nuiton-i18n/src/test/java/org/nuiton/util/converter/
trunk/nuiton-i18n/src/test/java/org/nuiton/util/converter/LocaleConverterTest.java
Removed:
trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java
trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java
Modified:
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java
trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java
trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_en_GB.properties
trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_fr_FR.properties
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -128,12 +128,13 @@
}
/**
- * Retourne la chaine traduite si possible.
+ * Retourne la chaine traduite si possible dans la locale demandée.
*
* @param locale la locale dans lequel on souhaite la traduction
* @param message la chaine a traduire
* @return la traduction si possible ou la chaine passee en parametre
* sinon.
+ * @since 2.1
*/
public static String l_(Locale locale, String message) {
@@ -150,14 +151,16 @@
return applyFilter(result);
}
- /**
- * Retourne la chaine traduite si possible.
+ /**
+ * Retourne la chaine traduite si possible dans la locale demandée.
*
+ * @param locale la locale dans lequel on souhaite la traduction
* @param message message formate avec la meme syntaxe que {@link
* String#format}
* @param args les parametres pour le message.
* @return la traduction si possible ou la chaine passee en parametre
* sinon.
+ * @since 2.1
*/
public static String l_(Locale locale, String message, Object... args) {
@@ -273,7 +276,7 @@
}
/**
- * close i18n caches, says the store if exists
+ * Close i18n caches, says the store if exists.
* <p/>
* This method should be called to reset all caches (languages,
* bundles,...)
@@ -335,49 +338,4 @@
return filter;
}
- /**
- * @return the current store
- * @deprecated since 1.1, only keep for compatibility
- */
- @Deprecated
- public static I18nStore getLoader() {
- return getStore();
- }
-
- /**
- * Parse a list of {@link Locale} seperated by comma.
- * <p/>
- * Example : fr_FR,en_GB
- *
- * @param str the string representation of locale separated by comma
- * @return list of available locales
- * @throws IllegalArgumentException ia a locale is not valid
- * @deprecated since 1.1, prefer use the {@link I18nUtil#parseLocales(String)}
- */
- @Deprecated
- public static Locale[] parseLocales(String str)
- throws IllegalArgumentException {
- return I18nUtil.parseLocales(str);
- }
-
- /**
- * @param str the text representation of the locale
- * @return the locale, or default locale if could not parse the given one
- * @deprecated since 1.1, prefer use the {@link I18nUtil#newLocale(String)}
- */
- @Deprecated
- public static Locale newLocale(String str) {
- return I18nUtil.newLocale(str);
- }
-
- /**
- * @param language the language of the locale
- * @param country the country of the locale
- * @return the required locale
- * @deprecated since 1.1, prefer use the {@link I18nUtil#newLocale(String,String)}
- */
- @Deprecated
- public static Locale newLocale(String language, String country) {
- return I18nUtil.newLocale(language, country);
- }
}
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -23,7 +23,7 @@
* #L%
*/
-/* *
+/**
* i18nFilter.java
*
* Created: 2 déc. 2003
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -158,7 +158,7 @@
}
I18nLanguage result = getLanguage(locale);
language = result;
- //TC-20090702 the selected langue is the default locale, usefull for
+ //TC-20090702 the selected language is the default locale, usefull for
// objects dealing with the default locale (swing widgets,...)
Locale.setDefault(locale);
}
@@ -166,7 +166,7 @@
/**
* Close store and release cache ofg language.
* <p/>
- * Current language will be also clean.
+ * Current language will be also cleaned.
*/
protected void close() {
if (languages != null) {
@@ -186,8 +186,14 @@
}
/**
+ * Recherche un object de type {@link I18nLanguage} pour la locale donnée
+ * en paramètre dans le cache des langues chargées ({@link #languages}).
+ *
+ * Si un tel objet n'existe pas, alors on en crée un et on le place dans le
+ * cache.
+ *
* @param locale la locale du language recherche
- * @return le language trouve dans le cache, ou null.
+ * @return le language trouve dans le cache.
*/
protected I18nLanguage getLanguage(Locale locale) {
I18nLanguage result = null;
@@ -208,7 +214,6 @@
}
}
-
return result;
}
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -61,13 +61,6 @@
public static final String DIRECTORY_SEARCH_BUNDLE_PATTERN = "i18n";
- /**
- * @deprecated since 2.0, this is not compatible with os, so do not used it
- * any more.
- */
- @Deprecated
- public static final String SEARCH_BUNDLE_PATTERN = ".*i18n/.+\\.properties";
-
private static final I18nBundleEntry[] EMPTY_I18N_BUNDLE_ENTRYS_ARRAY =
new I18nBundleEntry[0];
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -116,12 +116,11 @@
@Override
public I18nBundle[] resolvBundles() throws Exception {
- // detect bundles urls
+ // detect bundles urls
URL[] urls = resolvURLs();
// detect bundles
-
I18nBundle[] result = resolvBundles(urls);
return result;
}
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -162,10 +162,9 @@
return definitionURL;
}
-// @Override
+ public URL[] resolvURLs(String prefixURL,
+ Properties definition) throws Exception {
- public URL[] resolvURLs(String prefixURL, Properties definition) throws Exception {
-
// get locales from properties
String localesAsStr = definition.getProperty(BUNDLE_DEF_LOCALES);
@@ -206,11 +205,9 @@
String prefixURL = resolvDefinition(definition);
// detect bundles urls
-
URL[] urls = resolvURLs(prefixURL, definition);
// detect bundles
-
I18nBundle[] result = resolvBundles(urls);
return result;
}
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -158,20 +158,16 @@
}
// detect bundles urls
-
URL[] urls = resolvURLs(prefixURL, definition);
// detect bundles
-
I18nBundle[] bundles = resolvBundles(urls);
// detect bundles entries
-
I18nBundleEntry[] entries =
I18nBundleUtil.getBundleEntries(bundles);
// copy all bundle entries resource
-
for (I18nBundleEntry e : entries) {
URL url = e.getPath();
@@ -190,8 +186,7 @@
log.info("Create user file to create : " + dst);
}
- // recopie du fichier
-
+ // copy file
outStream = new FileOutputStream(dst);
try {
IOUtils.copy(url.openStream(), outStream);
Deleted: trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -1,149 +0,0 @@
-/*
- * #%L
- * I18n :: Api
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.util;
-
-import org.apache.commons.beanutils.ConversionException;
-import org.apache.commons.beanutils.Converter;
-import static org.apache.commons.logging.LogFactory.getLog;
-
-import org.apache.commons.logging.Log;
-import org.nuiton.i18n.CountryEnum;
-import org.nuiton.i18n.LanguageEnum;
-
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * classe pour convertir une chaine en un objet {@link Locale}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @deprecated since 2.0.1, use the {@link org.nuiton.util.converter.LocaleConverter} instead
- */
-@Deprecated
-public class LocaleConverter implements Converter {
-
- private static final Pattern FULL_SCOPE_PATTERN =
- Pattern.compile("([a-zA-Z]{2})_([a-zA-Z]{2})");
-
- private static final Pattern MEDIUM_SCOPE_PATTERN =
- Pattern.compile("([a-zA-Z]{2})");
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static Log log = getLog(LocaleConverter.class);
-
- @Override
- public Object convert(Class aClass, Object value) {
- if (value == null) {
- throw new ConversionException("can not convert null value in " +
- this + " convertor");
- }
- if (isEnabled(aClass)) {
- Object result;
- if (isEnabled(value.getClass())) {
- result = value;
- return result;
- }
- if (value instanceof String) {
- result = valueOf(((String) value).trim());
- return result;
- }
- }
- throw new ConversionException(
- "could not find a convertor for type " + aClass.getName() +
- " and value : " + value);
- }
-
- public Locale valueOf(String value) {
- try {
- Locale result = convertFullScope(value);
-
- if (result == null) {
- result = convertMediumScope(value);
- }
-
- if (result == null) {
- throw new ConversionException("could not convert locale " +
- value);
- }
-
- return result;
- } catch (Exception e) {
- throw new ConversionException("could not convert locale " + value +
- " for reason " + e.getMessage());
- }
- }
-
- private Locale convertFullScope(String value) {
- Matcher m = FULL_SCOPE_PATTERN.matcher(value);
- if (m.matches()) {
- // found a full scope pattern (language + country)
- LanguageEnum language =
- LanguageEnum.valueOf(m.group(1).toLowerCase());
- CountryEnum country = CountryEnum.valueOf(m.group(2).toUpperCase());
- if (language == null || country == null) {
- // not safe
- throw new ConversionException("could not convert locale " +
- value);
- }
- return new Locale(language.name(), country.name());
- }
- return null;
- }
-
- private Locale convertMediumScope(String value) {
- Matcher m = MEDIUM_SCOPE_PATTERN.matcher(value);
- if (m.matches()) {
- // found a medium scope pattern (only language)
- LanguageEnum language =
- LanguageEnum.valueOf(m.group(1).toLowerCase());
-
- if (language == null) {
- // not safe
- throw new ConversionException("could not convert locale " +
- value);
- }
- return new Locale(language.name());
- }
- return null;
- }
-
-
- public LocaleConverter() {
- if (log.isDebugEnabled()) {
- log.debug(this);
- }
- }
-
- protected boolean isEnabled(Class<?> aClass) {
- return Locale.class.equals(aClass);
- }
-
- public Class<?> getType() {
- return Locale.class;
- }
-
-}
Modified: trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -51,7 +51,7 @@
I18nStore store;
@BeforeClass
- public static void beforeClass() throws MalformedURLException {
+ public static void beforeClass() {
I18n.setInitializer(
new DefaultI18nInitializer(I18nStoreTest.class.getSimpleName())
);
Added: trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java (rev 0)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -0,0 +1,113 @@
+package org.nuiton.i18n;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+
+import java.util.Locale;
+
+/**
+ * Test the class {@link I18n}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+public class I18nTest {
+
+ @BeforeClass
+ public static void beforeClass() {
+ I18n.setInitializer(
+ new DefaultI18nInitializer(I18nStoreTest.class.getSimpleName())
+ );
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ I18n.setInitializer(null);
+ I18n.close();
+ }
+
+ @Test
+ public void testSimple() {
+
+ String expected;
+ String actual;
+
+ // passage en français
+
+ I18n.getStore().setLanguage(Locale.FRANCE);
+
+ expected = "Clef avec %s";
+ actual = I18n._("key.with.param");
+ Assert.assertEquals(expected, actual);
+
+ expected = "Clef avec param";
+ actual = I18n._("key.with.param", "param");
+ Assert.assertEquals(expected, actual);
+
+ // passage en anglais
+
+ I18n.getStore().setLanguage(Locale.UK);
+
+ expected = "Key with %s";
+ actual = I18n._("key.with.param");
+ Assert.assertEquals(expected, actual);
+
+ expected = "Key with param";
+ actual = I18n._("key.with.param", "param");
+ Assert.assertEquals(expected, actual);
+
+ // passage langue inconnue
+
+ I18n.getStore().setLanguage(Locale.CHINA);
+
+ expected = "key.with.param";
+ actual = I18n._("key.with.param");
+ Assert.assertEquals(expected, actual);
+
+ expected = "key.with.param";
+ actual = I18n._("key.with.param", "param");
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testMultiLanguage() {
+
+ String expected;
+ String actual;
+
+ // en français
+
+ expected = "Clef avec %s";
+ actual = I18n.l_(Locale.FRANCE, "key.with.param");
+ Assert.assertEquals(expected, actual);
+
+ expected = "Clef avec param";
+ actual = I18n.l_(Locale.FRANCE, "key.with.param", "param");
+ Assert.assertEquals(expected, actual);
+
+ // en anglais
+
+ I18n.getStore().setLanguage(Locale.UK);
+
+ expected = "Key with %s";
+ actual = I18n.l_(Locale.UK, "key.with.param");
+ Assert.assertEquals(expected, actual);
+
+ expected = "Key with param";
+ actual = I18n.l_(Locale.UK, "key.with.param", "param");
+ Assert.assertEquals(expected, actual);
+
+ // dans une langue inconnue
+
+ expected = "key.with.param";
+ actual = I18n.l_(Locale.CHINA, "key.with.param");
+ Assert.assertEquals(expected, actual);
+
+ expected = "key.with.param";
+ actual = I18n.l_(Locale.CHINA, "key.with.param", "param");
+ Assert.assertEquals(expected, actual);
+ }
+}
Property changes on: trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -1,137 +0,0 @@
-/*
- * #%L
- * I18n :: Api
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.util;
-
-import junit.framework.TestCase;
-import org.apache.commons.beanutils.Converter;
-
-import java.util.Locale;
-
-/**
- * Tests {@link LocaleConverter}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- */
-public class LocaleConverterTest extends TestCase {
-
- String toConvert;
-
- Locale excepted;
-
- Converter converter;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- converter = new LocaleConverter();
- }
-
- public void testConvertFull() throws Exception {
- toConvert = "fr_FR";
- excepted = Locale.FRANCE;
- assertEquals(toConvert, excepted);
-
- toConvert = "fr_fr";
- assertEquals(toConvert, excepted);
-
- toConvert = "FR_fr";
- assertEquals(toConvert, excepted);
-
- toConvert = "FR_FR";
- assertEquals(toConvert, excepted);
-
- toConvert = "\n\tFr_fR ";
- assertEquals(toConvert, excepted);
-
- toConvert = "en_GB";
- excepted = Locale.UK;
- assertEquals(toConvert, excepted);
-
- toConvert = "en_US";
- excepted = Locale.US;
- assertEquals(toConvert, excepted);
-
- //TODO Arch, we must also check coherence !
- toConvert = "fr_GB";
- excepted = new Locale("fr", "GB");
- assertEquals(toConvert, excepted);
- }
-
- public void testConvertMedium() throws Exception {
- toConvert = "fr";
- excepted = new Locale("fr");
- assertEquals(toConvert, excepted);
-
- toConvert = "fR";
- assertEquals(toConvert, excepted);
-
- toConvert = "FR";
- assertEquals(toConvert, excepted);
-
- toConvert = " fR \t";
- assertEquals(toConvert, excepted);
-
- toConvert = "en";
- excepted = new Locale("en");
- assertEquals(toConvert, excepted);
-
- toConvert = "es";
- excepted = new Locale("es");
- assertEquals(toConvert, excepted);
-
- }
-
- public void testConvertFailed() throws Exception {
-
- toConvert = null;
- assertConvertFailed(toConvert);
-
- toConvert = "";
- assertConvertFailed(toConvert);
-
- toConvert = "fr_";
- assertConvertFailed(toConvert);
-
- toConvert = "_FR";
- assertConvertFailed(toConvert);
-
- }
-
- protected void assertEquals(String toConvert, Locale expected) {
- Object result = converter.convert(Locale.class, toConvert);
- assertEquals(expected, result);
- }
-
- protected void assertConvertFailed(String toConvert) {
- try {
- converter.convert(Locale.class, toConvert);
- fail();
- } catch (Exception e) {
- assertTrue(true);
- }
-
- }
-}
Copied: trunk/nuiton-i18n/src/test/java/org/nuiton/util/converter/LocaleConverterTest.java (from rev 1842, trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java)
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/util/converter/LocaleConverterTest.java (rev 0)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/util/converter/LocaleConverterTest.java 2011-01-19 21:38:53 UTC (rev 1844)
@@ -0,0 +1,137 @@
+/*
+ * #%L
+ * I18n :: Api
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.util.converter;
+
+import junit.framework.TestCase;
+import org.apache.commons.beanutils.Converter;
+
+import java.util.Locale;
+
+/**
+ * Tests {@link LocaleConverter}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class LocaleConverterTest extends TestCase {
+
+ String toConvert;
+
+ Locale excepted;
+
+ Converter converter;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ converter = new LocaleConverter();
+ }
+
+ public void testConvertFull() throws Exception {
+ toConvert = "fr_FR";
+ excepted = Locale.FRANCE;
+ assertEquals(toConvert, excepted);
+
+ toConvert = "fr_fr";
+ assertEquals(toConvert, excepted);
+
+ toConvert = "FR_fr";
+ assertEquals(toConvert, excepted);
+
+ toConvert = "FR_FR";
+ assertEquals(toConvert, excepted);
+
+ toConvert = "\n\tFr_fR ";
+ assertEquals(toConvert, excepted);
+
+ toConvert = "en_GB";
+ excepted = Locale.UK;
+ assertEquals(toConvert, excepted);
+
+ toConvert = "en_US";
+ excepted = Locale.US;
+ assertEquals(toConvert, excepted);
+
+ //TODO Arch, we must also check coherence !
+ toConvert = "fr_GB";
+ excepted = new Locale("fr", "GB");
+ assertEquals(toConvert, excepted);
+ }
+
+ public void testConvertMedium() throws Exception {
+ toConvert = "fr";
+ excepted = new Locale("fr");
+ assertEquals(toConvert, excepted);
+
+ toConvert = "fR";
+ assertEquals(toConvert, excepted);
+
+ toConvert = "FR";
+ assertEquals(toConvert, excepted);
+
+ toConvert = " fR \t";
+ assertEquals(toConvert, excepted);
+
+ toConvert = "en";
+ excepted = new Locale("en");
+ assertEquals(toConvert, excepted);
+
+ toConvert = "es";
+ excepted = new Locale("es");
+ assertEquals(toConvert, excepted);
+
+ }
+
+ public void testConvertFailed() throws Exception {
+
+ toConvert = null;
+ assertConvertFailed(toConvert);
+
+ toConvert = "";
+ assertConvertFailed(toConvert);
+
+ toConvert = "fr_";
+ assertConvertFailed(toConvert);
+
+ toConvert = "_FR";
+ assertConvertFailed(toConvert);
+
+ }
+
+ protected void assertEquals(String toConvert, Locale expected) {
+ Object result = converter.convert(Locale.class, toConvert);
+ assertEquals(expected, result);
+ }
+
+ protected void assertConvertFailed(String toConvert) {
+ try {
+ converter.convert(Locale.class, toConvert);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ }
+}
Property changes on: trunk/nuiton-i18n/src/test/java/org/nuiton/util/converter/LocaleConverterTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_en_GB.properties
===================================================================
--- trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_en_GB.properties 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_en_GB.properties 2011-01-19 21:38:53 UTC (rev 1844)
@@ -24,3 +24,4 @@
###
key.one=First
key.two=Second
+key.with.param=Key with %s
\ No newline at end of file
Modified: trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_fr_FR.properties
===================================================================
--- trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_fr_FR.properties 2011-01-19 20:29:56 UTC (rev 1843)
+++ trunk/nuiton-i18n/src/test/resources/META-INF/I18nStoreTest_fr_FR.properties 2011-01-19 21:38:53 UTC (rev 1844)
@@ -24,3 +24,4 @@
###
key.one=Premier
key.two=Seconde
+key.with.param=Clef avec %s
1
0
r1843 - in trunk/maven-i18n-plugin/src: it/parsers/newProject it/parsers/newProject/src/main/java/org/nuiton/i18n/test it/parsers/withNewKeys it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test main/java/org/nuiton/i18n/plugin main/java/org/nuiton/i18n/plugin/parser/impl
by tchemit@users.nuiton.org 19 Jan '11
by tchemit@users.nuiton.org 19 Jan '11
19 Jan '11
Author: tchemit
Date: 2011-01-19 21:29:56 +0100 (Wed, 19 Jan 2011)
New Revision: 1843
Url: http://nuiton.org/repositories/revision/i18n/1843
Log:
Evolution #1208: Be able to force locale for translation
- change parser to detect the new keys from the l_(Locale,String,...) method
- improve its
- use now I18nFilter inside the ParserJavaMojo and no more the one from processor project
Modified:
trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java
trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2011-01-19 20:29:56 UTC (rev 1843)
@@ -55,6 +55,11 @@
</dependencies>
+ <properties>
+ <i18n.bundles>fr_FR,en_GB</i18n.bundles>
+ <i18n.verbose>true</i18n.verbose>
+ <i18n.keepGetters>true</i18n.keepGetters>
+ </properties>
<build>
<plugins>
@@ -92,7 +97,16 @@
</configuration>
</execution>
<execution>
- <!-- this execution is to test thread with no files -->
+ <id>gen</id>
+ <goals>
+ <goal>gen</goal>
+ </goals>
+ <!--<configuration>-->
+ <!--<keepGetters>true</keepGetters>-->
+ <!--</configuration>-->
+ </execution>
+ <!-- this execution is to test thread with no files -->
+ <!--execution>
<id>second</id>
<goals>
<goal>parserJava</goal>
@@ -101,7 +115,7 @@
<goal>parserGWTJava</goal>
</goals>
<phase>compile</phase>
- </execution>
+ </execution-->
</executions>
</plugin>
</plugins>
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java 2011-01-19 20:29:56 UTC (rev 1843)
@@ -24,12 +24,19 @@
*/
package org.nuiton.i18n.test;
+import java.util.Locale;
+
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l_;
public class MyBean {
protected String field1 = n_("javaGetter.key1");
protected String field2 = _("javaGetter.key2");
+
+ public void method() {
+ l_(Locale.FRENCH,"javaGetter.key3");
+ }
}
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2011-01-19 20:29:56 UTC (rev 1843)
@@ -23,40 +23,57 @@
* #L%
*/
-file = new File(basedir, 'target/generated-sources/i18n/java.getter');
-assert file.exists();
+def checkKeysInFile(path, keys) {
-content = file.text;
-assert content.contains( 'javaGetter.key1=' );
-assert content.contains( 'javaGetter.key2=' );
+ file = new File(basedir, path);
+ if (!file.exists()) {
+ println("Could not find file [" + file + "]");
+ return false;
+ }
-file = new File(basedir, 'target/generated-sources/i18n/validation.getter');
-assert file.exists();
+ content = file.text;
-content = file.text;
-assert content.contains( 'validationGetter.key1=' );
-assert content.contains( 'validationGetter.key2=' );
+ for (key in keys) {
+ if (!content.contains(key)) {
+ println("Could not find " + key + " in file " + file);
+ return false;
+ }
+ }
+ return true;
+}
-file = new File(basedir, 'target/generated-sources/i18n/jsp.getter');
-assert file.exists();
+assert checkKeysInFile('target/generated-sources/i18n/java.getter',
+ ['javaGetter.key1=', 'javaGetter.key2=', 'javaGetter.key3='])
-content = file.text;
-assert content.contains( 'jspGetter.key1=' );
-assert content.contains( 'jspGetter.key2=' );
+assert checkKeysInFile('target/generated-sources/i18n/validation.getter',
+ ['validationGetter.key1=', 'validationGetter.key2='])
-file = new File(basedir, 'target/generated-sources/i18n/tapestry.getter');
-assert file.exists();
+assert checkKeysInFile('target/generated-sources/i18n/jsp.getter',
+ ['jspGetter.key1=', 'jspGetter.key2='])
-content = file.text;
-assert content.contains( 'tmlGetter.key1=' );
-assert content.contains( 'tmlGetter.key2=' );
+assert checkKeysInFile('target/generated-sources/i18n/tapestry.getter',
+ ['tmlGetter.key1=', 'tmlGetter.key2='])
-file = new File(basedir, 'target/generated-sources/i18n/gwt-java.getter');
-assert file.exists();
+assert checkKeysInFile('target/generated-sources/i18n/gwt-java.getter',
+ ['gwtJavaGetter.key1=', 'gwtJavaGetter.key2=', 'gwtJavaGetter.key3='])
-content = file.text;
-assert content.contains( 'gwtJavaGetter.key1=' );
-assert content.contains( 'gwtJavaGetter.key2=' );
-assert content.contains( 'gwtJavaGetter.key3=' );
+assert checkKeysInFile('target/generated-sources/i18n/parsers-newProject_fr_FR.properties',
+ [
+ 'javaGetter.key1=', 'javaGetter.key2=', 'javaGetter.key3=',
+ 'validationGetter.key1=', 'validationGetter.key2=',
+ 'jspGetter.key1=', 'jspGetter.key2=',
+ 'tmlGetter.key1=', 'tmlGetter.key2=',
+ 'gwtJavaGetter.key1=', 'gwtJavaGetter.key2=', 'gwtJavaGetter.key3='
+ ])
+assert checkKeysInFile('target/generated-sources/i18n/parsers-newProject_en_GB.properties',
+ [
+ 'javaGetter.key1=', 'javaGetter.key2=', 'javaGetter.key3=',
+ 'validationGetter.key1=', 'validationGetter.key2=',
+ 'jspGetter.key1=', 'jspGetter.key2=',
+ 'tmlGetter.key1=', 'tmlGetter.key2=',
+ 'gwtJavaGetter.key1=', 'gwtJavaGetter.key2=', 'gwtJavaGetter.key3='
+ ])
+
+
return true;
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2011-01-19 20:29:56 UTC (rev 1843)
@@ -65,6 +65,11 @@
</dependencies>
+ <properties>
+ <i18n.bundles>fr_FR,en_GB</i18n.bundles>
+ <i18n.verbose>true</i18n.verbose>
+ <i18n.keepGetters>true</i18n.keepGetters>
+ </properties>
<build>
<plugins>
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java 2011-01-19 20:29:56 UTC (rev 1843)
@@ -24,12 +24,20 @@
*/
package org.nuiton.i18n.test;
+import java.util.Locale;
+
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.I18n.l_;
public class MyBean {
protected String field1 = n_("javaGetter.key1");
protected String field2 = _("javaGetter.key2");
+
+
+ public void method() {
+ l_(Locale.FRENCH,"javaGetter.key3");
+ }
}
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2011-01-19 20:29:56 UTC (rev 1843)
@@ -23,66 +23,122 @@
* #L%
*/
-file = new File(basedir, 'target/generated-sources/i18n/java.getter');
-assert file.exists();
-content = file.text;
-//assert content.contains( 'javaGetter.old.key1=' );
-//assert content.contains( 'javaGetter.old.key2=' );
-assert content.contains( 'javaGetter.key1=' );
-assert content.contains( 'javaGetter.key2=' );
+def checkKeysInFile(path, keys) {
-file = new File(basedir, 'target/generated-sources/i18n/validation.getter');
-assert file.exists();
+ file = new File(basedir, path);
+ if (!file.exists()) {
+ println("Could not find file [" + file + "]");
+ return false;
+ }
-content = file.text;
-assert content.contains( 'validationGetter.key1=' );
-assert content.contains( 'validationGetter.key2=' );
-assert content.contains( 'validationGetter.key3=' );
+ content = file.text;
-file = new File(basedir, 'target/generated-sources/i18n/jsp.getter');
-assert file.exists();
+ for (key in keys) {
+ if (!content.contains(key)) {
+ println("Could not find " + key + " in file " + file);
+ return false;
+ }
+ }
+ return true;
+}
-content = file.text;
-assert content.contains( 'jspGetter.key1=' );
-assert content.contains( 'jspGetter.key2=' );
+assert checkKeysInFile('target/generated-sources/i18n/java.getter',
+ ['javaGetter.key1=', 'javaGetter.key2=', 'javaGetter.key3='])
-file = new File(basedir, 'target/generated-sources/i18n/tapestry.getter');
-assert file.exists();
+assert checkKeysInFile('target/generated-sources/i18n/validation.getter',
+ ['validationGetter.key1=', 'validationGetter.key2=', 'validationGetter.key3='])
-content = file.text;
-assert content.contains( 'tmlGetter.key1=' );
-assert content.contains( 'tmlGetter.key2=' );
+assert checkKeysInFile('target/generated-sources/i18n/jsp.getter',
+ ['jspGetter.key1=', 'jspGetter.key2='])
+assert checkKeysInFile('target/generated-sources/i18n/tapestry.getter',
+ ['tmlGetter.key1=', 'tmlGetter.key2='])
-file = new File(basedir, 'target/generated-sources/i18n/gwt-java.getter');
-assert file.exists();
+assert checkKeysInFile('target/generated-sources/i18n/gwt-java.getter',
+ ['gwtJavaGetter.key1=', 'gwtJavaGetter.key2=', 'gwtJavaGetter.key3='])
-content = file.text;
-assert content.contains( 'gwtJavaGetter.key1=' );
-assert content.contains( 'gwtJavaGetter.key2=' );
-assert content.contains( 'gwtJavaGetter.key3=' );
+assert checkKeysInFile('target/generated-sources/i18n/parsers-withNewKeys_fr_FR.properties',
+ [
+ 'javaGetter.key1=', 'javaGetter.key2=', 'javaGetter.key3=',
+ 'javaGetter.old.key1=', 'javaGetter.old.key2=',
+ 'validationGetter.key1=', 'validationGetter.key2=', 'validationGetter.key3=',
+ 'jspGetter.key1=', 'jspGetter.key2=',
+ 'tmlGetter.key1=', 'tmlGetter.key2=',
+ 'gwtJavaGetter.key1=', 'gwtJavaGetter.key2=', 'gwtJavaGetter.key3='
+ ])
-file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties');
-assert file.exists();
+assert checkKeysInFile('target/generated-sources/i18n/parsers-withNewKeys_en_GB.properties',
+ [
+ 'javaGetter.key1=', 'javaGetter.key2=', 'javaGetter.key3=',
+ 'validationGetter.key1=', 'validationGetter.key2=',
+ 'jspGetter.key1=', 'jspGetter.key2=',
+ 'tmlGetter.key1=', 'tmlGetter.key2=',
+ 'gwtJavaGetter.key1=', 'gwtJavaGetter.key2=', 'gwtJavaGetter.key3='
+ ])
+//
+//file = new File(basedir, 'target/generated-sources/i18n/java.getter');
+//assert file.exists();
+//
+//content = file.text;
+////assert content.contains( 'javaGetter.old.key1=' );
+////assert content.contains( 'javaGetter.old.key2=' );
+//assert content.contains( 'javaGetter.key1=' );
+//assert content.contains( 'javaGetter.key2=' );
+//assert content.contains( 'javaGetter.key3=' );
-content = file.text;
-assert content.contains( 'javaGetter.old.key1=' );
-assert content.contains( 'javaGetter.old.key2=' );
-assert content.contains( 'javaGetter.key1=' );
-assert content.contains( 'javaGetter.key2=' );
-assert content.contains( 'validationGetter.key1=' );
-assert content.contains( 'validationGetter.key2=' );
-assert content.contains( 'validationGetter.key3=' );
-assert content.contains( 'jspGetter.key1=' );
-assert content.contains( 'jspGetter.key2=' );
+//file = new File(basedir, 'target/generated-sources/i18n/validation.getter');
+//assert file.exists();
+//
+//content = file.text;
+//assert content.contains( 'validationGetter.key1=' );
+//assert content.contains( 'validationGetter.key2=' );
+//assert content.contains( 'validationGetter.key3=' );
-assert content.contains( 'tmlGetter.key1=' );
-assert content.contains( 'tmlGetter.key2=' );
+//file = new File(basedir, 'target/generated-sources/i18n/jsp.getter');
+//assert file.exists();
+//
+//content = file.text;
+//assert content.contains( 'jspGetter.key1=' );
+//assert content.contains( 'jspGetter.key2=' );
+//
+//
+//file = new File(basedir, 'target/generated-sources/i18n/tapestry.getter');
+//assert file.exists();
+//
+//content = file.text;
+//assert content.contains( 'tmlGetter.key1=' );
+//assert content.contains( 'tmlGetter.key2=' );
-assert content.contains( 'gwtJavaGetter.key1=' );
-assert content.contains( 'gwtJavaGetter.key2=' );
-assert content.contains( 'gwtJavaGetter.key3=' );
+//file = new File(basedir, 'target/generated-sources/i18n/gwt-java.getter');
+//assert file.exists();
+//
+//content = file.text;
+//assert content.contains( 'gwtJavaGetter.key1=' );
+//assert content.contains( 'gwtJavaGetter.key2=' );
+//assert content.contains( 'gwtJavaGetter.key3=' );
+//file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties');
+//assert file.exists();
+//
+//content = file.text;
+//assert content.contains('javaGetter.old.key1=');
+//assert content.contains('javaGetter.old.key2=');
+//assert content.contains('javaGetter.key1=');
+//assert content.contains('javaGetter.key2=');
+//assert content.contains('javaGetter.key3=');
+//assert content.contains('validationGetter.key1=');
+//assert content.contains('validationGetter.key2=');
+//assert content.contains('validationGetter.key3=');
+//assert content.contains('jspGetter.key1=');
+//assert content.contains('jspGetter.key2=');
+//
+//assert content.contains('tmlGetter.key1=');
+//assert content.contains('tmlGetter.key2=');
+//
+//assert content.contains('gwtJavaGetter.key1=');
+//assert content.contains('gwtJavaGetter.key2=');
+//assert content.contains('gwtJavaGetter.key3=');
+
return true;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2011-01-19 20:29:56 UTC (rev 1843)
@@ -168,6 +168,9 @@
}
if (!keepGetters) {
+ if (isVerbose()) {
+ getLog().info("Will delete getter " + bundleGetterOut);
+ }
deleteFile(bundleGetterOut);
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2011-01-19 20:29:56 UTC (rev 1843)
@@ -97,6 +97,9 @@
propertiesOut.putAll(propertiesIn);
if (!keepGetters) {
+ if (isVerbose()) {
+ getLog().info("Will delete getter " + bundleGetter);
+ }
deleteFile(bundleGetter);
}
if (!silent) {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2011-01-19 16:24:40 UTC (rev 1842)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2011-01-19 20:29:56 UTC (rev 1843)
@@ -35,20 +35,22 @@
import org.nuiton.io.FileUpdater;
import org.nuiton.io.FileUpdaterHelper;
import org.nuiton.io.SortedProperties;
-import org.nuiton.processor.filters.I18nFilter;
+import org.nuiton.processor.filters.DefaultFilter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* To parse java files to detect new i18n keys.
- *
+ * <p/>
* <b>Note: </b> this goal must always be invoked before the {@code process-resources}
* phase, otherwise all files will be considered as uptodate.
- *
+ *
* @author jruchaud <ruchaud(a)codelutin.com>
* @author tchemit <tchemit(a)codelutin.com>
* @goal parserJava
@@ -128,13 +130,14 @@
protected static class JavaFileParser extends AbstractFileParser {
- protected final I18nFilter filter = new I18nFilter();
+ protected final I18nFilter filter;
public JavaFileParser(Log log,
String encoding,
SortedProperties oldParser,
boolean showTouchedFiles) {
super(log, encoding, oldParser, showTouchedFiles);
+ filter = new I18nFilter(log);
}
@Override
@@ -180,4 +183,131 @@
}
}
}
+
+ public static class I18nFilter extends DefaultFilter {
+
+ /** Instance logger */
+ private final Log log;
+
+// private String header = "_\\(\\s*\"";
+ private String header = "^_\\(\\s*\\\"|[^l]_\\(\\s*\\\"|l_\\([^,]+\\s*,\\s*\\\"";
+
+ private String footer = "\"\\s*(\\)|,|\\+|$)";
+
+ private Pattern headerPattern = Pattern.compile(getHeader());
+
+ private Pattern footerPattern = Pattern.compile(getFooter());
+
+ private Matcher matcher;
+
+ public I18nFilter(Log log) {
+ this.log = log;
+ }
+
+ protected void setFooter(String footer) {
+ this.footer = footer;
+ }
+
+ protected void setHeader(String header) {
+ this.header = header;
+ }
+
+ @Override
+ protected String getHeader() {
+ return header;
+ }
+
+ @Override
+ protected String getFooter() {
+ return footer;
+ }
+
+ @Override
+ public int getMatchIndexFor(String input, String sequence) {
+ int index = NOT_FOUND;
+
+ setMatcher(null);
+ if (sequence.equals(getHeader())) {
+ setMatcher(getHeaderPattern().matcher(input));
+ } else if (sequence.equals(getFooter())) {
+ setMatcher(getFooterPattern().matcher(input));
+ }
+ if (getMatcher() != null) {
+ try {
+ getMatcher().find();
+ index = getMatcher().start();
+ } catch (RuntimeException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Could not match with " + getMatcher() + " input " + input);
+ }
+ }
+ }
+
+ return index;
+ }
+
+ @Override
+ public int getMatchLengthFor(String sequence) {
+ int length = NOT_FOUND;
+
+ try {
+ length = getMatcher().end() - getMatcher().start();
+ } catch (RuntimeException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Could not match with " + getMatcher() + " input " + sequence);
+ }
+ }
+
+ return length;
+ }
+
+ /**
+ * methode appele lorsqu'on a la chaine entiere entre le header et le
+ * footer.
+ *
+ * @param ch la chaine trouve
+ * @return ce qu'il faut ecrire dans le fichier de sortie
+ */
+ @Override
+ protected String performInFilter(String ch) {
+ return ch.replaceAll("\"\\s*\\+\\s*\"", "") + "=";
+ }
+
+ @Override
+ public String performHeaderFooterFilter(String ch) {
+ return ch.substring(ch.indexOf('"') + 1, ch.lastIndexOf('"'));
+ }
+
+ /**
+ * methode appele lorsqu'on a la chaine entiere a l'exterieur du
+ * header/footer
+ *
+ * @param ch la chaine trouve
+ * @return ce qu'il faut ecrire dans le fichier de sortie
+ */
+ @Override
+ protected String performOutFilter(String ch) {
+ return EMPTY_STRING;
+ }
+
+ /** @return Returns the footerPattern. */
+ protected Pattern getFooterPattern() {
+ return footerPattern;
+ }
+
+ /** @return Returns the headerPattern. */
+ protected Pattern getHeaderPattern() {
+ return headerPattern;
+ }
+
+ /** @return Returns the matcher. */
+ protected Matcher getMatcher() {
+ return matcher;
+ }
+
+ /** @param matcher The matcher to set. */
+ protected void setMatcher(Matcher matcher) {
+ this.matcher = matcher;
+ }
+ }
}
1
0
19 Jan '11
Author: bpoussin
Date: 2011-01-19 17:24:40 +0100 (Wed, 19 Jan 2011)
New Revision: 1842
Url: http://nuiton.org/repositories/revision/i18n/1842
Log:
Anomalie #1208: Be able to force locale for translation
- rename method _(Locale locale, ...) to l_(Locale locale, ...)
Modified:
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-19 15:18:57 UTC (rev 1841)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-19 16:24:40 UTC (rev 1842)
@@ -45,7 +45,7 @@
* the translation support with the init(String language) or init(String
* language, String country), init(Localelocale) static methods in your main, (
* eg: I18n.init("fr","FR") ) <li> call the translate static method for each
- * sentence, ( eg: I18n._("hello you !") ) <li> create a resource file for each
+ * sentence, ( eg: I18n.l_("hello you !") ) <li> create a resource file for each
* language following the naming convention given in the
* java.util.ResourceBundle javadoc and translate all the sentence. </ul>
*
@@ -135,7 +135,7 @@
* @return la traduction si possible ou la chaine passee en parametre
* sinon.
*/
- public static String _(Locale locale, String message) {
+ public static String l_(Locale locale, String message) {
// if the key to translate is null, just return null
if (message == null) {
@@ -159,7 +159,7 @@
* @return la traduction si possible ou la chaine passee en parametre
* sinon.
*/
- public static String _(Locale locale, String message, Object... args) {
+ public static String l_(Locale locale, String message, Object... args) {
// if the key to translate is null, just return null
if (message == null) {
@@ -196,7 +196,7 @@
*/
public static String _(String message) {
Locale locale = getCurrentLanguage().getLocale();
- String result = _(locale, message);
+ String result = l_(locale, message);
return result;
}
@@ -211,7 +211,7 @@
*/
public static String _(String message, Object... args) {
Locale locale = getCurrentLanguage().getLocale();
- String result = _(locale, message, args);
+ String result = l_(locale, message, args);
return result;
}
@@ -223,7 +223,7 @@
* <p/>
* Par exemple :
* <pre>String key = "nuitonutils.key";
- * String result = _(key)</pre>
+ * String result = l_(key)</pre>
* fonctionnera, mais la chaine n'aura pas été marquée comme devant être
* internationalisé.
* <p/>
@@ -257,7 +257,7 @@
* <p/>
* Par exemple :
* <pre>String key = "nuitonutils.key";
- * String result = _(key)</pre>
+ * String result = l_(key)</pre>
* fonctionnera, mais la chaine n'aura pas été marquée comme devant être
* internationalisé.
* <p/>
1
0
19 Jan '11
Author: bpoussin
Date: 2011-01-19 16:18:57 +0100 (Wed, 19 Jan 2011)
New Revision: 1841
Url: http://nuiton.org/repositories/revision/i18n/1841
Log:
Anomalie #1208: Be able to force locale for translation
- _(Locale locale, ...) method added
- old _(String message, ...) method call new _(Locale locale, ...) method
- I18nStore add translation in cache when get is call (before this is done when set is done)
- lazy loading of initializer in get method
Modified:
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-12 17:17:54 UTC (rev 1840)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2011-01-19 15:18:57 UTC (rev 1841)
@@ -118,10 +118,6 @@
* @param locale language to use
*/
public static void init(Locale locale) {
- if (initializer == null) {
- initializer = new ClassPathI18nInitializer();
- }
-
if (locale == null) {
// use default locale
locale = I18nUtil.newLocale(null, null);
@@ -134,18 +130,19 @@
/**
* Retourne la chaine traduite si possible.
*
+ * @param locale la locale dans lequel on souhaite la traduction
* @param message la chaine a traduire
* @return la traduction si possible ou la chaine passee en parametre
* sinon.
*/
- public static String _(String message) {
+ public static String _(Locale locale, String message) {
// if the key to translate is null, just return null
if (message == null) {
return null;
}
- I18nLanguage language = getCurrentLanguage();
+ I18nLanguage language = getStore().getLanguage(locale);
String result = message;
if (language != null) {
result = language.translate(message);
@@ -153,7 +150,7 @@
return applyFilter(result);
}
- /**
+ /**
* Retourne la chaine traduite si possible.
*
* @param message message formate avec la meme syntaxe que {@link
@@ -162,14 +159,14 @@
* @return la traduction si possible ou la chaine passee en parametre
* sinon.
*/
- public static String _(String message, Object... args) {
+ public static String _(Locale locale, String message, Object... args) {
// if the key to translate is null, just return null
if (message == null) {
return null;
}
- I18nLanguage language = getCurrentLanguage();
+ I18nLanguage language = getStore().getLanguage(locale);
String result = message;
if (language != null) {
result = language.translate(message);
@@ -191,6 +188,34 @@
}
/**
+ * Retourne la chaine traduite si possible.
+ *
+ * @param message la chaine a traduire
+ * @return la traduction si possible ou la chaine passee en parametre
+ * sinon.
+ */
+ public static String _(String message) {
+ Locale locale = getCurrentLanguage().getLocale();
+ String result = _(locale, message);
+ return result;
+ }
+
+ /**
+ * Retourne la chaine traduite si possible.
+ *
+ * @param message message formate avec la meme syntaxe que {@link
+ * String#format}
+ * @param args les parametres pour le message.
+ * @return la traduction si possible ou la chaine passee en parametre
+ * sinon.
+ */
+ public static String _(String message, Object... args) {
+ Locale locale = getCurrentLanguage().getLocale();
+ String result = _(locale, message, args);
+ return result;
+ }
+
+ /**
* Retourne la chaine passée en argument.
* <p/>
* Utile surtout pour collecter les chaines et ne pas les traduires à leur
@@ -261,6 +286,10 @@
}
public static I18nInitializer getInitializer() {
+ if (initializer == null) {
+ initializer = new ClassPathI18nInitializer();
+ }
+
return initializer;
}
@@ -274,7 +303,7 @@
public static I18nStore getStore() {
if (store == null) {
- store = new I18nStore(DEFAULT_LOCALE, initializer);
+ store = new I18nStore(DEFAULT_LOCALE, getInitializer());
}
return store;
}
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java 2011-01-12 17:17:54 UTC (rev 1840)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java 2011-01-19 15:18:57 UTC (rev 1841)
@@ -157,13 +157,6 @@
log.debug("locale: " + locale);
}
I18nLanguage result = getLanguage(locale);
- if (result == null) {
- result = addLanguage(locale);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("using cached language : " + result);
- }
- }
language = result;
//TC-20090702 the selected langue is the default locale, usefull for
// objects dealing with the default locale (swing widgets,...)
@@ -197,15 +190,26 @@
* @return le language trouve dans le cache, ou null.
*/
protected I18nLanguage getLanguage(Locale locale) {
-
+ I18nLanguage result = null;
if (!(languages == null || languages.isEmpty())) {
for (I18nLanguage l : languages) {
if (locale.equals(l.getLocale())) {
- return l;
+ result = l;
+ break;
}
}
}
- return null;
+
+ if (result == null) {
+ result = addLanguage(locale);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("using cached language : " + result);
+ }
+ }
+
+
+ return result;
}
protected I18nLanguage addLanguage(Locale locale) {
1
0
Author: jcouteau
Date: 2011-01-12 18:17:54 +0100 (Wed, 12 Jan 2011)
New Revision: 1840
Url: http://nuiton.org/repositories/revision/i18n/1840
Log:
Quickly add some doc about generateDefaultLocale option, parserTapestry and parserGWTJava
Modified:
trunk/src/site/apt/index.apt
trunk/src/site/en/apt/index.apt
Modified: trunk/src/site/apt/index.apt
===================================================================
--- trunk/src/site/apt/index.apt 2011-01-12 16:41:52 UTC (rev 1839)
+++ trunk/src/site/apt/index.apt 2011-01-12 17:17:54 UTC (rev 1840)
@@ -50,6 +50,16 @@
- {{{./ant-i18n-task/index.html}I18n Ant task}} (ce module a été désactivé depuis la version 2.0)
+Quoi de neuf dans la version 2.1
+
+ Il est maintenant possible de générer une locale par défaut (par exemple
+ mesTraductions.properties) en utilisant l'option generateDefaultLocale dans
+ votre pom.
+
+ Un <<parserTapestry>> et un <<parserGWTJava>> ont été ajoutés. Le parseur GWT
+ récupère toutes les clés identifiées par l'annotation @Key. En le couplant
+ avec le parseurXML, vous pouvez gérer complètement vos traductions avec nuiton-i18n.
+
Quoi de nouveau dans la version 2.0
Depuis la version 2.0, les bundles i18n générés (dans <src/main/resources/i18n>)
Modified: trunk/src/site/en/apt/index.apt
===================================================================
--- trunk/src/site/en/apt/index.apt 2011-01-12 16:41:52 UTC (rev 1839)
+++ trunk/src/site/en/apt/index.apt 2011-01-12 17:17:54 UTC (rev 1840)
@@ -51,6 +51,15 @@
- {{{./maven-i18n-plugin/index.html}I18n Maven Plugin}}
+What's new in 2.1 version
+ It is now possible to generate a default locale (for example
+ myTranslations.properties) using the generateDefaultLocale option in your pom.
+
+ A <<parserTapestry>> and <<parserGWTJava>> have been introduced. The GWT parser gathers
+ all the keys identified by the annotation @Key. Coupling it with the XML Parser
+ for UIBinder screens, you can manage all the translations of your application
+ using nuiton-i18n.
+
What is new in the 2.0 version
Since 2.0 version, the generated i18n bundles (in <src/main/resources/i18n>)
1
0
r1839 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . bundle parser/impl
by tchemit@users.nuiton.org 12 Jan '11
by tchemit@users.nuiton.org 12 Jan '11
12 Jan '11
Author: tchemit
Date: 2011-01-12 17:41:52 +0100 (Wed, 12 Jan 2011)
New Revision: 1839
Url: http://nuiton.org/repositories/revision/i18n/1839
Log:
Evolution #1203: Add generateDefaultLocale parameter in Bundle like mojos
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/TapestryBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2011-01-12 16:41:52 UTC (rev 1839)
@@ -199,16 +199,21 @@
/**
* @param root le repertoire ou sont stockes les fichiers i18n
* @param artifactId le nom de l'artifact
- * @param locale le nom du bundle
+ * @param locale le nom de la locale (peut-être nulle)
* @param create {@code true} pour creer le fichier si non present
* @return le fichier i18n
* @throws IOException si probleme lors de la creation du fichier
*/
- public File getI18nFile(File root, String artifactId,
- Locale locale, boolean create) throws IOException {
- File file = new File(
- root.getAbsolutePath() + File.separatorChar + artifactId +
- "_" + locale.toString() + ".properties");
+ public File getI18nFile(File root,
+ String artifactId,
+ Locale locale,
+ boolean create) throws IOException {
+ String path = root.getAbsolutePath() + File.separatorChar + artifactId;
+ if (locale != null) {
+ path += "_" + locale.toString();
+ }
+ path += ".properties";
+ File file = new File(path);
if (create && !file.exists()) {
createNewFile(file);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java 2011-01-12 16:41:52 UTC (rev 1839)
@@ -24,9 +24,11 @@
*/
package org.nuiton.i18n.plugin.bundle;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -59,6 +61,15 @@
protected String bundleOutputName;
/**
+ * A flag to generate a bundle with the first locale defined as a default
+ * bundle (with no locale specialization).
+ *
+ * @parameter expression="${i18n.generateDefaultLocale}" default-value="false"
+ * @since 2.1
+ */
+ protected boolean generateDefaultLocale;
+
+ /**
* A flag to check that bundles are complete (no missing i18n translations).
* <p/>
* <b>Note :</b> This behaviour will be activated is {@link #failsIfWarning} is on.
@@ -127,4 +138,50 @@
}
}
+ /**
+ * Gets the bundle file for the given parameters.
+ *
+ * @param root the root directory where bundles are stored
+ * @param artifactId the artifactId (says the prefix of bundle)
+ * @param locale the locale used in bundle ({@code null} means no locale specialized)
+ * @param create a flag to create the file if none existing
+ * @return the bundle file
+ * @throws IOException if any IO problem while creating it (if needed).
+ * @since 2.1
+ */
+ protected abstract File getBundleFile(File root,
+ String artifactId,
+ Locale locale,
+ boolean create) throws IOException;
+
+ /**
+ * Generates the default bundle, says the bundle with no locale specialized.
+ * <p/>
+ * This bundle is a copy of the bundle of the first locale (which in fact
+ * is considered as the main locale).
+ *
+ * @throws IOException if any IO problem while the copy.
+ * @since 2.1
+ */
+ protected void generateDefaultBundle() throws IOException {
+
+ File bundleFirstLocale = getBundleFile(bundleOutputDir,
+ bundleOutputName,
+ locales[0],
+ false
+ );
+
+ File bundleWithoutLocale = getBundleFile(bundleOutputDir,
+ bundleOutputName,
+ null,
+ false
+ );
+
+ if (!isSilent()) {
+ getLog().info("Generate default bundle at " + bundleWithoutLocale);
+ }
+
+ FileUtils.copyFile(bundleFirstLocale, bundleWithoutLocale);
+ }
+
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2011-01-12 16:41:52 UTC (rev 1839)
@@ -25,6 +25,8 @@
package org.nuiton.i18n.plugin.bundle;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.nuiton.i18n.bundle.I18nBundleEntry;
import org.nuiton.i18n.bundle.I18nBundleUtil;
import org.nuiton.i18n.init.DefaultI18nInitializer;
@@ -195,6 +197,10 @@
failsIfWarning();
+ if (generateDefaultLocale) {
+ generateDefaultBundle();
+ }
+
if (generateDefinitionFile) {
generateDefinitionFile(version, bundleDico);
@@ -205,6 +211,14 @@
}
}
+ @Override
+ protected File getBundleFile(File root,
+ String artifactId,
+ Locale locale,
+ boolean create) throws IOException {
+ return getI18nFile(root, artifactId, locale, create);
+ }
+
protected void generateDefinitionFile(String version,
Map<Locale, String> bundleDico) throws IOException {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/TapestryBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/TapestryBundleMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/TapestryBundleMojo.java 2011-01-12 16:41:52 UTC (rev 1839)
@@ -72,7 +72,7 @@
long t0 = System.nanoTime();
- File bundleOut = getTapestryI18nFile(
+ File bundleOut = getBundleFile(
bundleOutputDir,
bundleOutputName,
locale,
@@ -131,13 +131,16 @@
failsIfWarning();
+ if (generateDefaultLocale) {
+ generateDefaultBundle();
+ }
+
if (!silent && verbose) {
getLog().info("done in " +
PluginHelper.convertTime(t00, System.nanoTime()));
}
}
-
/**
* @param root le repertoire ou sont stockes les fichiers i18n
* @param artifactId le nom de l'artifact
@@ -146,13 +149,18 @@
* @return le fichier i18n
* @throws IOException si probleme lors de la creation du fichier
*/
- public File getTapestryI18nFile(File root,
- String artifactId,
- Locale locale,
- boolean create) throws IOException {
+ @Override
+ protected File getBundleFile(File root,
+ String artifactId,
+ Locale locale,
+ boolean create) throws IOException {
+ String path = root.getAbsolutePath() + File.separatorChar + artifactId;
+ if (locale != null) {
+ path += "_" + locale.getLanguage();
+ }
+ path += ".properties";
File file = new File(
- root.getAbsolutePath() + File.separatorChar + artifactId +
- "_" + locale.getLanguage() + ".properties");
+ path);
if (create && !file.exists()) {
createNewFile(file);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-12 16:41:52 UTC (rev 1839)
@@ -282,67 +282,5 @@
return footer;
}
}
-
- // /**
- // * To remove jsp comment from files.
- // *
- // * @author tchemit <chemit(a)codelutin.com>
- // * @since 2.0
- // */
- // public static class JspCommentFilter extends DefaultFilter {
- //
- // private String header = "<" + "%" + "-" + "-";
- //
- // private String footer = "-" + "-" + "%" + ">";
- //
- // @Override
- // protected String performInFilter(String ch) {
- // return EMPTY_STRING;
- // }
- //
- // @Override
- // protected String performOutFilter(String ch) {
- // return ch;
- // }
- //
- // protected String getHeader() {
- // return header;
- // }
- //
- // protected String getFooter() {
- // return footer;
- // }
- // }
- //
- // /**
- // * To remove jsp directive from files.
- // *
- // * @author tchemit <chemit(a)codelutin.com>
- // * @since 2.0
- // */
- // public static class JspDirectiveFilter extends DefaultFilter {
- //
- // private String header = "<" + "%";
- //
- // private String footer = "%" + ">";
- //
- // @Override
- // protected String performInFilter(String ch) {
- // return EMPTY_STRING;
- // }
- //
- // @Override
- // protected String performOutFilter(String ch) {
- // return ch;
- // }
- //
- // protected String getHeader() {
- // return header;
- // }
- //
- // protected String getFooter() {
- // return footer;
- // }
- // }
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-12 16:41:52 UTC (rev 1839)
@@ -294,6 +294,5 @@
extractKeys(extractor2, fileTemp, encoding, verbose, keys);
saveKeysToFile(fileout, keys);
}
-
}
}
1
0
r1838 - in trunk/maven-i18n-plugin/src: it/parsers/newProject/src/main/java/com/google/gwt/i18n/client it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client main/java/org/nuiton/i18n/plugin main/java/org/nuiton/i18n/plugin/parser main/java/org/nuiton/i18n/plugin/parser/impl site site/apt site/en/apt
by tchemit@users.nuiton.org 04 Jan '11
by tchemit@users.nuiton.org 04 Jan '11
04 Jan '11
Author: tchemit
Date: 2011-01-04 14:54:04 +0100 (Tue, 04 Jan 2011)
New Revision: 1838
Url: http://nuiton.org/repositories/revision/i18n/1838
Log:
update licenses svn keywords + doc
Modified:
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserExecutor.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java
trunk/maven-i18n-plugin/src/site/apt/index.apt
trunk/maven-i18n-plugin/src/site/en/apt/index.apt
trunk/maven-i18n-plugin/src/site/site_en.xml
trunk/maven-i18n-plugin/src/site/site_fr.xml
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2007 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package com.google.gwt.i18n.client;
import java.lang.annotation.*;
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2007 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package com.google.gwt.i18n.client;
import java.lang.annotation.*;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserExecutor.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserExecutor.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserExecutor.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 poussin. All rights reserved.
+ * Copyright (C) 2010 poussin, Tony Chemit. All rights reserved.
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package org.nuiton.i18n.plugin.parser.impl;
import org.apache.maven.plugin.logging.Log;
@@ -20,7 +44,7 @@
import java.util.Set;
/**
- * To detect from GWT java files Tapestry templates new I18n keys, says content of patterns :
+ * To detect from GWT java files new I18n keys, says content of patterns :
* <ul>
* <li>{@code @Key("XXX")}</li>
* <li>{@code @LocalizableResource.Key("XXX")}</li>
@@ -130,9 +154,9 @@
public FileParser newFileParser() {
return new GWTJavaFileParser(getLog(),
- getEncoding(),
- oldParser,
- isShowTouchedFiles()
+ getEncoding(),
+ oldParser,
+ isShowTouchedFiles()
);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2007 - 2010 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java 2011-01-04 13:54:04 UTC (rev 1838)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package org.nuiton.i18n.plugin.parser.impl;
import org.apache.commons.io.FileUtils;
Modified: trunk/maven-i18n-plugin/src/site/apt/index.apt
===================================================================
--- trunk/maven-i18n-plugin/src/site/apt/index.apt 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/site/apt/index.apt 2011-01-04 13:54:04 UTC (rev 1838)
@@ -44,6 +44,8 @@
* {{{./parserJsp-mojo.html} i18n:parserJsp}} parse JSP sources.
+ * {{{./parserGWTJava-mojo.html} i18n:parserGWTJava}} parse GWT java sources.
+
* {{{./parserTapestry-mojo.html} i18n:parserTapestry}} parse Tapestry templates sources.
* {{{./get-mojo.html} i18n:get}} assembly getter computed by parser-like goals.
Modified: trunk/maven-i18n-plugin/src/site/en/apt/index.apt
===================================================================
--- trunk/maven-i18n-plugin/src/site/en/apt/index.apt 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/site/en/apt/index.apt 2011-01-04 13:54:04 UTC (rev 1838)
@@ -44,6 +44,8 @@
* {{{./parserJsp-mojo.html} i18n:parserJsp}} parse jsp sources.
+ * {{{./parserGWTJava-mojo.html} i18n:parserGWTJava}} parse GWT java sources.
+
* {{{./parserTapestry-mojo.html} i18n:parserTapestry}} parse Tapestry template sources.
* {{{./get-mojo.html} i18n:get}} assembly getter computed by parser-like goals.
Modified: trunk/maven-i18n-plugin/src/site/site_en.xml
===================================================================
--- trunk/maven-i18n-plugin/src/site/site_en.xml 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/site/site_en.xml 2011-01-04 13:54:04 UTC (rev 1838)
@@ -53,6 +53,7 @@
<item name="parserJava" href="parserJava-mojo.html"/>
<item name="parserXml" href="parserXml-mojo.html"/>
<item name="parserJsp" href="parserJsp-mojo.html"/>
+ <item name="parserGWTJava" href="parserGWTJava-mojo.html"/>
<item name="parserTapestry" href="parserTapestry-mojo.html"/>
<item name="parserValidation" href="parserValidation-mojo.html"/>
<item name="get" href="get-mojo.html"/>
Modified: trunk/maven-i18n-plugin/src/site/site_fr.xml
===================================================================
--- trunk/maven-i18n-plugin/src/site/site_fr.xml 2011-01-04 13:43:41 UTC (rev 1837)
+++ trunk/maven-i18n-plugin/src/site/site_fr.xml 2011-01-04 13:54:04 UTC (rev 1838)
@@ -52,6 +52,7 @@
<item name="parserXml" href="parserXml-mojo.html"/>
<item name="parserJsp" href="parserJsp-mojo.html"/>
<item name="parserTapestry" href="parserTapestry-mojo.html"/>
+ <item name="parserGWTJava" href="parserGWTJava-mojo.html"/>
<item name="parserValidation" href="parserValidation-mojo.html"/>
<item name="get" href="get-mojo.html"/>
<item name="gen" href="gen-mojo.html"/>
1
0
Author: tchemit
Date: 2011-01-04 14:43:41 +0100 (Tue, 04 Jan 2011)
New Revision: 1837
Url: http://nuiton.org/repositories/revision/i18n/1837
Log:
pass to version 2.1-SNAPSHOT
Evolution #1196: Introduce GWT Parser to grab i18n keys from java files
refactor processor code to use for any Parser processor
Added:
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyGWTBean.java
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyGWTBean.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java
Removed:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/JspFileProcessor.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java
Modified:
trunk/ant-i18n-task/pom.xml
trunk/maven-i18n-plugin/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
trunk/nuiton-i18n/pom.xml
trunk/pom.xml
Modified: trunk/ant-i18n-task/pom.xml
===================================================================
--- trunk/ant-i18n-task/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/ant-i18n-task/pom.xml 2011-01-04 13:43:41 UTC (rev 1837)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/pom.xml 2011-01-04 13:43:41 UTC (rev 1837)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>2.0.2-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2011-01-04 13:43:41 UTC (rev 1837)
@@ -73,6 +73,7 @@
<goal>parserJava</goal>
<goal>parserValidation</goal>
<goal>parserTapestry</goal>
+ <goal>parserGWTJava</goal>
</goals>
</execution>
<execution>
@@ -97,6 +98,7 @@
<goal>parserJava</goal>
<goal>parserValidation</goal>
<goal>parserTapestry</goal>
+ <goal>parserGWTJava</goal>
</goals>
<phase>compile</phase>
</execution>
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -0,0 +1,13 @@
+package com.google.gwt.i18n.client;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+
+public class LocalizableResource {
+
+ @Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Key {
+ String[] value();
+ }
+}
\ No newline at end of file
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyGWTBean.java (from rev 1834, trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java)
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyGWTBean.java (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyGWTBean.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2007 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.i18n.test;
+
+import com.google.gwt.i18n.client.LocalizableResource;
+import static com.google.gwt.i18n.client.LocalizableResource.Key;
+
+public class MyGWTBean {
+
+ @Key("gwtJavaGetter.key1")
+ protected String field1;
+
+ @LocalizableResource.Key("gwtJavaGetter.key2")
+ protected String field2;
+
+ @com.google.gwt.i18n.client.LocalizableResource.Key("gwtJavaGetter.key3")
+ protected String field3;
+
+}
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2011-01-04 13:43:41 UTC (rev 1837)
@@ -51,4 +51,12 @@
assert content.contains( 'tmlGetter.key1=' );
assert content.contains( 'tmlGetter.key2=' );
+file = new File(basedir, 'target/generated-sources/i18n/gwt-java.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'gwtJavaGetter.key1=' );
+assert content.contains( 'gwtJavaGetter.key2=' );
+assert content.contains( 'gwtJavaGetter.key3=' );
+
return true;
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2011-01-04 13:43:41 UTC (rev 1837)
@@ -82,6 +82,7 @@
<id>first</id>
<goals>
<goal>parserJava</goal>
+ <goal>parserGWTJava</goal>
<goal>parserValidation</goal>
<goal>parserTapestry</goal>
</goals>
@@ -112,6 +113,7 @@
<id>second</id>
<goals>
<goal>parserJava</goal>
+ <goal>parserGWTJava</goal>
<goal>parserValidation</goal>
<goal>parserTapestry</goal>
<goal>gen</goal>
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -0,0 +1,13 @@
+package com.google.gwt.i18n.client;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+
+public class LocalizableResource {
+
+ @Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Key {
+ String[] value();
+ }
+}
\ No newline at end of file
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/com/google/gwt/i18n/client/LocalizableResource.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyGWTBean.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyGWTBean.java (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyGWTBean.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2007 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.i18n.test;
+
+import com.google.gwt.i18n.client.LocalizableResource;
+import static com.google.gwt.i18n.client.LocalizableResource.Key;
+
+public class MyGWTBean {
+
+ @Key("gwtJavaGetter.key1")
+ protected String field1;
+
+ @LocalizableResource.Key("gwtJavaGetter.key2")
+ protected String field2;
+
+ @com.google.gwt.i18n.client.LocalizableResource.Key("gwtJavaGetter.key3")
+ protected String field3;
+
+}
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyGWTBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2011-01-04 13:43:41 UTC (rev 1837)
@@ -55,6 +55,15 @@
assert content.contains( 'tmlGetter.key1=' );
assert content.contains( 'tmlGetter.key2=' );
+
+file = new File(basedir, 'target/generated-sources/i18n/gwt-java.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'gwtJavaGetter.key1=' );
+assert content.contains( 'gwtJavaGetter.key2=' );
+assert content.contains( 'gwtJavaGetter.key3=' );
+
file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties');
assert file.exists();
@@ -72,4 +81,8 @@
assert content.contains( 'tmlGetter.key1=' );
assert content.contains( 'tmlGetter.key2=' );
+assert content.contains( 'gwtJavaGetter.key1=' );
+assert content.contains( 'gwtJavaGetter.key2=' );
+assert content.contains( 'gwtJavaGetter.key3=' );
+
return true;
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -1,67 +0,0 @@
-/*
- * #%L
- * I18n :: Maven Plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2007 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.i18n.plugin.parser;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Interface type pour la définition d'un nouveau parser.
- * <p/>
- * Une implantation abstraite est proposée : {@link AbstractI18nParserMojo}.
- *
- * @author julien
- * @deprecated since 1.2, use now {@link FileParser} api, which is
- * multi-thread
- */
-@Deprecated
-public interface Parser {
-
- /**
- * Lancement du parser
- *
- * @throws IOException if any io pb
- */
- void parse() throws IOException;
-
- /**
- * Parse sur un fichier
- *
- * @param file le fichier à parser
- * @throws IOException if any pb
- */
- void parseFile(File file) throws IOException;
-
- /**
- * Parse une partie du fichier
- *
- * @param file le fichier à parser
- * @param line la ligne à parser
- * @throws IOException if any pb
- */
- void parseLine(File file, String line) throws IOException;
-
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/JspFileProcessor.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/JspFileProcessor.java 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/JspFileProcessor.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -1,167 +0,0 @@
-/*
- * #%L
- * I18n :: Maven Plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2007 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.nuiton.processor.Processor;
-import org.nuiton.processor.ProcessorUtil;
-import org.nuiton.processor.filters.DefaultFilter;
-import org.nuiton.processor.filters.Filter;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * To transform jsp files to valid xml files.
- * <p/>
- * Says :
- * <ul>
- * <li>Remove jsp directive</li>
- * <li>Remove jsp comment</li>
- * <li>Remove any tags in attributes (used for example in struts)</li>
- * <li>? Other thing</li>
- * </ul>
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class JspFileProcessor extends Processor {
-
- public JspFileProcessor() {
- setInputFilter(
- new Filter[]{
- new JspDirectiveFilter(),
- new JspCommentFilter(),
- new JspAttributeWithTagFilter()
- }
- );
- }
-
- /**
- * @param filein the source file to process
- * @param fileout the output file to generate
- * @param encoding encoding used to read and write files
- * @throws IOException if any io problems while processing
- * @since 1.0.4
- */
- public void process(File filein,
- File fileout,
- String encoding) throws IOException {
- ProcessorUtil.doProcess(this, filein, fileout, encoding);
- }
-
- /**
- * To remove in attributes any sub tags inside it (used for example in
- * struts) from jsp files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
- public static class JspAttributeWithTagFilter extends DefaultFilter {
-
- private String header = "=" + "\"" + "<";
-
- private String footer = "\"" + "/" + ">" + "\"";
-
- @Override
- protected String performInFilter(String ch) {
- return "=\"\"";
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return ch;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-
- /**
- * To remove jsp comment from files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
- public static class JspCommentFilter extends DefaultFilter {
-
- private String header = "<" + "%" + "-" + "-";
-
- private String footer = "-" + "-" + "%" + ">";
-
- @Override
- protected String performInFilter(String ch) {
- return EMPTY_STRING;
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return ch;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-
- /**
- * To remove jsp directive from files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
- public static class JspDirectiveFilter extends DefaultFilter {
-
- private String header = "<" + "%";
-
- private String footer = "%" + ">";
-
- @Override
- protected String performInFilter(String ch) {
- return EMPTY_STRING;
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return ch;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-}
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -0,0 +1,263 @@
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.apache.maven.plugin.logging.Log;
+import org.nuiton.i18n.plugin.parser.AbstractFileParser;
+import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
+import org.nuiton.i18n.plugin.parser.FileParser;
+import org.nuiton.i18n.plugin.parser.I18nSourceEntry;
+import org.nuiton.i18n.plugin.parser.ParserException;
+import org.nuiton.i18n.plugin.parser.SourceEntry;
+import org.nuiton.io.FileUpdater;
+import org.nuiton.io.MirroredFileUpdater;
+import org.nuiton.io.SortedProperties;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * To detect from GWT java files Tapestry templates new I18n keys, says content of patterns :
+ * <ul>
+ * <li>{@code @Key("XXX")}</li>
+ * <li>{@code @LocalizableResource.Key("XXX")}</li>
+ * <li>{@code @com.google.gwt.i18n.client.LocalizableResource.Key("XXX")}</li>
+ * </ul>
+ * <b>Note: </b> this goal must always be invoked before the {@code process-resources}
+ * phase, otherwise all files will be considered as uptodate.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @goal parserGWTJava
+ * @phase generate-resources
+ * @since 2.1
+ */
+public class ParserGWTJavaMojo extends AbstractI18nParserMojo {
+
+ /**
+ * Root directory of the default entry.
+ *
+ * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java"
+ */
+ protected File defaultBasedir;
+
+ /**
+ * Default included files to process (ant-like expression).
+ *
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java"
+ */
+ protected String defaultIncludes;
+
+ /**
+ * Defines the file name of the getter where to put detected i18n keys
+ * while getter phase.
+ *
+ * @parameter expression="${i18n.outputGetter}" default-value="gwt-java.getter"
+ * @since 2.0
+ */
+ protected String outputGetter;
+
+ /**
+ * Where to generated temporary processed files.
+ *
+ * @parameter expression="${i18n.workdir}" default-value="${basedir}/target/i18n-workdir"
+ * @since 2.0
+ */
+ protected File workdir;
+
+ protected MirroredFileUpdater entryUpdater;
+
+ @Override
+ public String[] getDefaultIncludes() {
+ return new String[]{defaultIncludes};
+ }
+
+ @Override
+ public String[] getDefaultExcludes() {
+ return I18nSourceEntry.EMPTY_STRING_ARRAY;
+ }
+
+ @Override
+ public File getDefaultBasedir() {
+ return defaultBasedir;
+ }
+
+ @Override
+ protected boolean onEnterEntry(I18nSourceEntry entry) {
+ boolean b = super.onEnterEntry(entry);
+ if (!b) {
+
+ // no skipped entry
+ // keep the file updater
+ entryUpdater = (MirroredFileUpdater) entry.getUpdater();
+ }
+ return b;
+ }
+
+ @Override
+ public FileUpdater newFileUpdater(SourceEntry entry) {
+ return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) {
+
+ @Override
+ public File getMirrorFile(File f) {
+ String file =
+ f.getAbsolutePath().substring(prefixSourceDirecotory);
+ return new File(destinationDirectory + File.separator + file);
+ }
+ };
+ }
+
+ @Override
+ @Deprecated
+ protected String getKeyModifierStart() {
+ return "_\\(\\s*\"";
+ }
+
+ @Override
+ @Deprecated
+ protected String getKeyModifierEnd() {
+ return "\"\\s*(\\)|,|\\+|$)";
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return outputGetter;
+ }
+
+ @Override
+ public FileParser newFileParser() {
+
+ return new GWTJavaFileParser(getLog(),
+ getEncoding(),
+ oldParser,
+ isShowTouchedFiles()
+ );
+ }
+
+ protected class GWTJavaFileParser extends AbstractFileParser {
+
+
+ public GWTJavaFileParser(Log log,
+ String encoding,
+ SortedProperties oldParser,
+ boolean showTouchedFiles) {
+ super(log, encoding, oldParser, showTouchedFiles);
+ }
+
+
+ protected File prepareFile(File file) throws IOException {
+
+ // clean the jsp to make it xml
+
+ File result = entryUpdater.getMirrorFile(file);
+ if (isVerbose()) {
+ getLog().info("Will process [" + file + "] to " + result);
+ }
+ try {
+ createDirectoryIfNecessary(result.getParentFile());
+ } catch (IOException e) {
+ // don't care about it...
+ }
+ GWTJavaProcessor processor = new GWTJavaProcessor();
+ processor.setVerbose(isVerbose());
+ processor.process(file, result, getEncoding());
+ return result;
+ }
+
+ @Override
+ public void parseFile(File file) throws IOException {
+
+ // clean the jsp to make it xml
+
+ File processedFile = prepareFile(file);
+
+ // process file to obtain
+ String line = null;
+ LineNumberReader lnr = new LineNumberReader(new InputStreamReader(
+ new FileInputStream(processedFile), getEncoding()));
+ try {
+ while ((line = lnr.readLine()) != null) {
+ parseLine(processedFile, line);
+ }
+ } catch (Exception e) {
+ if (line != null) {
+ getLog().error(
+ "could not parse line (" + lnr.getLineNumber() + ") '"
+ + line + "' of file " + file);
+ }
+ throw new ParserException(e);
+ } finally {
+ lnr.close();
+ }
+ }
+
+ @Override
+ public void parseLine(File file, String line) throws IOException {
+
+ String key = line.trim();
+
+ if (key.isEmpty()) {
+ // no key detected on this line
+ return;
+ }
+
+ // one key found in file, so file is marked as touched
+ setTouched(true);
+ // Found a i18n key, register it.
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(file.getName() + " detected key = " + key);
+ }
+ registerKey(key);
+ }
+ }
+
+ /**
+ * To Extract i18n keys from GWT java files.
+ * <p/>
+ * Says keep content only of those patterns :
+ * <ul>
+ * <li>{@code @Key("XXX")}</li>
+ * <li>{@code @LocalizableResource.Key("XXX")}</li>
+ * <li>{@code @com.google.gwt.i18n.client.LocalizableResource.Key("XXX")}</li>
+ * </ul>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public static class GWTJavaProcessor extends ProcessorHelper.AbstractParserProcessor {
+
+ protected ProcessorHelper.KeyExtractor filter1 =
+ new ProcessorHelper.KeyExtractor(
+ "@Key(\"",
+ "\")"
+ );
+
+ protected ProcessorHelper.KeyExtractor filter2 =
+ new ProcessorHelper.KeyExtractor(
+ "@LocalizableResource.Key(\"",
+ "\")"
+ );
+
+ protected ProcessorHelper.KeyExtractor filter3 =
+ new ProcessorHelper.KeyExtractor(
+ "@com.google.gwt.i18n.client.LocalizableResource.Key(\"",
+ "\")"
+ );
+
+
+ @Override
+ public void process(File filein,
+ File fileout,
+ String encoding) throws IOException {
+
+ Set<String> keys = new HashSet<String>();
+ extractKeys(filter1, filein, encoding, verbose, keys);
+ extractKeys(filter2, filein, encoding, verbose, keys);
+ extractKeys(filter3, filein, encoding, verbose, keys);
+ saveKeysToFile(fileout, keys);
+ }
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -29,6 +29,9 @@
import org.nuiton.i18n.plugin.parser.SourceEntry;
import org.nuiton.io.FileUpdater;
import org.nuiton.io.MirroredFileUpdater;
+import org.nuiton.processor.ProcessorUtil;
+import org.nuiton.processor.filters.DefaultFilter;
+import org.nuiton.processor.filters.Filter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
@@ -195,4 +198,151 @@
protected String getKeyModifierEnd() {
return "[\"\']";
}
+
+ /**
+ * To transform jsp files to valid xml files.
+ * <p/>
+ * Says :
+ * <ul>
+ * <li>Remove jsp directive</li>
+ * <li>Remove jsp comment</li>
+ * <li>Remove any tags in attributes (used for example in struts)</li>
+ * <li>? Other thing</li>
+ * </ul>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+ public static class JspFileProcessor extends ProcessorHelper.AbstractParserProcessor {
+
+ protected ProcessorHelper.FragmentRemover remover1 =
+ new ProcessorHelper.FragmentRemover(
+ "<" + "%" + "-" + "-",
+ "-" + "-" + "%" + ">"
+ );
+
+ protected ProcessorHelper.FragmentRemover remover2 =
+ new ProcessorHelper.FragmentRemover(
+ "<" + "%",
+ "%" + ">"
+ );
+
+ public JspFileProcessor() {
+ setInputFilter(
+ new Filter[]{
+ remover1,
+ remover2,
+ new JspAttributeWithTagFilter()
+ }
+ );
+ }
+
+ /**
+ * @param filein the source file to process
+ * @param fileout the output file to generate
+ * @param encoding encoding used to read and write files
+ * @throws IOException if any io problems while processing
+ * @since 1.0.4
+ */
+ @Override
+ public void process(File filein,
+ File fileout,
+ String encoding) throws IOException {
+ ProcessorUtil.doProcess(this, filein, fileout, encoding);
+ }
+
+ /**
+ * To remove in attributes any sub tags inside it (used for example in
+ * struts) from jsp files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+ public static class JspAttributeWithTagFilter extends DefaultFilter {
+
+ private String header = "=" + "\"" + "<";
+
+ private String footer = "\"" + "/" + ">" + "\"";
+
+ @Override
+ protected String performInFilter(String ch) {
+ return "=\"\"";
+ }
+
+ @Override
+ protected String performOutFilter(String ch) {
+ return ch;
+ }
+
+ protected String getHeader() {
+ return header;
+ }
+
+ protected String getFooter() {
+ return footer;
+ }
+ }
+
+ // /**
+ // * To remove jsp comment from files.
+ // *
+ // * @author tchemit <chemit(a)codelutin.com>
+ // * @since 2.0
+ // */
+ // public static class JspCommentFilter extends DefaultFilter {
+ //
+ // private String header = "<" + "%" + "-" + "-";
+ //
+ // private String footer = "-" + "-" + "%" + ">";
+ //
+ // @Override
+ // protected String performInFilter(String ch) {
+ // return EMPTY_STRING;
+ // }
+ //
+ // @Override
+ // protected String performOutFilter(String ch) {
+ // return ch;
+ // }
+ //
+ // protected String getHeader() {
+ // return header;
+ // }
+ //
+ // protected String getFooter() {
+ // return footer;
+ // }
+ // }
+ //
+ // /**
+ // * To remove jsp directive from files.
+ // *
+ // * @author tchemit <chemit(a)codelutin.com>
+ // * @since 2.0
+ // */
+ // public static class JspDirectiveFilter extends DefaultFilter {
+ //
+ // private String header = "<" + "%";
+ //
+ // private String footer = "%" + ">";
+ //
+ // @Override
+ // protected String performInFilter(String ch) {
+ // return EMPTY_STRING;
+ // }
+ //
+ // @Override
+ // protected String performOutFilter(String ch) {
+ // return ch;
+ // }
+ //
+ // protected String getHeader() {
+ // return header;
+ // }
+ //
+ // protected String getFooter() {
+ // return footer;
+ // }
+ // }
+ }
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -40,12 +40,14 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
+import java.util.HashSet;
+import java.util.Set;
/**
* To parse Tapestry templates to detect new I18n keys, says content of patterns :
* {@code ${message:XXX}} and {@code ${format:XXX=...}}.
- *
* <p/>
+ * <p/>
* <b>Note: </b> this goal must always be invoked before the {@code process-resources}
* phase, otherwise all files will be considered as uptodate.
*
@@ -233,4 +235,65 @@
}
}
+ /**
+ * To Extract i18n keys from tapestry template files.
+ * <p/>
+ * Says :
+ * <ul>
+ * <li>Remove all xml comments</li>
+ * <li>Keep content of {@code ${message:XXX}}</li>
+ * <li>Keep content of {@code ${format:XXX}}}</li>
+ * </ul>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public static class TapestryFileProcessor extends ProcessorHelper.AbstractParserProcessor {
+
+ protected ProcessorHelper.FragmentRemover remover1 =
+ new ProcessorHelper.FragmentRemover(
+ "<" + "!" + "-" + "-",
+ "-" + "-" + ">"
+ );
+
+ protected ProcessorHelper.KeyExtractor extractor1 =
+ new ProcessorHelper.KeyExtractor(
+ "$" + "{" + "m" + "e" + "s" + "s" + "a" + "g" + "e" + ":",
+ "}"
+ );
+
+ protected ProcessorHelper.KeyExtractor extractor2 =
+ new ProcessorHelper.KeyExtractor(
+ "$" + "{" + "f" + "o" + "r" + "m" + "a" + "t" + ":",
+ "}") {
+
+ @Override
+ protected String performInFilter(String ch) {
+ int i = ch.indexOf('=');
+ if (verbose) {
+ log.info("Detected key " + ch);
+ }
+ if (i == -1) {
+ return "";
+ }
+ return ch.substring(0, i) + "\n";
+ }
+ };
+
+
+ public void process(File filein,
+ File fileout,
+ String encoding) throws IOException {
+
+ // remove comment fragments
+ File fileTemp = new File(fileout.getAbsolutePath() + "-no-comment");
+ removefragments(remover1, filein, fileTemp, encoding, false);
+
+ Set<String> keys = new HashSet<String>();
+ extractKeys(extractor1, fileTemp, encoding, verbose, keys);
+ extractKeys(extractor2, fileTemp, encoding, verbose, keys);
+ saveKeysToFile(fileout, keys);
+ }
+
+ }
}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -1,263 +0,0 @@
-/*
- * #%L
- * I18n :: Maven Plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2007 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.apache.maven.plugin.logging.Log;
-import org.nuiton.i18n.plugin.parser.AbstractFileParser;
-import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
-import org.nuiton.i18n.plugin.parser.FileParser;
-import org.nuiton.i18n.plugin.parser.ParserException;
-import org.nuiton.io.SortedProperties;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathFactory;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Récupération des chaines à traduire depuis les fichiers xml.
- *
- * @author julien
- * @deprecated since 2.0, prefer use the {@link AbstractParserXmlMojo} instead.
- */
-@Deprecated
-public abstract class ParserXmlMojo extends AbstractI18nParserMojo {
-
- /** Taille du buffer pour les lectures/écritures */
- protected static final int BUFFER_SIZE = 8 * 1024;
-
- protected String rules;
-
- protected XPathFactory factory;
-
- protected DocumentBuilderFactory documentBuilderFactory;
-
- /** @return le fichier des rules */
- protected abstract String getFileRules();
-
- /** @return le fichier des rules de base à toujours charger */
- protected abstract String getCoreFileRules();
-
- protected abstract XmlFileParser newXmlFileParser(XPath xpath,
- DocumentBuilder builder);
-
- @Override
- public void init() throws Exception {
- super.init();
- factory = XPathFactory.newInstance();
- rules = getRules(getFileRules());
-
- documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- }
-
- @Override
- public final FileParser newFileParser() {
-
- DocumentBuilder builder;
- try {
- // never forget this!
- builder = documentBuilderFactory.newDocumentBuilder();
- } catch (ParserConfigurationException ex) {
- throw new IllegalStateException(
- "could not load DocumentBuilder for reason " +
- ex.getMessage(), ex);
- }
-
- XPath xpath = factory.newXPath();
-
- return newXmlFileParser(xpath, builder);
- }
-
- /**
- * Récupère le xpath à partir d'un fichier
- *
- * @param fileRules le nom du fichier contant les règles
- * @return le xpath à partir d'un fichier
- */
- private String getRules(String fileRules) {
- StringBuilder buffer = new StringBuilder();
-
- try {
- String readInputStream;
-
- // load core rules
- readInputStream = loadRulesFile(getCoreFileRules());
- if (!silent && verbose) {
- getLog().info("core rules : " + getCoreFileRules());
- }
- buffer.append(readInputStream);
-
- if (!fileRules.equals(getCoreFileRules())) {
- // add custom rules
- readInputStream = loadRulesFile(fileRules);
- if (!silent && verbose) {
- getLog().info("custom rules : " + fileRules);
- }
- buffer.append(" | ").append(readInputStream);
- }
- } catch (IOException e) {
- throw new ParserException(e);
- }
-
- return buffer.toString();
- }
-
- private String loadRulesFile(String fileRules) throws IOException {
- File f = new File(fileRules);
-
- InputStream inputStream;
- if (f.exists()) {
- // load from a file
- try {
- inputStream = new FileInputStream(f);
- } catch (FileNotFoundException e) {
- throw new ParserException(e);
- }
- } else {
- // load from classpath
- ClassLoader classLoader = getClass().getClassLoader();
- inputStream = classLoader.getResourceAsStream(fileRules);
- }
- if (inputStream == null) {
- throw new ParserException(
- "could not found file of rules : " + fileRules);
- }
-
- inputStream = new BufferedInputStream(inputStream);
-
- try {
- // Lecture
- String readInputStream;
- readInputStream = readInputStream(inputStream);
- return readInputStream;
- } catch (IOException e) {
- throw new ParserException(e);
- } finally {
- inputStream.close();
- }
- }
-
- /**
- * Permet la lecture d'un InputStream et Suppressions.
- *
- * @param in le flux entrant
- * @return le contenu du flux
- * @throws IOException si problème de lecture dans flux entrant
- */
- private String readInputStream(InputStream in) throws IOException {
- StringBuilder sb = new StringBuilder();
- byte[] buffer = new byte[BUFFER_SIZE];
- while (in.read(buffer, 0, BUFFER_SIZE) != -1) {
- String tmp = new String(buffer);
- sb.append(tmp);
- }
- in.close();
- // Suppression
- String txt = sb.toString().trim();
- // suppression des commentaires
- txt = txt.replaceAll("#.*\n", "");
- // contruction du xpath avec des ou
- txt = txt.replaceAll("\\s+", " | ");
- // suppression des ou de début ee fin
- txt = txt.replaceAll("(^ \\| )|( \\| $)", "");
- return txt;
- }
-
- public static abstract class XmlFileParser extends AbstractFileParser {
-
- private final XPath xpath;
-
- private final String rules;
-
- private final DocumentBuilder builder;
-
- /**
- * Fonction d'extraction de la chaine
- *
- * @param i18nString le clef i18n
- * @return la chaine
- */
- public abstract String extract(String i18nString);
-
- public XmlFileParser(Log log,
- String encoding,
- SortedProperties oldParser,
- boolean showTouchedFiles,
- String rules,
- XPath xpath,
- DocumentBuilder builder) {
- super(log, encoding, oldParser, showTouchedFiles);
- this.xpath = xpath;
- this.rules = rules;
- this.builder = builder;
-
- }
-
- @Override
- public void parseFile(File file) throws IOException {
-
- try {
-
- // Recherche des clés à partir d'un xpath
-
- Document doc = builder.parse(file.getAbsolutePath());
- XPathExpression expression = xpath.compile(rules);
- NodeList list = (NodeList)
- expression.evaluate(doc, XPathConstants.NODESET);
-
- for (int index = 0; index < list.getLength(); index++) {
- Node node = list.item(index);
- parseLine(file, node.getTextContent());
- }
- } catch (Exception e) {
- throw new ParserException(e);
- }
- }
-
- @Override
- public void parseLine(File file, String key) throws IOException {
-
- key = extract(key);
- if (key != null) {
- setTouched(true);
- registerKey(key);
- }
- }
- }
-}
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -0,0 +1,243 @@
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.processor.Processor;
+import org.nuiton.processor.ProcessorUtil;
+import org.nuiton.processor.filters.DefaultFilter;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Helper of processor api.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ProcessorHelper extends ProcessorUtil {
+
+ /** Logger */
+ private static final Log log = LogFactory.getLog(ProcessorHelper.class);
+
+ /**
+ * Abstract processor to be used with some smooth logic...
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public abstract static class AbstractParserProcessor extends Processor {
+
+ protected boolean verbose;
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ public abstract void process(File filein,
+ File fileout,
+ String encoding) throws IOException;
+
+ protected void removefragments(FragmentRemover filter,
+ File filein,
+ File fileout,
+ String encoding,
+ boolean verbose) throws IOException {
+
+ filter.setVerbose(verbose || log.isDebugEnabled());
+ setInputFilter(filter);
+ doProcess(this, filein, fileout, encoding);
+ }
+
+ public void extractKeys(KeyExtractor filter,
+ File filein,
+ String encoding,
+ boolean verbose,
+ Set<String> result) throws IOException {
+
+ filter.setVerbose(verbose);
+ setInputFilter(filter);
+ InputStream in = new FileInputStream(filein);
+
+ try {
+ OutputStream out = new ByteArrayOutputStream();
+ try {
+ doProcess(this, in, out, encoding);
+ String lines = out.toString();
+ for (String line : lines.split("\n")) {
+ String key = line.trim();
+ if (StringUtils.isNotBlank(key)) {
+ result.add(key);
+ }
+ }
+ } finally {
+ out.close();
+ }
+ } finally {
+ in.close();
+ }
+ }
+
+ public void saveKeysToFile(File fileout,
+ Set<String> keys) throws IOException {
+ StringBuilder buffer = new StringBuilder();
+ List<String> sortedKeys = new ArrayList<String>(keys);
+ Collections.sort(sortedKeys);
+
+ for (String key : keys) {
+ buffer.append(key).append("\n");
+ }
+ FileUtils.writeStringToFile(fileout, buffer.toString());
+ }
+ }
+
+ /**
+ * To extract all content inside the header and footer.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public static class KeyExtractor extends DefaultFilter {
+
+ /** Logger. */
+ static protected final Log log =
+ LogFactory.getLog(KeyExtractor.class);
+
+ protected String header;
+
+ protected String footer;
+
+ protected boolean verbose;
+
+ public KeyExtractor(String header, String footer) {
+ this.header = header;
+ this.footer = footer;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ @Override
+ protected String performInFilter(String ch) {
+ if (verbose) {
+ log.info("Detected key " + ch);
+ }
+ return ch + "\n";
+ }
+
+ @Override
+ protected String performOutFilter(String ch) {
+ return EMPTY_STRING;
+ }
+
+ @Override
+ protected String getHeader() {
+ return header;
+ }
+
+ @Override
+ protected String getFooter() {
+ return footer;
+ }
+ }
+
+ /**
+ * To remove all content inside the header and footer.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public static class FragmentRemover extends DefaultFilter {
+
+ /** Logger. */
+ static private final Log log =
+ LogFactory.getLog(FragmentRemover.class);
+
+ protected String header;
+
+ protected String footer;
+
+ protected boolean verbose;
+
+ public FragmentRemover(String header, String footer) {
+ this.header = header;
+ this.footer = footer;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ @Override
+ protected String performInFilter(String ch) {
+ if (verbose) {
+ log.info("Will remove " + ch);
+ }
+ return EMPTY_STRING;
+ }
+
+ @Override
+ protected String performOutFilter(String ch) {
+ return ch;
+ }
+
+ @Override
+ protected String getHeader() {
+ return header;
+ }
+
+ @Override
+ protected String getFooter() {
+ return footer;
+ }
+ }
+
+ /**
+ * Launch the process of the given {@code processor} to the given streams.
+ *
+ * @param processor the processor to launch
+ * @param in the input file
+ * @param out the output file
+ * @param encoding encoding to use to read and write files.
+ * @throws IOException if any problems while processing file
+ * @since 2.1 remove this when will use processor >= 1.1
+ */
+ public static void doProcess(Processor processor,
+ InputStream in,
+ OutputStream out,
+ String encoding) throws IOException {
+ InputStreamReader input = new InputStreamReader(in, encoding);
+ try {
+ OutputStreamWriter output = new OutputStreamWriter(out, encoding);
+ try {
+ processor.process(input, output);
+ } catch (IOException eee) {
+ if (log.isErrorEnabled()) {
+ log.error(
+ "Error while processing file " + in + " to " + out +
+ " with processor " + processor, eee);
+ }
+ throw eee;
+ } finally {
+ output.close();
+ }
+ } finally {
+ input.close();
+ }
+ }
+
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ProcessorHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java 2011-01-04 13:43:41 UTC (rev 1837)
@@ -1,192 +0,0 @@
-/*
- * #%L
- * I18n :: Maven Plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.processor.Processor;
-import org.nuiton.processor.ProcessorUtil;
-import org.nuiton.processor.filters.DefaultFilter;
-import org.nuiton.processor.filters.Filter;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * To Extract i18n keys from tapestry template files.
- * <p/>
- * Says :
- * <ul>
- * <li>Remove all xml comments</li>
- * <li>Keep content of {@code ${message:XXX}}</li>
- * <li>Keep content of {@code ${format:XXX}}}</li>
- * </ul>
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.1
- */
-public class TapestryFileProcessor extends Processor {
-
- /** Logger. */
- static private final Log log =
- LogFactory.getLog(TapestryFileProcessor.class);
-
- protected boolean verbose;
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public void process(File filein,
- File fileout,
- String encoding) throws IOException {
- File fileTemp1 = new File(fileout.getAbsolutePath() + "~-message");
- setInputFilter(new Filter[]{
- new RemoveCommentFilter(),
- new ExtractMessageFilter()
- });
- ProcessorUtil.doProcess(this, filein, fileTemp1, encoding);
-
- File fileTemp2 = new File(fileout.getAbsolutePath() + "~-format");
-
- setInputFilter(new Filter[]{
- new RemoveCommentFilter(),
- new ExtractFormatFilter()
- });
- ProcessorUtil.doProcess(this, filein, fileTemp2, encoding);
-
- String tmp1 = FileUtils.readFileToString(fileTemp1).trim();
- String tmp2 = FileUtils.readFileToString(fileTemp2).trim();
- if (log.isDebugEnabled()) {
- log.debug("Keys from message:\n" + tmp1);
- log.debug("Keys from format:\n" + tmp2);
- }
- FileUtils.writeStringToFile(fileout, tmp1 + "\n" + tmp2);
- }
-
- /**
- * To remove comments from tapestry template files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.1
- */
- public class RemoveCommentFilter extends DefaultFilter {
-
- private String header = "<" + "!" + "-" + "-";
-
- private String footer = "-" + "-" + ">";
-
- @Override
- protected String performInFilter(String ch) {
- return EMPTY_STRING;
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return ch;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-
- /**
- * To obtain inside of {@code ${message:XXX}} from tapestry template files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.1
- */
- public class ExtractMessageFilter extends DefaultFilter {
-
- private String header = "$" + "{" + "m" + "e" + "s" + "s" + "a" + "g" + "e" + ":";
-
- private String footer = "}";
-
- @Override
- protected String performInFilter(String ch) {
- if (verbose) {
- log.info("Detected key " + ch);
- }
- return ch + "\n";
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return EMPTY_STRING;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-
- /**
- * To obtain {@code XXX} data {@code ${format:XXX=YYY}} from tapestry template files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.1
- */
- public class ExtractFormatFilter extends DefaultFilter {
-
- private String header = "$" + "{" + "f" + "o" + "r" + "m" + "a" + "t" + ":";
-
- private String footer = "}";
-
- @Override
- protected String performInFilter(String ch) {
- int i = ch.indexOf('=');
- if (verbose) {
- log.info("Detected key " + ch);
- }
- if (i == -1) {
- return "";
- }
- return ch.substring(0, i) + "\n";
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return EMPTY_STRING;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-}
Modified: trunk/nuiton-i18n/pom.xml
===================================================================
--- trunk/nuiton-i18n/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/nuiton-i18n/pom.xml 2011-01-04 13:43:41 UTC (rev 1837)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>2.0.2-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
+++ trunk/pom.xml 2011-01-04 13:43:41 UTC (rev 1837)
@@ -37,7 +37,7 @@
</parent>
<artifactId>i18n</artifactId>
- <version>2.0.2-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
<modules>
<module>nuiton-i18n</module>
1
0
Author: tchemit
Date: 2011-01-04 09:15:32 +0100 (Tue, 04 Jan 2011)
New Revision: 1836
Url: http://nuiton.org/repositories/revision/i18n/1836
Log:
Evolution #1195: Clean site documentation
Evolution #1193: Introduce Tapestry Parser to grab i18n keys from tml files
Added:
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/webapp/tapestry/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/webapp/tapestry/MyTml.tml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/webapp/tapestry/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/webapp/tapestry/MyTml.tml
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java
Modified:
trunk/maven-i18n-plugin/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
trunk/maven-i18n-plugin/src/site/apt/index.apt
trunk/maven-i18n-plugin/src/site/en/apt/index.apt
trunk/maven-i18n-plugin/src/site/site_en.xml
trunk/maven-i18n-plugin/src/site/site_fr.xml
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -67,12 +67,12 @@
<artifactId>commons-lang</artifactId>
</dependency>
- <!--dependency>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- </dependency-->
-
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
</dependency>
@@ -159,6 +159,10 @@
<version>2.5.1</version>
</plugin>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.5</version>
+ </plugin>
</plugins>
</reporting>
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -72,7 +72,8 @@
<goals>
<goal>parserJava</goal>
<goal>parserValidation</goal>
- </goals>
+ <goal>parserTapestry</goal>
+ </goals>
</execution>
<execution>
<id>jsp</id>
@@ -95,6 +96,7 @@
<goals>
<goal>parserJava</goal>
<goal>parserValidation</goal>
+ <goal>parserTapestry</goal>
</goals>
<phase>compile</phase>
</execution>
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/webapp/tapestry/MyTml.tml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/webapp/tapestry/MyTml.tml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/webapp/tapestry/MyTml.tml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ I18n :: Maven Plugin
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<div>
+ <label>${message:tmlGetter.key1} : </label>
+ <label>${format:tmlGetter.key2=miamiam} : </label>
+</div>
\ No newline at end of file
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/webapp/tapestry/MyTml.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2011-01-04 08:15:32 UTC (rev 1836)
@@ -44,4 +44,11 @@
assert content.contains( 'jspGetter.key1=' );
assert content.contains( 'jspGetter.key2=' );
+file = new File(basedir, 'target/generated-sources/i18n/tapestry.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'tmlGetter.key1=' );
+assert content.contains( 'tmlGetter.key2=' );
+
return true;
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -83,6 +83,7 @@
<goals>
<goal>parserJava</goal>
<goal>parserValidation</goal>
+ <goal>parserTapestry</goal>
</goals>
</execution>
<execution>
@@ -112,6 +113,7 @@
<goals>
<goal>parserJava</goal>
<goal>parserValidation</goal>
+ <goal>parserTapestry</goal>
<goal>gen</goal>
</goals>
<phase>compile</phase>
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties 2011-01-04 08:15:32 UTC (rev 1836)
@@ -1,3 +1,4 @@
javaGetter.old.key1=hum1
javaGetter.old.key2=hum2
jspGetter.key1=humJsp1
+tmlGetter.key1=humTapestry1
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/webapp/tapestry/MyTml.tml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/webapp/tapestry/MyTml.tml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/webapp/tapestry/MyTml.tml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ I18n :: Maven Plugin
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<div>
+ <label>${message:tmlGetter.key1} : </label>
+ <label>${format:tmlGetter.key2=miamiam} : </label>
+</div>
\ No newline at end of file
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/webapp/tapestry/MyTml.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2011-01-04 08:15:32 UTC (rev 1836)
@@ -47,6 +47,14 @@
assert content.contains( 'jspGetter.key1=' );
assert content.contains( 'jspGetter.key2=' );
+
+file = new File(basedir, 'target/generated-sources/i18n/tapestry.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'tmlGetter.key1=' );
+assert content.contains( 'tmlGetter.key2=' );
+
file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties');
assert file.exists();
@@ -61,4 +69,7 @@
assert content.contains( 'jspGetter.key1=' );
assert content.contains( 'jspGetter.key2=' );
+assert content.contains( 'tmlGetter.key1=' );
+assert content.contains( 'tmlGetter.key2=' );
+
return true;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java 2011-01-04 08:15:32 UTC (rev 1836)
@@ -137,7 +137,7 @@
* @param file the incoming file
* @return the real file to process
* @throws IOException if any IO problem while preparing file
- * @since 2.0.2
+ * @since 2.1
*/
protected File prepareFile(File file) throws IOException {
return file;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2011-01-04 08:15:32 UTC (rev 1836)
@@ -1,6 +1,29 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package org.nuiton.i18n.plugin.parser.impl;
-import org.apache.commons.logging.LogFactory;
import org.apache.maven.plugin.logging.Log;
import org.nuiton.i18n.plugin.parser.AbstractFileParser;
import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
@@ -11,10 +34,6 @@
import org.nuiton.io.FileUpdater;
import org.nuiton.io.MirroredFileUpdater;
import org.nuiton.io.SortedProperties;
-import org.nuiton.processor.Processor;
-import org.nuiton.processor.ProcessorUtil;
-import org.nuiton.processor.filters.DefaultFilter;
-import org.nuiton.processor.filters.Filter;
import java.io.File;
import java.io.FileInputStream;
@@ -23,7 +42,9 @@
import java.io.LineNumberReader;
/**
- * To parse Tapestry templates to detect new I18n keys.
+ * To parse Tapestry templates to detect new I18n keys, says content of patterns :
+ * {@code ${message:XXX}} and {@code ${format:XXX=...}}.
+ *
* <p/>
* <b>Note: </b> this goal must always be invoked before the {@code process-resources}
* phase, otherwise all files will be considered as uptodate.
@@ -31,7 +52,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @goal parserTapestry
* @phase generate-resources
- * @since 2.0.2
+ * @since 2.1
*/
public class ParserTapestryMojo extends AbstractI18nParserMojo {
@@ -160,6 +181,7 @@
// don't care about it...
}
TapestryFileProcessor processor = new TapestryFileProcessor();
+ processor.setVerbose(isVerbose());
processor.process(file, result, getEncoding());
return result;
}
@@ -211,133 +233,4 @@
}
}
- /**
- * To Extract from tapestry template files, i18n keys.
- * <p/>
- * Says :
- * <ul>
- * <li>Keep content of {@code ${message:XXX}</li>
- * <li>Keep content of {@code ${format:XXX}</li>
- * </ul>
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.2
- */
- public static class TapestryFileProcessor extends Processor {
-
- public TapestryFileProcessor() {
- setInputFilter(new Filter[]{
- new RemoveCommentFilter(),
- new ExtractMessageFilter()
- });
- }
-
- public void process(File filein,
- File fileout,
- String encoding) throws IOException {
- ProcessorUtil.doProcess(this, filein, fileout, encoding);
- }
-
- /**
- * To remove comments from tapestry template files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.2
- */
- public static class RemoveCommentFilter extends DefaultFilter {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static org.apache.commons.logging.Log log = LogFactory.getLog(ExtractMessageFilter.class);
-
- private String header = "<" + "!" + "-" + "-";
-
- private String footer = "-" + "-" + ">";
-
- @Override
- protected String performInFilter(String ch) {
- return EMPTY_STRING;
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return ch;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-
- /**
- * To obtain inside of {@code ${message:XXX}} from tapestry template files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.2
- */
- public static class ExtractMessageFilter extends DefaultFilter {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static org.apache.commons.logging.Log log = LogFactory.getLog(ExtractMessageFilter.class);
-
- private String header = "$" + "{" + "m" + "e" + "s" + "s" + "a" + "g" + "e" + ":";
-
- private String footer = "}";
-
- @Override
- protected String performInFilter(String ch) {
- if (log.isDebugEnabled()) {
- log.debug("Detected key " + ch);
- }
- return ch + "\n";
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return EMPTY_STRING;
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
-
- /**
- * To obtain inside of {@code ${format:XXX}} from tapestry template files.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.2
- */
- public static class ExtractFormatFilter extends DefaultFilter {
-
- private String header = "$" + "{" + "f" + "o" + "r" + "m" + "a" + "t" + ":";
-
- private String footer = "}";
-
- @Override
- protected String performInFilter(String ch) {
- return ch + "\n";
- }
-
- @Override
- protected String performOutFilter(String ch) {
- return "";
- }
-
- protected String getHeader() {
- return header;
- }
-
- protected String getFooter() {
- return footer;
- }
- }
- }
}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java 2011-01-04 08:15:32 UTC (rev 1836)
@@ -0,0 +1,192 @@
+/*
+ * #%L
+ * I18n :: Maven Plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.processor.Processor;
+import org.nuiton.processor.ProcessorUtil;
+import org.nuiton.processor.filters.DefaultFilter;
+import org.nuiton.processor.filters.Filter;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * To Extract i18n keys from tapestry template files.
+ * <p/>
+ * Says :
+ * <ul>
+ * <li>Remove all xml comments</li>
+ * <li>Keep content of {@code ${message:XXX}}</li>
+ * <li>Keep content of {@code ${format:XXX}}}</li>
+ * </ul>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+public class TapestryFileProcessor extends Processor {
+
+ /** Logger. */
+ static private final Log log =
+ LogFactory.getLog(TapestryFileProcessor.class);
+
+ protected boolean verbose;
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ public void process(File filein,
+ File fileout,
+ String encoding) throws IOException {
+ File fileTemp1 = new File(fileout.getAbsolutePath() + "~-message");
+ setInputFilter(new Filter[]{
+ new RemoveCommentFilter(),
+ new ExtractMessageFilter()
+ });
+ ProcessorUtil.doProcess(this, filein, fileTemp1, encoding);
+
+ File fileTemp2 = new File(fileout.getAbsolutePath() + "~-format");
+
+ setInputFilter(new Filter[]{
+ new RemoveCommentFilter(),
+ new ExtractFormatFilter()
+ });
+ ProcessorUtil.doProcess(this, filein, fileTemp2, encoding);
+
+ String tmp1 = FileUtils.readFileToString(fileTemp1).trim();
+ String tmp2 = FileUtils.readFileToString(fileTemp2).trim();
+ if (log.isDebugEnabled()) {
+ log.debug("Keys from message:\n" + tmp1);
+ log.debug("Keys from format:\n" + tmp2);
+ }
+ FileUtils.writeStringToFile(fileout, tmp1 + "\n" + tmp2);
+ }
+
+ /**
+ * To remove comments from tapestry template files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public class RemoveCommentFilter extends DefaultFilter {
+
+ private String header = "<" + "!" + "-" + "-";
+
+ private String footer = "-" + "-" + ">";
+
+ @Override
+ protected String performInFilter(String ch) {
+ return EMPTY_STRING;
+ }
+
+ @Override
+ protected String performOutFilter(String ch) {
+ return ch;
+ }
+
+ protected String getHeader() {
+ return header;
+ }
+
+ protected String getFooter() {
+ return footer;
+ }
+ }
+
+ /**
+ * To obtain inside of {@code ${message:XXX}} from tapestry template files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public class ExtractMessageFilter extends DefaultFilter {
+
+ private String header = "$" + "{" + "m" + "e" + "s" + "s" + "a" + "g" + "e" + ":";
+
+ private String footer = "}";
+
+ @Override
+ protected String performInFilter(String ch) {
+ if (verbose) {
+ log.info("Detected key " + ch);
+ }
+ return ch + "\n";
+ }
+
+ @Override
+ protected String performOutFilter(String ch) {
+ return EMPTY_STRING;
+ }
+
+ protected String getHeader() {
+ return header;
+ }
+
+ protected String getFooter() {
+ return footer;
+ }
+ }
+
+ /**
+ * To obtain {@code XXX} data {@code ${format:XXX=YYY}} from tapestry template files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public class ExtractFormatFilter extends DefaultFilter {
+
+ private String header = "$" + "{" + "f" + "o" + "r" + "m" + "a" + "t" + ":";
+
+ private String footer = "}";
+
+ @Override
+ protected String performInFilter(String ch) {
+ int i = ch.indexOf('=');
+ if (verbose) {
+ log.info("Detected key " + ch);
+ }
+ if (i == -1) {
+ return "";
+ }
+ return ch.substring(0, i) + "\n";
+ }
+
+ @Override
+ protected String performOutFilter(String ch) {
+ return EMPTY_STRING;
+ }
+
+ protected String getHeader() {
+ return header;
+ }
+
+ protected String getFooter() {
+ return footer;
+ }
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/TapestryFileProcessor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/maven-i18n-plugin/src/site/apt/index.apt
===================================================================
--- trunk/maven-i18n-plugin/src/site/apt/index.apt 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/site/apt/index.apt 2011-01-04 08:15:32 UTC (rev 1836)
@@ -42,9 +42,9 @@
* {{{./parserValidation-mojo.html} i18n:parserValidation}} parse XWorks validation sources.
- * {{{./parserJavaActionConfig-mojo.html} i18n:parserJavaActionConfig}} parse actions jaxx.
+ * {{{./parserJsp-mojo.html} i18n:parserJsp}} parse JSP sources.
- * {{{./parserJavaTabConfig-mojo.html} i18n:parserJavaTabConfig}} parse tabs jaxx.
+ * {{{./parserTapestry-mojo.html} i18n:parserTapestry}} parse Tapestry templates sources.
* {{{./get-mojo.html} i18n:get}} assembly getter computed by parser-like goals.
Modified: trunk/maven-i18n-plugin/src/site/en/apt/index.apt
===================================================================
--- trunk/maven-i18n-plugin/src/site/en/apt/index.apt 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/site/en/apt/index.apt 2011-01-04 08:15:32 UTC (rev 1836)
@@ -42,9 +42,9 @@
* {{{./parserValidation-mojo.html} i18n:parserValidation}} parse XWorks validation sources.
- * {{{./parserJavaActionConfig-mojo.html} i18n:parserJavaActionConfig}} parse actions jaxx.
+ * {{{./parserJsp-mojo.html} i18n:parserJsp}} parse jsp sources.
- * {{{./parserJavaTabConfig-mojo.html} i18n:parserJavaTabConfig}} parse tabs jaxx.
+ * {{{./parserTapestry-mojo.html} i18n:parserTapestry}} parse Tapestry template sources.
* {{{./get-mojo.html} i18n:get}} assembly getter computed by parser-like goals.
Modified: trunk/maven-i18n-plugin/src/site/site_en.xml
===================================================================
--- trunk/maven-i18n-plugin/src/site/site_en.xml 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/site/site_en.xml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -51,11 +51,9 @@
<item name="Usages" href="usages.html"/>
<item name="Parser Goals" href="plugin-info.html">
<item name="parserJava" href="parserJava-mojo.html"/>
- <item name="parserJaxx" href="parserJaxx-mojo.html"/>
- <item name="parserSwixat" href="parserSwixat-mojo.html"/>
- <item name="parserJavaActionConfig"
- href="parserJavaActionConfig-mojo.html"/>
- <item name="parserJavaTabConfig" href="parserJavaTabConfig-mojo.html"/>
+ <item name="parserXml" href="parserXml-mojo.html"/>
+ <item name="parserJsp" href="parserJsp-mojo.html"/>
+ <item name="parserTapestry" href="parserTapestry-mojo.html"/>
<item name="parserValidation" href="parserValidation-mojo.html"/>
<item name="get" href="get-mojo.html"/>
<item name="gen" href="gen-mojo.html"/>
Modified: trunk/maven-i18n-plugin/src/site/site_fr.xml
===================================================================
--- trunk/maven-i18n-plugin/src/site/site_fr.xml 2011-01-03 20:13:39 UTC (rev 1835)
+++ trunk/maven-i18n-plugin/src/site/site_fr.xml 2011-01-04 08:15:32 UTC (rev 1836)
@@ -49,11 +49,9 @@
<item name="Usages" href="usages.html"/>
<item name="Parser Goals" href="plugin-info.html">
<item name="parserJava" href="parserJava-mojo.html"/>
- <item name="parserJaxx" href="parserJaxx-mojo.html"/>
- <item name="parserSwixat" href="parserSwixat-mojo.html"/>
- <item name="parserJavaActionConfig"
- href="parserJavaActionConfig-mojo.html"/>
- <item name="parserJavaTabConfig" href="parserJavaTabConfig-mojo.html"/>
+ <item name="parserXml" href="parserXml-mojo.html"/>
+ <item name="parserJsp" href="parserJsp-mojo.html"/>
+ <item name="parserTapestry" href="parserTapestry-mojo.html"/>
<item name="parserValidation" href="parserValidation-mojo.html"/>
<item name="get" href="get-mojo.html"/>
<item name="gen" href="gen-mojo.html"/>
1
0