This is an automated email from the git hooks/post-receive script. New commit to branch feature/integrity in repository i18n. See https://gitlab.nuiton.org/nuiton/i18n.git commit 9821f619667b6bb470d9419831658e520d06c4bd Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 8 18:04:04 2016 +0200 POC --- .../resources/i18n/evo-integrity_en_GB.properties | 1 + .../resources/i18n/evo-integrity_fr_FR.properties | 1 + i18n-maven-plugin/src/it/evo-integrity/src/pom.xml | 94 ++++++++++++++++++++++ .../i18n/plugin/CheckBundlesIntegrityMojo.java | 90 +++++++++++++++++++++ 4 files changed, 186 insertions(+) diff --git a/i18n-maven-plugin/src/it/evo-integrity/src/main/resources/i18n/evo-integrity_en_GB.properties b/i18n-maven-plugin/src/it/evo-integrity/src/main/resources/i18n/evo-integrity_en_GB.properties new file mode 100644 index 0000000..9f75c23 --- /dev/null +++ b/i18n-maven-plugin/src/it/evo-integrity/src/main/resources/i18n/evo-integrity_en_GB.properties @@ -0,0 +1 @@ +app.property=My application {0} \ No newline at end of file diff --git a/i18n-maven-plugin/src/it/evo-integrity/src/main/resources/i18n/evo-integrity_fr_FR.properties b/i18n-maven-plugin/src/it/evo-integrity/src/main/resources/i18n/evo-integrity_fr_FR.properties new file mode 100644 index 0000000..6b86078 --- /dev/null +++ b/i18n-maven-plugin/src/it/evo-integrity/src/main/resources/i18n/evo-integrity_fr_FR.properties @@ -0,0 +1 @@ +app.property=Mon application {0} \ No newline at end of file diff --git a/i18n-maven-plugin/src/it/evo-integrity/src/pom.xml b/i18n-maven-plugin/src/it/evo-integrity/src/pom.xml new file mode 100644 index 0000000..44c3045 --- /dev/null +++ b/i18n-maven-plugin/src/it/evo-integrity/src/pom.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%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% + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + 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> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>i18n</artifactId> + <version>@pom.version@</version> + </parent> + + <groupId>org.nuiton.i18n</groupId> + <artifactId>evo-integrity</artifactId> + + <name>I18n Test :: check bundle integrity plugin</name> + + <dependencies> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nuiton-i18n</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + + <plugins> + + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>i18n-maven-plugin</artifactId> + <version>@pom.version@</version> + <configuration> + <verbose>true</verbose> + </configuration> + <executions> + <execution> + <id>check-integrity</id> + <goals> + <goal>check-integrity</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> + + diff --git a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/CheckBundlesIntegrityMojo.java b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/CheckBundlesIntegrityMojo.java new file mode 100644 index 0000000..8abcb6c --- /dev/null +++ b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/CheckBundlesIntegrityMojo.java @@ -0,0 +1,90 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * 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; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.io.SortedProperties; + +import java.io.File; +import java.util.Arrays; +import java.util.Locale; + +/** + * Check bundles integrity. That all keys have a value in all bundles. + * + * @since 3.5 + */ +@Mojo(name = "check-bundles-integrity", defaultPhase = LifecyclePhase.PREPARE_PACKAGE) +public class CheckBundlesIntegrityMojo extends AbstractI18nGenerateMojo { + + /** Directory where to find project i18n files. */ + @Parameter(property = "i18n.src", defaultValue = "${basedir}/src/main/resources/i18n", required = true) + protected File src; + + /** + * A flag to check that bundles are complete (no missing i18n translations). + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.checkBundle", defaultValue = "true", required = true) + protected boolean checkBundle; + + + + + /** + * A flag to show missing i18n translation. + * + * <b>Note :</b> Need the {@link #checkBundle} to be activated). + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.showEmpty", defaultValue = "false", required = true) + protected boolean showEmpty; + + + @Override + protected void doAction() throws Exception { + if (!silent) { + getLog().info("config - src basedir : " + src.getAbsolutePath()); + getLog().info("config - locales : " + Arrays.toString(locales)); + } + for (Locale locale : locales) { + + File bundleSrc = I18nUtil.getI18nFile(src, artifactId, locale, false); + + SortedProperties propertiesSrc = new SortedProperties(encoding); + + if (bundleSrc.exists()) { + propertiesSrc.load(bundleSrc); + } + + checkBundle(locale, propertiesSrc, showEmpty, null); + } + } +} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.