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
November 2010
- 3 participants
- 44 discussions
r1800 - in trunk/maven-i18n-plugin: . src/main/java/org/nuiton/i18n/plugin src/main/java/org/nuiton/i18n/plugin/bundle src/main/java/org/nuiton/i18n/plugin/parser src/main/java/org/nuiton/i18n/plugin/parser/impl
by tchemit@users.nuiton.org 11 Nov '10
by tchemit@users.nuiton.org 11 Nov '10
11 Nov '10
Author: tchemit
Date: 2010-11-11 14:02:21 +0100 (Thu, 11 Nov 2010)
New Revision: 1800
Url: http://nuiton.org/repositories/revision/i18n/1800
Log:
use {@code ...} instead of <code>...</code> + Anomalie #1030: All mojo configuration documentation must be in english. + improve parser mojos
Added:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java
Modified:
trunk/maven-i18n-plugin/pom.xml
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/bundle/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.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/AbstractI18nParserMojo.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/ParserValidationMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/pom.xml 2010-11-11 13:02:21 UTC (rev 1800)
@@ -113,9 +113,8 @@
<!-- ************************************************************* -->
<name>I18n :: Maven Plugin</name>
<description>
- Plugin pour maven 2 de génération des bundles pour
- l'internationalisation (i18n) des applications java
- basé sur nuiton-i18n-api.
+ Maven plugin to deal with i18n stuff in a project, mainly base on the
+ nuiton-i18n api (but not only).
</description>
<inceptionYear>2007</inceptionYear>
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -34,14 +34,18 @@
import java.io.File;
import java.io.IOException;
import java.util.Locale;
+import java.util.Map;
import java.util.Properties;
import java.util.SortedSet;
+import java.util.TreeSet;
/**
- * Classe permettant d'obenir les parametres pendant les différentes phases du
- * plugin.
+ * Lower level i18n mojo abstraction.
+ * <p/>
+ * We defines here all commons parameters and shared behaviour.
*
- * @author julien
+ * @author tchemit <chemit(a)codelutin.com>
+ * @author jruchaud <ruchaud(a)codelutin.com>
*/
public abstract class AbstractI18nMojo extends AbstractPlugin implements PluginWithEncoding {
@@ -58,7 +62,9 @@
protected MavenProject project;
/**
- * Nom du projet.
+ * Name to use as prefix of generated files.
+ * <p/>
+ * <b>Note :</b> By default, use the artifact id.
*
* @parameter expression="${i18n.artifactId}" default-value="${project.artifactId}"
* @readonly
@@ -66,8 +72,10 @@
protected String artifactId;
/**
- * Langues des bundles generes.
+ * Locales to treate, separated by comma.
* <p/>
+ * Example :
+ * <pre>fr_FR,en_GB</pre>
*
* @parameter expression="${i18n.bundles}" default-value="fr_FR,en_GB"
* @required
@@ -75,7 +83,7 @@
protected String bundles;
/**
- * Repertoire sources des fichiers i18n.
+ * Directory where to find project i18n files.
*
* @parameter expression="${i18n.src}" default-value="${basedir}/src/main/resources/i18n"
* @required
@@ -83,7 +91,7 @@
protected File src;
/**
- * Repertoire des fichiers generes i18n.
+ * Directory where to generate i18n files.
*
* @parameter expression="${i18n.out}" default-value="${basedir}/target/generated-sources/i18n"
* @required
@@ -91,7 +99,7 @@
protected File out;
/**
- * encoding a utiliser pour charger et sauver les bundles
+ * Encoding used to load and store files.
* <p/>
* <b>Note:</b> If nothing is filled here, we will use the system
* property {@code file.encoding}.
@@ -102,26 +110,26 @@
protected String encoding;
/**
- * Met les fichiers generes dans le repertoire des sources i18n.
+ * To update generated files to user i18n files.
* <p/>
- * Note: Par défaut active, pour pouvoir paquager avec les bundles mis a
- * jour.
+ * <b>Note :</b> By default, this is active, in order to have a project uptodate
+ * with last i18n bundles detected.
*
* @parameter expression="${i18n.genSrc}" default-value="true"
*/
protected boolean genSrc;
/**
- * verbose flag
+ * Verbose flag.
* <p/>
- * Note: si non renseigne, on utilise la propiété <code>maven.verbose</code>.
+ * <b>Note :</b> if not setted, we used the {@code maven.verbose} property.
*
* @parameter expression="${i18n.verbose}" default-value="${maven.verbose}"
*/
protected boolean verbose;
/**
- * silent flag
+ * Silent flag to see only errors in console.
*
* @parameter expression="${i18n.silent}" default-value="false"
* @since 1.0.0-rc-5
@@ -129,21 +137,22 @@
protected boolean silent;
/**
- * ne conserve que les clef scannees (et donc traite tous les fichiers)
+ * Strict mode to only keep in user i18n detected i18n keys and remove obsolete keys.
* <p/>
- * <p/>
- * Note : par default, on ne l'active car rescanne tous les fichiers. s
+ * <b>Note :</b> By default not active. Use this with care since it can
+ * delete keys. Moreover if this flag is activated, then all files will be parsed.
*
* @parameter expression="${i18n.strictMode}" default-value="false"
*/
protected boolean strictMode;
- /** les locales a traiter */
+ /** locales to process */
protected Locale[] locales;
@Override
protected boolean checkPackaging() {
+
// nothing to do on a pom module
return !acceptPackaging(Packaging.pom);
}
@@ -169,8 +178,8 @@
}
/**
- * @return <code>true</code> si des getters ont etes enregistres pendant le
- * cycle de vie, <code>false</code> sinon.
+ * @return {@code true} si des getters ont etes enregistres pendant le
+ * cycle de vie, {@code false} sinon.
*/
protected boolean needGeneration() {
boolean needGeneration = NB_GETTER_FILES > 0;
@@ -191,7 +200,7 @@
* @param root le repertoire ou sont stockes les fichiers i18n
* @param artifactId le nom de l'artifact
* @param locale le nom du bundle
- * @param create <code>true</code> pour creer le fichier si non present
+ * @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
*/
@@ -209,7 +218,7 @@
/**
* @param root le repertoire ou sont stockes les fichiers getter
* @param getter le nom du getter
- * @param create <code>true</code> pour creer le fichier si non present
+ * @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
*/
@@ -223,14 +232,24 @@
return file;
}
- protected boolean checkBundle(Locale locale, Properties propertiesOut,
- boolean showEmpty) {
+ protected void checkBundle(Locale locale,
+ Properties propertiesOut,
+ boolean showEmpty,
+ Map<Locale, SortedSet<String>> unsafeHolder) {
- boolean safe = true;
// on verifie qu'il n'y a pas de traduction vide
SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut);
if (!emptyEntries.isEmpty()) {
- safe=false;
+ if (unsafeHolder != null) {
+
+ // push empties i18n keys in the holder
+ SortedSet<String> empties = unsafeHolder.get(locale);
+ if (empties == null) {
+ empties = new TreeSet<String>();
+ unsafeHolder.put(locale, empties);
+ }
+ empties.addAll(emptyEntries);
+ }
StringBuilder buffer = new StringBuilder();
int size = emptyEntries.size();
buffer.append("bundle ");
@@ -261,7 +280,6 @@
" entries).");
}
}
- return safe;
}
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -33,9 +33,10 @@
import java.util.Locale;
/**
- * Merge des fichiers de propriétés avec les anciens.
+ * Merge new generated i18n bundles with older existing ones.
*
- * @author julien
+ * @author jruchaud <ruchaud(a)codelutin.com>
+ * @author chemit <chemit(a)codelutin.com>
* @goal gen
* @phase generate-resources
* @execute goal=get
@@ -43,8 +44,7 @@
public class GenerateMojo extends AbstractI18nMojo {
/**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
- * vides.
+ * A flag to check that bundles are complete (no missing i18n translations).
*
* @parameter expression="${i18n.checkBundle}" default-value="true"
* @required
@@ -53,8 +53,9 @@
protected boolean checkBundle;
/**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link
- * #checkBundle} activé).
+ * A flag to show missing i18n translation.
+ * <p/>
+ * <b>Note :</b> Need the {@link #checkBundle} to be activated).
*
* @parameter expression="${i18n.showEmpty}" default-value="false"
* @required
@@ -63,16 +64,18 @@
protected boolean showEmpty;
/**
- * conserve les anciens fichiers de traduction avec un suffix ~
+ * To keep a backup of old i18n bundles (suffiex by a {@code ~}).
* <p/>
- * Note: par defaut, on ne l'active pas.
+ * <b>Note: </b> By default, this property is not active.
*
* @parameter expression="${i18n.keepBackup}" default-value="false"
*/
protected boolean keepBackup;
/**
- * Conserve les fichiers de getters.
+ * To keep generated getter files.
+ * <p/>
+ * <b>Note: </b> By default, this property is not active.
*
* @parameter expression="${i18n.keepGetters}" default-value="false"
*/
@@ -153,7 +156,7 @@
}
if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
+ checkBundle(locale, propertiesOut, showEmpty, null);
}
if (genSrc) {
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -43,7 +43,9 @@
public class GetterMojo extends AbstractI18nMojo {
/**
- * Conserve les fichiers de getters.
+ * To keep generated getter files.
+ * <p/>
+ * <b>Note: </b> By default, this property is not active.
*
* @parameter expression="${i18n.keepGetters}" default-value="false"
*/
Added: 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 (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -0,0 +1,130 @@
+/*
+ * #%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.bundle;
+
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SortedSet;
+
+/**
+ * Common mojo to all final bundle maker.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public abstract class AbstractMakeI18nBundleMojo extends AbstractI18nBundleMojo {
+
+ /**
+ * Directory where to generate aggregated bundles.
+ *
+ * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources/META-INF"
+ * @required
+ * @since 1.0.0
+ */
+ protected File bundleOutputDir;
+
+ /**
+ * Name of the bundle to generate.
+ *
+ * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected String bundleOutputName;
+
+ /**
+ * 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.
+ *
+ * @parameter expression="${i18n.checkBundle}" default-value="true"
+ * @since 1.0.0
+ */
+ protected boolean checkBundle;
+
+ /**
+ * A flag to show missing i18n translation.
+ * <p/>
+ * <b>Note :</b> Need the {@link #checkBundle} to be activated).
+ *
+ * @parameter expression="${i18n.showEmpty}" default-value="false"
+ * @since 1.0.0
+ */
+ protected boolean showEmpty;
+
+ /**
+ * A flag to make the build fails if there is some warnings while generating
+ * bundle, says when it misses some translations.
+ * <p/>
+ * <b>Note :</b> This parameter should be used in a release profile to
+ * ensure bundles are complete.
+ *
+ * @parameter expression="${i18n.failsIfWarning}" default-value="false"
+ * @since 2.0
+ */
+ protected boolean failsIfWarning;
+
+ /** to keep all none translated i18n keys by locale. */
+ protected Map<Locale, SortedSet<String>> unsafeMapping;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+
+ if (failsIfWarning) {
+
+ // check bundle if wants to fail on unsafe bundles
+ checkBundle = true;
+
+ unsafeMapping = new HashMap<Locale, SortedSet<String>>();
+ } else {
+ unsafeMapping = null;
+ }
+
+ createDirectoryIfNecessary(bundleOutputDir);
+ }
+
+ protected void failsIfWarning() throws MojoFailureException {
+ if (!failsIfWarning) {
+
+ // no check
+ return;
+ }
+
+ if (unsafeMapping != null && !unsafeMapping.isEmpty()) {
+
+ // there is at least one not complete bundle, faisl the build
+ throw new MojoFailureException(
+ "Bundles for locale(s) " + unsafeMapping.keySet() +
+ " are not complete. Use the -Di18n.showEmpty to see " +
+ "missing translations.");
+ }
+ }
+
+}
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -25,7 +25,6 @@
package org.nuiton.i18n.plugin.bundle;
-import org.apache.maven.plugin.MojoFailureException;
import org.nuiton.i18n.bundle.I18nBundleEntry;
import org.nuiton.i18n.bundle.I18nBundleUtil;
import org.nuiton.i18n.init.DefaultI18nInitializer;
@@ -45,25 +44,18 @@
import java.util.Map.Entry;
/**
- * Créer un bundle pour une application finale.
+ * Generate an aggregate i18n bundle for all dependencies of the project.
* <p/>
- * Cela génère un merge de tous les fichiers i18n utilisés en un seul.
+ * The main idea is to have a final unique i18n bundle for a application to
+ * launch, this really improve i18n loading time to have a unique named bundle,
+ * no need to seek in all dependencies...
* <p/>
- * On utilise la dépendance sur les artifacts pour connaitre l'ordre le
- * chargement des bundles.
+ * Moreover, this permits also to deal with order of i18n keys, more precisly,
+ * we want to use the higher level i18n key for an application. If the i18n
+ * key is present on a library, we want to be able to override it in
+ * application (or user wants it:)).
* <p/>
- * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors
- * celui du parent,
- * <p/>
- * Ainsi on obtient un bundle dont toutes les clefs sont traduites.
- * <p/>
- * Le but aussi d'utiliser un unique bundle est de gagner du temps au runtime
- * car la recherche des bundles devient trop couteuse en temps lorsque l'on a de
- * nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
- * secondes, ce qui 'est pas acceptable).
- * <p/>
- * On a ajoute un second mode d'initialisation dans la clesse I18n pour
- * n'utiliser qu'un seul bundle et courcircuiter le chargement couteux...
+ * This goal permits this using the dependencies graph order of artifacts.
*
* @author tchemit <chemit(a)codelutin.com>
* @goal bundle
@@ -73,49 +65,17 @@
* @requiresDependencyResolution runtime
* @since 0.12
*/
-public class BundleMojo extends AbstractI18nBundleMojo {
+public class BundleMojo extends AbstractMakeI18nBundleMojo {
/**
- * Repertoire ou generer les bundles.
- *
- * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources/META-INF"
- * @required
- * @since 1.0.0
- */
- protected File bundleOutputDir;
-
- /**
- * Nom du bundle a generer.
- *
- * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n"
- * @required
- * @since 1.0.2
- */
- protected String bundleOutputName;
-
- /**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
- * vides.
- *
- * @parameter expression="${i18n.checkBundle}" default-value="true"
- * @since 1.0.0
- */
- protected boolean checkBundle;
-
- /**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link
- * #checkBundle} activé).
- *
- * @parameter expression="${i18n.showEmpty}" default-value="false"
- * @since 1.0.0
- */
- protected boolean showEmpty;
-
- /**
- * Un drapeau pour utiliser le répertoire parent du {@link #bundleOutputDir}
- * comme répertoire de ressources à ajouter au build.
+ * A flag to use the parent of directory {@link #bundleOutputDir}
+ * as directory to add in build ressources.
* <p/>
- * Si ce drapeau n'est pas activé, alors on utilise directement le répertoire donné.
+ * If the flag is not activated, the, we use directly the given
+ * {@link #bundleOutputDir} directory.
+ * <p/>
+ * <b>Note :</b> By default we use the parent directory, since this is more
+ * natural, only special cases should desactivate this parameter.
*
* @parameter expression="${i18n.addBundleOuputDirParent}" default-value="true"
* @since 2.0
@@ -123,35 +83,20 @@
protected boolean addBundleOuputDirParent;
/**
- * Un drapeau pour générer le fichier de définition i18n.
+ * A flag to generate the i18n definition file.
* <p/>
- * Ce fichier permet d'avoir les locales utilisables par I18n ainsi que les
- * chemins (dans le classpath) des resources i18n utilisées pour construire
- * le bundle final.
+ * This file contains all generated bundles and the paths of all i18n
+ * artifacts used to make it.
*
* @parameter expression="${i18n.generateDefinitionFile}" default-value="true"
* @since 2.0
*/
protected boolean generateDefinitionFile;
- /**
- * A flag to make the build fails if there is some warnings while generating
- * bundle, says when it misses some translations.
- * <p/>
- * <b>Note :</b> This parameter should be used in a release profile to
- * ensure bundles are complete.
- *
- * @parameter expression="${i18n.failsIfWarning}" default-value="false"
- * @since 2.0
- */
- protected boolean failsIfWarning;
-
@Override
public void init() throws Exception {
super.init();
- createDirectoryIfNecessary(bundleOutputDir);
-
// ajout de repertoire de generation (le parent en fait)
// dans les resources du projet
@@ -180,13 +125,15 @@
Map<Locale, String> bundleDico =
new LinkedHashMap<Locale, String>(locales.length);
- List<Locale> unsafeLocales = new ArrayList<Locale>();
for (Locale locale : locales) {
long t0 = System.nanoTime();
- File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName,
- locale, false);
+ File bundleOut = getI18nFile(bundleOutputDir,
+ bundleOutputName,
+ locale,
+ false
+ );
SortedProperties propertiesOut =
new SortedProperties(encoding, false);
@@ -241,47 +188,16 @@
PluginHelper.convertTime(t0, System.nanoTime()) +
" (detected sentences : " + propertiesOut.size() + ")");
}
- if (checkBundle || failsIfWarning) {
- boolean localSafe =
- checkBundle(locale, propertiesOut, showEmpty);
- if (!localSafe) {
- unsafeLocales.add(locale);
- }
+ if (checkBundle) {
+ checkBundle(locale, propertiesOut, showEmpty, unsafeMapping);
}
}
- if (failsIfWarning && !unsafeLocales.isEmpty()) {
+ failsIfWarning();
- // there is at least one not complete bundle, faisl the build
- throw new MojoFailureException("Bundles for locale(s) " + unsafeLocales + " are not complete");
- }
-
if (generateDefinitionFile) {
- // ecriture du ficher des definitions i18n (permet de faire une
- // recherche exacte sur un fichier puis d'en deduire les bundles a
- // charger
- String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
- bundleOutputName);
- File defOut = new File(bundleOutputDir, f);
- if (!silent) {
- getLog().info("prepare i18n definition " +
- defOut.getAbsolutePath());
- }
- SortedProperties p = new SortedProperties(encoding, false);
- p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
- p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
- for (Entry<Locale, String> e : bundleDico.entrySet()) {
- p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
- e.getKey().toString(), e.getValue());
- }
- FileOutputStream out = new FileOutputStream(defOut);
- try {
- p.store(out, null);
- } finally {
- out.close();
- }
-
+ generateDefinitionFile(version, bundleDico);
}
if (!silent && verbose) {
getLog().info("done in " +
@@ -289,6 +205,34 @@
}
}
+ protected void generateDefinitionFile(String version,
+ Map<Locale, String> bundleDico) throws IOException {
+
+ // ecriture du ficher des definitions i18n (permet de faire une
+ // recherche exacte sur un fichier puis d'en deduire les bundles a
+ // charger
+ String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
+ bundleOutputName);
+ File defOut = new File(bundleOutputDir, f);
+ if (!silent) {
+ getLog().info("prepare i18n definition file in " +
+ defOut.getAbsolutePath());
+ }
+ SortedProperties p = new SortedProperties(encoding, false);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
+ for (Entry<Locale, String> e : bundleDico.entrySet()) {
+ p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
+ e.getKey().toString(), e.getValue());
+ }
+ FileOutputStream out = new FileOutputStream(defOut);
+ try {
+ p.store(out, null);
+ } finally {
+ out.close();
+ }
+ }
+
@Override
protected URL[] getCollectI18nResources(Locale locale) throws IOException {
File file = getCollectOutputFile(locale, false);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -48,9 +48,11 @@
import java.util.Map;
/**
- * Detects any i18n artifacts and store the result as a file.
+ * Detects any i18n artifacts in the dependencies of the project and store
+ * their references in a file.
* <p/>
- * Created: 24 déc. 2009
+ * The generated file will be used by {@code bundle} mojo to generate the final
+ * aggregated bundle.
*
* @author tchemit <chemit(a)codelutin.com>
* @goal collect-i18n-artifacts
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/TapestryBundleMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -40,25 +40,10 @@
/**
- * Créer un bundle pour une application finale.
+ * Generates a unique bundle for a tapestry application.
* <p/>
- * Cela génère un merge de tous les fichiers i18n utilisés en un seul.
- * <p/>
- * On utilise la dépendance sur les artifacts pour connaitre l'ordre le
- * chargement des bundles.
- * <p/>
- * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors
- * celui du parent,
- * <p/>
- * Ainsi on obtient un bundle dont toutes les clefs sont traduites.
- * <p/>
- * Le but aussi d'utiliser un unique bundle est de gagner du temps au runtime
- * car la recherche des bundles devient trop couteuse en temps lorsque l'on a de
- * nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
- * secondes, ce qui 'est pas acceptable).
- * <p/>
- * On a ajoute un second mode d'initialisation dans la clesse I18n pour
- * n'utiliser qu'un seul bundle et courcircuiter le chargement couteux...
+ * <b>Note :</b> The mojo has nothing specific to tapestry and should be renamed
+ * (or removed since the {@code bundle} mojo do the same with more options)...
*
* @author tchemit <chemit(a)codelutin.com>
* @goal tapestry-bundle
@@ -68,54 +53,9 @@
* @requiresDependencyResolution runtime
* @since 1.2
*/
-public class TapestryBundleMojo extends AbstractI18nBundleMojo {
+public class TapestryBundleMojo extends AbstractMakeI18nBundleMojo {
- /**
- * Repertoire ou generer les bundles.
- *
- * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/src/main/webapp/WEB-INF"
- * @required
- * @since 1.0.0
- */
- protected File bundleOutputDir;
-
- /**
- * Nom du bundle a generer.
- *
- * @parameter expression="${i18n.bundleOutputName}" default-value="app"
- * @required
- * @since 1.0.2
- */
- protected String bundleOutputName;
-
- /**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
- * vides.
- *
- * @parameter expression="${i18n.checkBundle}" default-value="true"
- * @required
- * @since 1.0.0
- */
- protected boolean checkBundle;
-
- /**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link
- * #checkBundle} activé).
- *
- * @parameter expression="${i18n.showEmpty}" default-value="false"
- * @required
- * @since 1.0.0
- */
- protected boolean showEmpty;
-
@Override
- public void init() throws Exception {
- super.init();
-
- createDirectoryIfNecessary(bundleOutputDir);
- }
-
- @Override
protected void doAction() throws Exception {
long t00 = System.nanoTime();
@@ -185,21 +125,24 @@
" (detected sentences : " + propertiesOut.size() + ")");
}
if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
+ checkBundle(locale, propertiesOut, showEmpty, unsafeMapping);
}
}
+ failsIfWarning();
+
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
* @param locale le nom du bundle
- * @param create <code>true</code> pour creer le fichier si non present
+ * @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
*/
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -82,12 +82,20 @@
public abstract FileUpdater newFileUpdater(SourceEntry entry);
/**
- * Active la modification de cle.
+ * Build directory (used to know if files in sources are up-to-date).
+ *
+ * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
+ */
+ protected File cp;
+
+ /**
+ * To activate the modification of keys
* <p/>
- * Note: par defaut, on ne l'active pas (build sur serveur non ui).
+ * <b>Note :</b> By default not active, since it requires to have UI available
+ * and this is not acceptable for server build.
* <p/>
- * Note: Ce paramètre n'est plus actif, la fonctionnalité n'est plus
- * disponible et sera remplacé par un autre goal.
+ * <b>Note :</b> At the moment the fully fonctionnality is no more available
+ * and will be recode in a separated goal (one day...)
*
* @parameter expression="${i18n.keysModifier}" default-value="false"
* @deprecated since 1.2, will no more used
@@ -96,24 +104,24 @@
protected boolean keysModifier;
/**
- * treate default entry
+ * To treate default entry offered by the mojo.
*
* @parameter expression="${i18n.treateDefaultEntry}" default-value="true"
*/
protected boolean treateDefaultEntry;
/**
- * Source entries (src+includes+excludes) .
+ * Source entries (src+includes+excludes) to process.
*
* @parameter expression="${i18n.entries}"
*/
protected I18nSourceEntry[] entries;
/**
- * flag to display touched files while parsing.
+ * Flag to display touched files while parsing.
* <p/>
- * Note: the value will be always <code>true</code> if {@link #verbose} is
- * set at <code>true</code>.
+ * Note: the value will be always {@code true} if {@link #verbose} is
+ * set at {@code true}.
*
* @parameter expression="${i18n.showTouchedFiles}" default-value="${maven.verbose}"
* @since 0.9
@@ -121,7 +129,7 @@
protected boolean showTouchedFiles;
/**
- * flag to save previous getter in a backup before doing parsing.
+ * Flag to save previous getter in a backup before doing parsing.
* <p/>
* Note: by default, do not perform backup (but it was here originaly so let
* it possible...)
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -44,35 +44,40 @@
import java.io.LineNumberReader;
/**
- * Récupération des chaine a traduire depuis les fichiers java.
+ * To parse java files to detect new i18n keys.
*
- * @author julien
+ * <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
* @phase generate-resources
*/
public class ParserJavaMojo extends AbstractI18nParserMojo {
/**
- * Source entries (src+includes+excludes) .
+ * Root directory of the default entry.
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java"
+ * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java"
*/
- protected String defaultIncludes;
+ protected File defaultBasedir;
/**
- * default src for an entry.
+ * Default included files to process (ant-like expression).
*
- * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java"
*/
- protected File defaultBasedir;
+ protected String defaultIncludes;
/**
- * Repertoire sources des fichiers i18n.
+ * Defines the file name of the getter where to put detected i18n keys
+ * while getter phase.
*
- * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
- * @required
+ * @parameter expression="${i18n.outputGetter}" default-value="java.getter"
+ * @since 2.0
*/
- protected File cp;
+ protected String outputGetter;
@Override
public String[] getDefaultIncludes() {
@@ -108,7 +113,7 @@
@Override
protected String getOutGetter() {
- return "java.getter";
+ return outputGetter;
}
@Override
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -42,9 +42,9 @@
/**
* Find i18n keys from xworks xml validation files.
- *
+ * <p/>
* <b>Note: </b> this goal must always be invoked before the {@code process-resources}
- * phase, otherwise all files will be considered as uptodate.
+ * phase, otherwise all files will be considered as uptodate.
*
* @author tchemit <chemit(a)codelutin.com>
* @goal parserValidation
@@ -55,18 +55,19 @@
final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd");
/**
- * Source entries (src+includes+excludes) .
+ * Root directory of the default entry.
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml"
+ * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/resources"
+ * @required
*/
- protected String defaultIncludes;
+ protected File defaultBasedir;
/**
- * Where jaxx files should have been generated.
+ * Default included files to process (ant-like expression).
*
- * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml"
*/
- protected File cp;
+ protected String defaultIncludes;
/**
* Defines the core rules file used to detect i18n keys in xml validation
@@ -81,14 +82,6 @@
protected String coreRuleFile;
/**
- * default src for an entry.
- *
- * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/resources"
- * @required
- */
- protected File defaultBasedir;
-
- /**
* Always use the local xowrks dtd to increase performance.
*
* @parameter expression="${i18n.useLocalResolver}" default-value="true"
@@ -97,7 +90,8 @@
protected boolean useLocalResolver;
/**
- * Defines the file name of the getter where to put detected i18n keys while getter phase.
+ * Defines the file name of the getter where to put detected i18n keys
+ * while getter phase.
*
* @parameter expression="${i18n.outputGetter}" default-value="validation.getter"
* @since 2.0
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 2010-11-11 13:01:26 UTC (rev 1799)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2010-11-11 13:02:21 UTC (rev 1800)
@@ -76,17 +76,6 @@
protected String coreRuleFile;
/**
- * Defines where included files will be copied.
- * <p/>
- * Knowing this permits us to parse included xml files only if they were
- * modified from a previous build.
- *
- * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
- * @since 2.0
- */
- protected File cp;
-
- /**
* Defines the file name of the getter where to put detected i18n keys while getter phase.
*
* @parameter expression="${i18n.outputGetter}" default-value="xmlUser.getter"
1
0
r1799 - in trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor: project ui
by tchemit@users.nuiton.org 11 Nov '10
by tchemit@users.nuiton.org 11 Nov '10
11 Nov '10
Author: tchemit
Date: 2010-11-11 14:01:26 +0100 (Thu, 11 Nov 2010)
New Revision: 1799
Url: http://nuiton.org/repositories/revision/i18n/1799
Log:
use {@code ...} instead of <code>...</code>
Modified:
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2010-11-11 12:08:48 UTC (rev 1798)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2010-11-11 13:01:26 UTC (rev 1799)
@@ -48,7 +48,7 @@
/**
*
- * @return <code>true</code> si la definition du projet est persiste
+ * @return {@code true} si la definition du projet est persiste
*/
boolean isStoreProject();
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2010-11-11 12:08:48 UTC (rev 1798)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2010-11-11 13:01:26 UTC (rev 1799)
@@ -101,8 +101,8 @@
* ce type de projet.
*
* @param model le model a valider
- * @return <code>true</code> si la partie specifique a ce type de projet
- * est valide, <code>false</code> autrement.
+ * @return {@code true} si la partie specifique a ce type de projet
+ * est valide, {@code false} autrement.
*/
boolean validateUIModel(ProjectUIModel model);
@@ -114,7 +114,7 @@
* afin de verifier la coherence du projet.
*
* @param properties les proprietes de la definition du projet
- * @return <code>true</code> si le projet est valide.
+ * @return {@code true} si le projet est valide.
*/
boolean validateDefinition(Properties properties);
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2010-11-11 12:08:48 UTC (rev 1798)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2010-11-11 13:01:26 UTC (rev 1799)
@@ -268,7 +268,7 @@
/**
* Méthode pour changer de mode d'affichage.
* <p/>
- * Si <code>fullscreen</code> est à <code>true</code> alors on passe en
+ * Si <code>fullscreen</code> est à {@code true} alors on passe en
* mode console (c'est à dire en mode plein écran exclusif), sinon on
* passe en mode fenetré normal.
*
@@ -938,7 +938,7 @@
* Test if there is some modification on screen,
*
* @param rootContext the context
- * @return <code>true</code> if no more modification is detected
+ * @return {@code true} if no more modification is detected
* @throws IllegalArgumentException if rootContext is null
*/
protected boolean ensureModification(JAXXContext rootContext) throws IllegalArgumentException {
1
0
r1798 - trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle
by tchemit@users.nuiton.org 11 Nov '10
by tchemit@users.nuiton.org 11 Nov '10
11 Nov '10
Author: tchemit
Date: 2010-11-11 13:08:48 +0100 (Thu, 11 Nov 2010)
New Revision: 1798
Url: http://nuiton.org/repositories/revision/i18n/1798
Log:
use {@code ...} instead of <code>...</code>
Modified:
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java 2010-11-11 11:16:40 UTC (rev 1797)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java 2010-11-11 12:08:48 UTC (rev 1798)
@@ -99,7 +99,7 @@
*
* @param locale the locale to match
* @param scope the highest scope to match
- * @return <code>true</code> if the entry match the scope and locale *
+ * @return {@code true} if the entry match the scope and locale *
*/
public boolean matchLocale(Locale locale, I18nBundleScope scope) {
if (this.locale == null) {
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 2010-11-11 11:16:40 UTC (rev 1797)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java 2010-11-11 12:08:48 UTC (rev 1798)
@@ -283,7 +283,7 @@
* Teste si un ensemble de bundles contient au moins une entrée.
*
* @param bundles les bundles a parcourir
- * @return <code>true</code> si aucune entree trouvee, <code>false</code>
+ * @return {@code true} si aucune entree trouvee, {@code false}
* autrement.
*/
public static boolean isEmpty(I18nBundle... bundles) {
1
0
r1797 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . bundle
by tchemit@users.nuiton.org 11 Nov '10
by tchemit@users.nuiton.org 11 Nov '10
11 Nov '10
Author: tchemit
Date: 2010-11-11 12:16:40 +0100 (Thu, 11 Nov 2010)
New Revision: 1797
Url: http://nuiton.org/repositories/revision/i18n/1797
Log:
Evolution #754: Add a flag failsIfWarning on bundle 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/BundleMojo.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 2010-11-11 11:00:37 UTC (rev 1796)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-11-11 11:16:40 UTC (rev 1797)
@@ -223,11 +223,14 @@
return file;
}
- protected void checkBundle(Locale locale, Properties propertiesOut,
+ protected boolean checkBundle(Locale locale, Properties propertiesOut,
boolean showEmpty) {
+
+ boolean safe = true;
// on verifie qu'il n'y a pas de traduction vide
SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut);
if (!emptyEntries.isEmpty()) {
+ safe=false;
StringBuilder buffer = new StringBuilder();
int size = emptyEntries.size();
buffer.append("bundle ");
@@ -258,6 +261,7 @@
" entries).");
}
}
+ return safe;
}
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 2010-11-11 11:00:37 UTC (rev 1796)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-11-11 11:16:40 UTC (rev 1797)
@@ -25,6 +25,7 @@
package org.nuiton.i18n.plugin.bundle;
+import org.apache.maven.plugin.MojoFailureException;
import org.nuiton.i18n.bundle.I18nBundleEntry;
import org.nuiton.i18n.bundle.I18nBundleUtil;
import org.nuiton.i18n.init.DefaultI18nInitializer;
@@ -133,6 +134,18 @@
*/
protected boolean generateDefinitionFile;
+ /**
+ * A flag to make the build fails if there is some warnings while generating
+ * bundle, says when it misses some translations.
+ * <p/>
+ * <b>Note :</b> This parameter should be used in a release profile to
+ * ensure bundles are complete.
+ *
+ * @parameter expression="${i18n.failsIfWarning}" default-value="false"
+ * @since 2.0
+ */
+ protected boolean failsIfWarning;
+
@Override
public void init() throws Exception {
super.init();
@@ -167,6 +180,7 @@
Map<Locale, String> bundleDico =
new LinkedHashMap<Locale, String>(locales.length);
+ List<Locale> unsafeLocales = new ArrayList<Locale>();
for (Locale locale : locales) {
long t0 = System.nanoTime();
@@ -227,13 +241,23 @@
PluginHelper.convertTime(t0, System.nanoTime()) +
" (detected sentences : " + propertiesOut.size() + ")");
}
- if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
+ if (checkBundle || failsIfWarning) {
+ boolean localSafe =
+ checkBundle(locale, propertiesOut, showEmpty);
+ if (!localSafe) {
+ unsafeLocales.add(locale);
+ }
}
}
+ if (failsIfWarning && !unsafeLocales.isEmpty()) {
+
+ // there is at least one not complete bundle, faisl the build
+ throw new MojoFailureException("Bundles for locale(s) " + unsafeLocales + " are not complete");
+ }
+
if (generateDefinitionFile) {
-
+
// ecriture du ficher des definitions i18n (permet de faire une
// recherche exacte sur un fichier puis d'en deduire les bundles a
// charger
1
0
r1796 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl
by tchemit@users.nuiton.org 11 Nov '10
by tchemit@users.nuiton.org 11 Nov '10
11 Nov '10
Author: tchemit
Date: 2010-11-11 12:00:37 +0100 (Thu, 11 Nov 2010)
New Revision: 1796
Url: http://nuiton.org/repositories/revision/i18n/1796
Log:
add header
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r1795 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl
by tchemit@users.nuiton.org 11 Nov '10
by tchemit@users.nuiton.org 11 Nov '10
11 Nov '10
Author: tchemit
Date: 2010-11-11 11:52:30 +0100 (Thu, 11 Nov 2010)
New Revision: 1795
Url: http://nuiton.org/repositories/revision/i18n/1795
Log:
Evolution #1026: Introduce parserXml mojo
Evolution #1027: Refactor ParserXml***
Evolution #1028: Deprecates parserJavaActionConfig and parserJavaTabConfig mojo
Added:
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/ParserXmlUserMojo.java
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.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/ParserXmlMojo.java
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java (from rev 1789, 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/AbstractParserXmlMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2010-11-11 10:52:30 UTC (rev 1795)
@@ -0,0 +1,370 @@
+/*
+ * #%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.commons.lang.StringUtils;
+import org.apache.maven.plugin.MojoFailureException;
+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.namespace.NamespaceContext;
+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;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Abstract xml parser mojo.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @author jruchaud <ruchaud(a)codelutin.com>
+ * @since 2.0
+ */
+public abstract class AbstractParserXmlMojo extends AbstractI18nParserMojo {
+
+ /** Taille du buffer pour les lectures/écritures */
+ protected static final int BUFFER_SIZE = 8 * 1024;
+
+ /** available rules to detect i18n keys in xml files. */
+ protected String rules;
+
+ /** XPath factory used to detect i18n keys in xml files. */
+ protected XPathFactory factory;
+
+ /** Document builder factory to load xml files. */
+ protected DocumentBuilderFactory documentBuilderFactory;
+
+ /**
+ * Extra rules files to use for detecting i18n keys in xml validation files.
+ * <p/>
+ * <b>Note : </b> If the {@code coreRulesFile} is not defined, then you must
+ * fill this parameter.
+ *
+ * @parameter
+ * @since 2.0
+ */
+ protected String[] userRulesFiles;
+
+ /**
+ * Defines namespaces mapping if needed.
+ * <p/>
+ * Example :
+ * <pre>
+ * <namespaces>
+ * <s>http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd</s>
+ * </namespaces>
+ * </pre>
+ *
+ * @parameter
+ * @since 2.0
+ */
+ protected Map<String, String> namespaces;
+
+ protected abstract String getCoreRuleFile();
+
+ protected abstract XmlFileParser newXmlFileParser(XPath xpath,
+ DocumentBuilder builder);
+
+ /**
+ * Obtain the list of files which define rules to apply.
+ *
+ * @return the list of path to rule files to used.
+ */
+ protected List<String> getRulefiles() {
+ List<String> result = new ArrayList<String>();
+
+ // load optional core rule file
+ String s = getCoreRuleFile();
+ if (!StringUtils.isEmpty(s)) {
+ result.add(s);
+ }
+
+ // load user rile files
+ String[] userFiles = getUserRuleFiles();
+ if (userFiles != null) {
+ for (String f : userFiles) {
+ if (!StringUtils.isEmpty(f)) {
+ result.add(f);
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+ factory = XPathFactory.newInstance();
+
+ List<String> files = getRulefiles();
+
+ if (files.isEmpty()) {
+
+ // no rules file defined
+ throw new MojoFailureException("No rules files defined, fill the coreRulesFile or userRulesFiles parameters");
+ }
+
+ rules = loadRules(files);
+
+ documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ documentBuilderFactory.setValidating(false);
+ documentBuilderFactory.setCoalescing(false);
+ documentBuilderFactory.setIgnoringComments(true);
+ }
+
+ public final String[] getUserRuleFiles() {
+ return userRulesFiles;
+ }
+
+ @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);
+ }
+
+ protected String loadRules(List<String> files) {
+
+ List<String> rules = new ArrayList<String>();
+
+ boolean verbose = !isSilent() && isVerbose();
+
+ for (String file : files) {
+
+ getLog().info("Load rules file " + file);
+
+ try {
+ String fileRules = loadRulesFile(file);
+ rules.add(fileRules);
+
+ if (verbose) {
+ getLog().info("Rules for file [" + file + "] : " + fileRules);
+ }
+
+ } catch (IOException e) {
+ throw new ParserException(e);
+ }
+ }
+
+ String result = StringUtils.join(rules, " | ");
+ if (verbose) {
+ getLog().info("Loaded rules : " + result);
+ }
+ return result;
+ }
+
+ protected 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 et de 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;
+
+ private final Map<String, String> namespaces;
+
+ private final Map<String, String> namespaces2;
+
+ /**
+ * 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, Map<String, String> namespaces) {
+ super(log, encoding, oldParser, showTouchedFiles);
+ this.xpath = xpath;
+ this.rules = rules;
+ this.builder = builder;
+
+ if (namespaces != null && !namespaces.isEmpty()) {
+ this.namespaces = namespaces;
+ namespaces2 = new TreeMap<String, String>();
+ for (Map.Entry<String, String> e : namespaces.entrySet()) {
+ namespaces2.put(e.getValue(), e.getKey());
+ }
+ NamespaceContext ctx = new NamespaceContext() {
+ public String getNamespaceURI(String prefix) {
+ return XmlFileParser.this.namespaces.get(prefix);
+// return getNamespaceForPrefix(prefix, doc);
+ }
+
+ @Override
+ public String getPrefix(String namespaceURI) {
+ return namespaces2.get(namespaceURI);
+ }
+
+ @Override
+ public Iterator<?> getPrefixes(String namespaceURI) {
+ return null;
+ }
+ };
+ xpath.setNamespaceContext(ctx);
+ } else {
+ namespaces2 = null;
+ this.namespaces = null;
+ }
+ }
+
+ @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);
+ getLog().info("Detected nodes [" + file + "] : " + list.getLength());
+ 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);
+ }
+ }
+ }
+}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java 2010-11-11 10:52:10 UTC (rev 1794)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java 2010-11-11 10:52:30 UTC (rev 1795)
@@ -37,7 +37,9 @@
* @author tchemit <chemit(a)codelutin.com>
* @goal parserJavaActionConfig
* @phase generate-resources
+ * @deprecated since 2.0, will not be replaced (was used by {@code jaxx-swing-action} project which is dead...)
*/
+@Deprecated
public class ParserJavaActionConfigMojo extends ParserJavaMojo {
protected static final Pattern MATCH_PATTERN = Pattern.compile("(name|shortDescription|longDescription|name2|shortDescription2|longDescription2)\\s*=\\s*\"([\\w|\\.]+)\"(|\\s*|\\s*,\\s*$)");
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java 2010-11-11 10:52:10 UTC (rev 1794)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java 2010-11-11 10:52:30 UTC (rev 1795)
@@ -31,7 +31,9 @@
* @author tchemit <chemit(a)codelutin.com>
* @goal parserJavaTabConfig
* @phase generate-resources
+ * @deprecated since 2.0, will not be replaced (was used by {@code jaxx-swing-action} project which is dead...)
*/
+@Deprecated
public class ParserJavaTabConfigMojo extends ParserJavaActionConfigMojo {
@Override
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 2010-11-11 10:52:10 UTC (rev 1794)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-11-11 10:52:30 UTC (rev 1795)
@@ -41,17 +41,16 @@
import java.net.URLConnection;
/**
- * Récupération des chaine à traduire depuis les fichiers xml de validation.
- * <p/>
- * Le goal doit etre execute avant que les resources soient copiees dans
- * target/classes pour rendre operatne le file updater (sinon lesfichiers sont
- * toujours a jour...)
+ * Find i18n keys from xworks xml validation files.
*
+ * <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 parserValidation
* @phase generate-resources
*/
-public class ParserValidationMojo extends ParserXmlMojo {
+public class ParserValidationMojo extends AbstractParserXmlMojo {
final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd");
@@ -70,11 +69,16 @@
protected File cp;
/**
- * Regles xml.
+ * Defines the core rules file used to detect i18n keys in xml validation
+ * files.
+ * <p/>
+ * <b>Note :</b> If you do not want to use it, set it to empty and fill the
+ * {@link #userRulesFiles} parameter.
*
- * @parameter expression="${i18n.rulesValidation}" default-value="validation.rules"
+ * @parameter expression="${i18n.coreRuleFile}" default-value="validation.rules"
+ * @since 2.0
*/
- protected String rulesValidation;
+ protected String coreRuleFile;
/**
* default src for an entry.
@@ -92,6 +96,15 @@
*/
protected boolean useLocalResolver;
+ /**
+ * Defines the file name of the getter where to put detected i18n keys while getter phase.
+ *
+ * @parameter expression="${i18n.outputGetter}" default-value="validation.getter"
+ * @since 2.0
+ */
+ protected String outputGetter;
+
+
@Override
public String[] getDefaultIncludes() {
return new String[]{defaultIncludes};
@@ -122,19 +135,14 @@
@Override
protected String getOutGetter() {
- return "validation.getter";
+ return outputGetter;
}
@Override
- protected String getFileRules() {
- return rulesValidation;
+ protected String getCoreRuleFile() {
+ return coreRuleFile;
}
- @Override
- protected String getCoreFileRules() {
- return "validation.rules";
- }
-
protected XmlFileParser newXmlFileParser(final XPath xpath,
final DocumentBuilder builder) {
@@ -147,7 +155,7 @@
showTouchedFiles,
rules,
xpath,
- builder) {
+ builder, namespaces) {
@Override
public String extract(String i18nString) {
String s = null;
Modified: 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 2010-11-11 10:52:10 UTC (rev 1794)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-11-11 10:52:30 UTC (rev 1795)
@@ -53,7 +53,9 @@
* 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 */
@@ -91,7 +93,6 @@
try {
// never forget this!
builder = documentBuilderFactory.newDocumentBuilder();
-
} catch (ParserConfigurationException ex) {
throw new IllegalStateException(
"could not load DocumentBuilder for reason " +
Added: 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 (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2010-11-11 10:52:30 UTC (rev 1795)
@@ -0,0 +1,168 @@
+/*
+ * #%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.i18n.plugin.parser.I18nSourceEntry;
+import org.nuiton.i18n.plugin.parser.SourceEntry;
+import org.nuiton.io.FileUpdater;
+import org.nuiton.io.MirroredFileUpdater;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.xpath.XPath;
+import java.io.File;
+
+/**
+ * To obtain i18n keys from xml files using the {@code userRulesFiles} (and
+ * an optional {@code coreRuleFile} if any serves your purpose).
+ * <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 tchemit <chemit(a)codelutin.com>
+ * @goal parserXml
+ * @phase generate-resources
+ * @since 2.0
+ */
+public class ParserXmlUserMojo extends AbstractParserXmlMojo {
+
+ /**
+ * Default directory where to look for files.
+ *
+ * @parameter expression="${i18n.xmlBasedir}" default-value="${basedir}/src/main/resources"
+ * @required
+ * @since 2.0
+ */
+ protected File basedir;
+
+ /**
+ * Defines files to parse.
+ *
+ * @parameter expression="${i18n.xmlIncludes}"
+ * @required
+ * @since 2.0
+ */
+ protected String includes;
+
+ /**
+ * Defines an optional files which contain xpath rules to obtain i18n
+ * keys in xml files and is defined in plugin.
+ *
+ * @parameter expression="${i18n.coreRuleFiles}"
+ * @since 2.0
+ */
+ protected String coreRuleFile;
+
+ /**
+ * Defines where included files will be copied.
+ * <p/>
+ * Knowing this permits us to parse included xml files only if they were
+ * modified from a previous build.
+ *
+ * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
+ * @since 2.0
+ */
+ protected File cp;
+
+ /**
+ * Defines the file name of the getter where to put detected i18n keys while getter phase.
+ *
+ * @parameter expression="${i18n.outputGetter}" default-value="xmlUser.getter"
+ * @since 2.0
+ */
+ protected String outputGetter;
+
+ @Override
+ public String[] getDefaultIncludes() {
+ return new String[]{includes};
+ }
+
+ @Override
+ public String[] getDefaultExcludes() {
+ return I18nSourceEntry.EMPTY_STRING_ARRAY;
+ }
+
+ @Override
+ public File getDefaultBasedir() {
+ return basedir;
+ }
+
+ @Override
+ protected String getCoreRuleFile() {
+ return coreRuleFile;
+ }
+
+ @Override
+ protected XmlFileParser newXmlFileParser(XPath xpath, DocumentBuilder builder) {
+ XmlFileParser fileParser = new XmlFileParser(getLog(),
+ getEncoding(),
+ oldParser,
+ showTouchedFiles,
+ rules,
+ xpath,
+ builder, namespaces) {
+ @Override
+ public String extract(String i18nString) {
+ String s = null;
+ if (!i18nString.trim().isEmpty()) {
+ s = i18nString.trim();
+ }
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(i18nString + " = " + s);
+ }
+ return s;
+ }
+ };
+ return fileParser;
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return outputGetter;
+ }
+
+ @Override
+ protected String getKeyModifierStart() {
+ return null;
+ }
+
+ @Override
+ protected String getKeyModifierEnd() {
+ return null;
+ }
+
+ @Override
+ public FileUpdater newFileUpdater(SourceEntry entry) {
+ return new MirroredFileUpdater("", "", entry.getBasedir(), cp) {
+
+ @Override
+ public File getMirrorFile(File f) {
+ String file =
+ f.getAbsolutePath().substring(prefixSourceDirecotory);
+ return new File(destinationDirectory + File.separator + file);
+ }
+ };
+ }
+}
\ No newline at end of file
1
0
Author: tchemit
Date: 2010-11-11 11:52:10 +0100 (Thu, 11 Nov 2010)
New Revision: 1794
Url: http://nuiton.org/repositories/revision/i18n/1794
Log:
add commons-lang dependencies
Modified:
trunk/maven-i18n-plugin/pom.xml
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-11-09 10:54:44 UTC (rev 1793)
+++ trunk/maven-i18n-plugin/pom.xml 2010-11-11 10:52:10 UTC (rev 1794)
@@ -61,7 +61,12 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
-
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
<!--dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
1
0
r1793 - in trunk/maven-i18n-plugin/src/it: . parsers/newProject parsers/withNewKeys parsers/withNewKeys/src/main/resources/i18n
by tchemit@users.nuiton.org 09 Nov '10
by tchemit@users.nuiton.org 09 Nov '10
09 Nov '10
Author: tchemit
Date: 2010-11-09 11:54:44 +0100 (Tue, 09 Nov 2010)
New Revision: 1793
Url: http://nuiton.org/repositories/revision/i18n/1793
Log:
fix it + reformat it poms
Added:
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties
Removed:
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties
Modified:
trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
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/it/settings.xml
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2010-11-09 08:39:04 UTC (rev 1792)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2010-11-09 10:54:44 UTC (rev 1793)
@@ -28,77 +28,77 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>i18n</artifactId>
- <version>@pom.version@</version>
- </parent>
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>i18n</artifactId>
+ <version>@pom.version@</version>
+ </parent>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>parsers-newProject</artifactId>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>parsers-newProject</artifactId>
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
- <name>I18n Test :: parsers-new</name>
+ <name>I18n Test :: parsers-new</name>
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
- <packaging>jar</packaging>
+ <packaging>jar</packaging>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>nuiton-i18n</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- </dependencies>
-
- <build>
+ </dependencies>
- <plugins>
+ <build>
- <plugin>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>@pom.version@</version>
- <configuration>
- <verbose>true</verbose>
- </configuration>
- <executions>
- <execution>
- <id>first</id>
- <goals>
- <goal>parserJava</goal>
- <goal>parserValidation</goal>
- </goals>
- </execution>
- <execution>
- <!-- this execution is to test thread with no files -->
- <id>second</id>
- <goals>
- <goal>parserJava</goal>
- <goal>parserValidation</goal>
- </goals>
- <phase>compile</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <id>first</id>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ </goals>
+ </execution>
+ <execution>
+ <!-- this execution is to test thread with no files -->
+ <id>second</id>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2010-11-09 08:39:04 UTC (rev 1792)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2010-11-09 10:54:44 UTC (rev 1793)
@@ -28,78 +28,78 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>i18n</artifactId>
- <version>@pom.version@</version>
- </parent>
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>i18n</artifactId>
+ <version>@pom.version@</version>
+ </parent>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>parsers-withNewKeys</artifactId>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>parsers-withNewKeys</artifactId>
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
- <name>I18n Test :: parsers-new</name>
+ <name>I18n Test :: parsers-new</name>
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
- <packaging>jar</packaging>
+ <packaging>jar</packaging>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>nuiton-i18n</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- </dependencies>
+ </dependencies>
- <build>
+ <build>
- <plugins>
+ <plugins>
- <plugin>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>@pom.version@</version>
- <configuration>
- <keepGetters>true</keepGetters>
- <verbose>true</verbose>
- </configuration>
- <executions>
- <execution>
- <id>first</id>
- <goals>
- <goal>parserJava</goal>
- <goal>parserValidation</goal>
- <goal>gen</goal>
- </goals>
- </execution>
- <execution>
- <!-- this execution is to test thread with no files -->
- <id>second</id>
- <goals>
- <goal>parserJava</goal>
- <goal>parserValidation</goal>
- <goal>gen</goal>
- </goals>
- <phase>compile</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <keepGetters>true</keepGetters>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <id>first</id>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ <execution>
+ <!-- this execution is to test thread with no files -->
+ <id>second</id>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ <goal>gen</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Deleted: 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 2010-11-09 08:39:04 UTC (rev 1792)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties 2010-11-09 10:54:44 UTC (rev 1793)
@@ -1,26 +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%
-###
-javaGetter.old.key1=hum1
-javaGetter.old.key2=hum2
Copied: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties (from rev 1789, 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 (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties 2010-11-09 10:54:44 UTC (rev 1793)
@@ -0,0 +1,26 @@
+###
+# #%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%
+###
+javaGetter.old.key1=hum1
+javaGetter.old.key2=hum2
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties
___________________________________________________________________
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 2010-11-09 08:39:04 UTC (rev 1792)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2010-11-09 10:54:44 UTC (rev 1793)
@@ -39,7 +39,7 @@
assert content.contains( 'validationGetter.key1=' );
assert content.contains( 'validationGetter.key2=' );
-file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties');
+file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys_fr_FR.properties');
assert file.exists();
content = file.text;
Modified: trunk/maven-i18n-plugin/src/it/settings.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/settings.xml 2010-11-09 08:39:04 UTC (rev 1792)
+++ trunk/maven-i18n-plugin/src/it/settings.xml 2010-11-09 10:54:44 UTC (rev 1793)
@@ -24,58 +24,38 @@
#L%
-->
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
<settings>
- <profiles>
- <profile>
- <id>it-repo</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <repositories>
- <repository>
- <id>local.central</id>
- <url>file:///@localRepository@</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>local.central</id>
- <url>file:///@localRepository@</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
- </profile>
- </profiles>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
</settings>
1
0
r1792 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle
by athimel@users.nuiton.org 09 Nov '10
by athimel@users.nuiton.org 09 Nov '10
09 Nov '10
Author: athimel
Date: 2010-11-09 09:39:04 +0100 (Tue, 09 Nov 2010)
New Revision: 1792
Url: http://nuiton.org/repositories/revision/i18n/1792
Log:
Orthograph fixes
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
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 2010-11-08 20:09:24 UTC (rev 1791)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-11-09 08:39:04 UTC (rev 1792)
@@ -112,7 +112,7 @@
/**
* Un drapeau pour utiliser le répertoire parent du {@link #bundleOutputDir}
- * comme répertoire de ressources à ajouter ua build.
+ * comme répertoire de ressources à ajouter au build.
* <p/>
* Si ce drapeau n'est pas activé, alors on utilise directement le répertoire donné.
*
@@ -235,7 +235,7 @@
if (generateDefinitionFile) {
// ecriture du ficher des definitions i18n (permet de faire une
- // recherche extact sur un fichier puis d'en deduire les bundles a
+ // recherche exacte sur un fichier puis d'en deduire les bundles a
// charger
String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
bundleOutputName);
1
0
r1791 - in trunk: . ant-i18n-task maven-i18n-plugin maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle nuiton-i18n
by tchemit@users.nuiton.org 08 Nov '10
by tchemit@users.nuiton.org 08 Nov '10
08 Nov '10
Author: tchemit
Date: 2010-11-08 21:09:24 +0100 (Mon, 08 Nov 2010)
New Revision: 1791
Url: http://nuiton.org/repositories/revision/i18n/1791
Log:
pass to version 2.0-SNAPSHOT
Evolution #1020: Add addBundleOuputDirParent parameter in BundleMojo
Evolution #1021: Add generateDefinitionFile parameter in BundleMojo
Modified:
trunk/ant-i18n-task/pom.xml
trunk/maven-i18n-plugin/pom.xml
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
trunk/nuiton-i18n/pom.xml
trunk/pom.xml
Modified: trunk/ant-i18n-task/pom.xml
===================================================================
--- trunk/ant-i18n-task/pom.xml 2010-11-08 15:09:17 UTC (rev 1790)
+++ trunk/ant-i18n-task/pom.xml 2010-11-08 20:09:24 UTC (rev 1791)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-11-08 15:09:17 UTC (rev 1790)
+++ trunk/maven-i18n-plugin/pom.xml 2010-11-08 20:09:24 UTC (rev 1791)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
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 2010-11-08 15:09:17 UTC (rev 1790)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-11-08 20:09:24 UTC (rev 1791)
@@ -97,7 +97,6 @@
* vides.
*
* @parameter expression="${i18n.checkBundle}" default-value="true"
- * @required
* @since 1.0.0
*/
protected boolean checkBundle;
@@ -107,11 +106,33 @@
* #checkBundle} activé).
*
* @parameter expression="${i18n.showEmpty}" default-value="false"
- * @required
* @since 1.0.0
*/
protected boolean showEmpty;
+ /**
+ * Un drapeau pour utiliser le répertoire parent du {@link #bundleOutputDir}
+ * comme répertoire de ressources à ajouter ua build.
+ * <p/>
+ * Si ce drapeau n'est pas activé, alors on utilise directement le répertoire donné.
+ *
+ * @parameter expression="${i18n.addBundleOuputDirParent}" default-value="true"
+ * @since 2.0
+ */
+ protected boolean addBundleOuputDirParent;
+
+ /**
+ * Un drapeau pour générer le fichier de définition i18n.
+ * <p/>
+ * Ce fichier permet d'avoir les locales utilisables par I18n ainsi que les
+ * chemins (dans le classpath) des resources i18n utilisées pour construire
+ * le bundle final.
+ *
+ * @parameter expression="${i18n.generateDefinitionFile}" default-value="true"
+ * @since 2.0
+ */
+ protected boolean generateDefinitionFile;
+
@Override
public void init() throws Exception {
super.init();
@@ -121,7 +142,12 @@
// ajout de repertoire de generation (le parent en fait)
// dans les resources du projet
- addResourceDir(bundleOutputDir.getParentFile(), "**/*.properties");
+ File ressourceDir = bundleOutputDir;
+
+ if (addBundleOuputDirParent) {
+ ressourceDir = ressourceDir.getParentFile();
+ }
+ addResourceDir(ressourceDir, "**/*.properties");
}
@Override
@@ -206,30 +232,33 @@
}
}
- // ecriture du ficher des definitions i18n (permet de faire une
- // recherche extact sur un fichier puis d'en deduire les bundles a
- // charger
- String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
- bundleOutputName);
- File defOut = new File(bundleOutputDir, f);
- if (!silent) {
- getLog().info("prepare i18n definition " +
- defOut.getAbsolutePath());
+ if (generateDefinitionFile) {
+
+ // ecriture du ficher des definitions i18n (permet de faire une
+ // recherche extact sur un fichier puis d'en deduire les bundles a
+ // charger
+ String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
+ bundleOutputName);
+ File defOut = new File(bundleOutputDir, f);
+ if (!silent) {
+ getLog().info("prepare i18n definition " +
+ defOut.getAbsolutePath());
+ }
+ SortedProperties p = new SortedProperties(encoding, false);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
+ for (Entry<Locale, String> e : bundleDico.entrySet()) {
+ p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
+ e.getKey().toString(), e.getValue());
+ }
+ FileOutputStream out = new FileOutputStream(defOut);
+ try {
+ p.store(out, null);
+ } finally {
+ out.close();
+ }
+
}
- SortedProperties p = new SortedProperties(encoding, false);
- p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
- p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
- for (Entry<Locale, String> e : bundleDico.entrySet()) {
- p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
- e.getKey().toString(), e.getValue());
- }
- FileOutputStream out = new FileOutputStream(defOut);
- try {
- p.store(out, null);
- } finally {
- out.close();
- }
-
if (!silent && verbose) {
getLog().info("done in " +
PluginHelper.convertTime(t00, System.nanoTime()));
Modified: trunk/nuiton-i18n/pom.xml
===================================================================
--- trunk/nuiton-i18n/pom.xml 2010-11-08 15:09:17 UTC (rev 1790)
+++ trunk/nuiton-i18n/pom.xml 2010-11-08 20:09:24 UTC (rev 1791)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-11-08 15:09:17 UTC (rev 1790)
+++ trunk/pom.xml 2010-11-08 20:09:24 UTC (rev 1791)
@@ -39,7 +39,7 @@
</parent>
<artifactId>i18n</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<modules>
<module>nuiton-i18n</module>
1
0