branch feature/29 created (now 934348b)
This is an automated email from the git hooks/post-receive script. New change to branch feature/29 in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git at 934348b Ajouter un bundle i18n (Closes #29) This branch includes the following new commits: new 934348b Ajouter un bundle i18n (Closes #29) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 934348b7a2a0bdd2c1bf857bf853da007d4a2b2c Author: Tony CHEMIT <dev@tchemit.fr> Date: Sun Jan 1 15:57:38 2017 +0100 Ajouter un bundle i18n (Closes #29) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/29 in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 934348b7a2a0bdd2c1bf857bf853da007d4a2b2c Author: Tony CHEMIT <dev@tchemit.fr> Date: Sun Jan 1 15:57:38 2017 +0100 Ajouter un bundle i18n (Closes #29) --- application-swing/pom.xml | 16 +++++++ application-swing/src/main/assembly/i18n.xml | 49 ++++++++++++++++++++ .../application/swing/ObserveResourceManager.java | 54 ++++++++-------------- .../observe/application/swing/ObserveRunner.java | 8 ++-- .../ui/actions/menu/help/ShowAboutAction.java | 5 +- .../src/main/resources/ftl/translate_en.ftl | 8 ++-- .../src/main/resources/ftl/translate_es.ftl | 8 ++-- .../src/main/resources/ftl/translate_fr.ftl | 8 ++-- 8 files changed, 102 insertions(+), 54 deletions(-) diff --git a/application-swing/pom.xml b/application-swing/pom.xml index 0d1119c..20096e6 100644 --- a/application-swing/pom.xml +++ b/application-swing/pom.xml @@ -560,6 +560,22 @@ <outputDirectory>${project.build.outputDirectory}</outputDirectory> </configuration> </execution> + <execution> + <id>create-i18n-assembly</id> + <phase>process-resources</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly/i18n.xml</descriptor> + </descriptors> + <attach>false</attach> + <finalName>observe-i18n</finalName> + <appendAssemblyId>false</appendAssemblyId> + <outputDirectory>${project.build.outputDirectory}</outputDirectory> + </configuration> + </execution> </executions> </plugin> diff --git a/application-swing/src/main/assembly/i18n.xml b/application-swing/src/main/assembly/i18n.xml new file mode 100644 index 0000000..0bed820 --- /dev/null +++ b/application-swing/src/main/assembly/i18n.xml @@ -0,0 +1,49 @@ +<!-- + #%L + ObServe :: Application Swing + %% + Copyright (C) 2008 - 2016 IRD, Code Lutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + <id>i18n</id> + <formats> + <format>zip</format> + </formats> + + <fileSets> + + <fileSet> + <directory>src/main/resources/ftl</directory> + <outputDirectory>templates</outputDirectory> + <fileMode>0755</fileMode> + <includes> + <include>*.ftl</include> + </includes> + </fileSet> + + <fileSet> + <directory>target/generated-sources/resources/META-INF</directory> + <outputDirectory/> + <includes> + <include>observe-i18n.csv</include> + </includes> + </fileSet> + + </fileSets> +</assembly> diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveResourceManager.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveResourceManager.java index 9ea07c6..c918db4 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveResourceManager.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveResourceManager.java @@ -36,7 +36,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.TreeMap; @@ -60,6 +62,8 @@ public class ObserveResourceManager { public static final String OBSERVE_MAP_ARCHIVE = "/map.zip"; + public static final String OBSERVE_I18N_ARCHIVE = "/observe-i18n.zip"; + public static final String OBSERVE_LOG_CONFIGURATION_FILE_PROPERTIES = "/observe-log4j.properties"; /** Logger */ @@ -157,9 +161,7 @@ public class ObserveResourceManager { return result; } - public void copyResource(Resource resource, - File file, - String message) throws IOException { + public void copyResource(Resource resource, File file, String message) throws IOException { try (FileOutputStream out = new FileOutputStream(file)) { // on fait une copie brute en ne passant pas par un Properties @@ -168,11 +170,8 @@ public class ObserveResourceManager { // chargement des ressources // sauvegarde dans le fichier cible - try (InputStreamReader in = new InputStreamReader( - new BufferedInputStream( - openInternalStream(resource.getUrl())), - "utf-8")) { - IOUtils.copy(in, out, "utf-8"); + try (InputStreamReader in = new InputStreamReader(new BufferedInputStream(openInternalStream(resource.getUrl())), StandardCharsets.UTF_8)) { + IOUtils.copy(in, out, StandardCharsets.UTF_8); } if (log.isInfoEnabled()) { @@ -181,36 +180,19 @@ public class ObserveResourceManager { } } - public void copyResource(URL resource, - File file, - String message) throws IOException { + public void copyResource(URL resource, File file, String message) throws IOException { - FileOutputStream out = new FileOutputStream(file); - try { - // on fait une copie brute en ne passant pas par un Properties - // qui perd le formatage et les commentaires + try (FileOutputStream out = new FileOutputStream(file)) { - // chargement des ressources - InputStreamReader in = - new InputStreamReader( - new BufferedInputStream( - openInternalStream(resource)), - "utf-8"); + try (InputStream in = openInternalStream(resource)) { - // sauvegarde dans le fichier cible - try { - IOUtils.copy(in, out, "utf-8"); - in.close(); - } finally { - IOUtils.closeQuietly(in); + // sauvegarde dans le fichier cible + IOUtils.copy(in, out); } if (log.isInfoEnabled()) { log.info(message); } - out.close(); - } finally { - IOUtils.closeQuietly(out); } } @@ -271,8 +253,11 @@ public class ObserveResourceManager { URL resource = ObserveResourceManager.class.getResource(location); try { // test que la resource existe bien dans le class-path - InputStream in = openInternalStream(resource); - in.close(); + try (InputStream in = openInternalStream(resource)) { + if (log.isDebugEnabled()) { + log.debug("opening: " + in); + } + } return resource; } catch (Exception e) { throw new IllegalStateException("Could not treat internal resource " + location); @@ -282,10 +267,7 @@ public class ObserveResourceManager { protected static InputStream openInternalStream(URL resource) { try { InputStream in = resource.openStream(); - if (in == null) { - throw new IllegalStateException("Could not find internal resource " + resource); - } - + Objects.requireNonNull(in, "Could not find internal resource " + resource); return in; } catch (Exception e) { throw new IllegalStateException("Could not treat internal resource " + resource); diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java index f7d4b85..e03a6f2 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java @@ -30,7 +30,6 @@ import fr.ird.observe.application.swing.ui.actions.menu.storage.StartServerModeA import fr.ird.observe.application.swing.ui.util.FloatConverter; import fr.ird.observe.application.swing.validation.ObserveSwingValidator; import fr.ird.observe.common.ObserveUtil; -import org.nuiton.jaxx.runtime.swing.application.ApplicationRunner; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; import org.apache.commons.beanutils.converters.DateConverter; @@ -46,6 +45,7 @@ import org.nuiton.converter.ConverterUtil; import org.nuiton.i18n.I18n; import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.i18n.init.UserI18nInitializer; +import org.nuiton.jaxx.runtime.swing.application.ApplicationRunner; import org.nuiton.util.StringUtil; import javax.script.ScriptEngine; @@ -512,10 +512,10 @@ public abstract class ObserveRunner extends ApplicationRunner { protected void createUserI18nLayout(File directory) throws Exception { super.createUserI18nLayout(directory); - // add also the i18n csv bundle + // add also a archive with all i18n stuff (says i18n bundle + templates) - URL resource = ObserveResourceManager.getResource("/META-INF/observe-i18n.csv"); - resourceManager.copyResource(resource, new File(directory, "observe-i18n.csv"), "Copy i18n csv bundle"); + URL resource = ObserveResourceManager.getResource(ObserveResourceManager.OBSERVE_I18N_ARCHIVE); + resourceManager.copyResource(resource, new File(directory, ObserveResourceManager.OBSERVE_I18N_ARCHIVE.substring(1)), "Copy i18n archive"); } }; diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/actions/menu/help/ShowAboutAction.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/actions/menu/help/ShowAboutAction.java index bddc050..82bf83a 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/actions/menu/help/ShowAboutAction.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/actions/menu/help/ShowAboutAction.java @@ -22,6 +22,7 @@ package fr.ird.observe.application.swing.ui.actions.menu.help; * #L% */ +import fr.ird.observe.application.swing.ObserveResourceManager; import fr.ird.observe.application.swing.ObserveRunner; import fr.ird.observe.application.swing.ObserveSwingApplicationContext; import fr.ird.observe.application.swing.ObserveTextGenerator; @@ -63,12 +64,12 @@ public class ShowAboutAction extends AbstractUIAction { ObserveMainUI ui = getMainUI(); - File csvFile = new File(ui.getConfig().getI18nDirectory(), "observe-i18n.csv"); + File i18nFile = new File(ui.getConfig().getI18nDirectory(), ObserveResourceManager.OBSERVE_I18N_ARCHIVE.substring(1)); String name = ObserveRunner.getRunner().getRunnerName(); ObserveTextGenerator textGenerator = ObserveSwingApplicationContext.get().getTextGenerator(); String aboutContent = textGenerator.getAbout(ui.getConfig()); - String translateContent = textGenerator.getTranslate(csvFile); + String translateContent = textGenerator.getTranslate(i18nFile); AboutUI about = AboutUIBuilder.builder(ui) .setIconPath("/icons/logo.png") diff --git a/application-swing/src/main/resources/ftl/translate_en.ftl b/application-swing/src/main/resources/ftl/translate_en.ftl index 89821c7..46e678a 100644 --- a/application-swing/src/main/resources/ftl/translate_en.ftl +++ b/application-swing/src/main/resources/ftl/translate_en.ftl @@ -25,8 +25,8 @@ <hr/> <br/> <ul> - <li>Récupérer le fichier <a href="${file}">observe-i18n.csv</a> dans le répertoire <strong>i18n</strong></li> - <li>ouvrez le avec un tableur avec les options suivantes : + <li>Récupérer le fichier <a href="${file}">observe-i18n.zip</a>. Il s'agit d'une archive comprenant les templates utilisées dans l'application ainsi que le fichier <i>csv</i> qui contient toutes les traductions de l'application. + <li>Ouvrez le fichier <i>observe-i18n.csv</i> dans un tableur avec les options suivantes : <dl> <dt>caractère séparateur</dt> <dd><strong><i>|</i></strong></dd> @@ -37,11 +37,11 @@ </dl> </li> <li>Traduisez, Améliorer, ...</li> - <li>Enfin renvoyez-le nous</li> + <li>Enfin renvoyez-le nous ce que vous avez modifié.</li> </ul> <br/> <p> - Vos modifications seront prises en compte avant la prochaine version. + Vos modifications seront prises en compte dans une version utlérieure. </p> </body> </html> diff --git a/application-swing/src/main/resources/ftl/translate_es.ftl b/application-swing/src/main/resources/ftl/translate_es.ftl index 89821c7..46e678a 100644 --- a/application-swing/src/main/resources/ftl/translate_es.ftl +++ b/application-swing/src/main/resources/ftl/translate_es.ftl @@ -25,8 +25,8 @@ <hr/> <br/> <ul> - <li>Récupérer le fichier <a href="${file}">observe-i18n.csv</a> dans le répertoire <strong>i18n</strong></li> - <li>ouvrez le avec un tableur avec les options suivantes : + <li>Récupérer le fichier <a href="${file}">observe-i18n.zip</a>. Il s'agit d'une archive comprenant les templates utilisées dans l'application ainsi que le fichier <i>csv</i> qui contient toutes les traductions de l'application. + <li>Ouvrez le fichier <i>observe-i18n.csv</i> dans un tableur avec les options suivantes : <dl> <dt>caractère séparateur</dt> <dd><strong><i>|</i></strong></dd> @@ -37,11 +37,11 @@ </dl> </li> <li>Traduisez, Améliorer, ...</li> - <li>Enfin renvoyez-le nous</li> + <li>Enfin renvoyez-le nous ce que vous avez modifié.</li> </ul> <br/> <p> - Vos modifications seront prises en compte avant la prochaine version. + Vos modifications seront prises en compte dans une version utlérieure. </p> </body> </html> diff --git a/application-swing/src/main/resources/ftl/translate_fr.ftl b/application-swing/src/main/resources/ftl/translate_fr.ftl index 89821c7..46e678a 100644 --- a/application-swing/src/main/resources/ftl/translate_fr.ftl +++ b/application-swing/src/main/resources/ftl/translate_fr.ftl @@ -25,8 +25,8 @@ <hr/> <br/> <ul> - <li>Récupérer le fichier <a href="${file}">observe-i18n.csv</a> dans le répertoire <strong>i18n</strong></li> - <li>ouvrez le avec un tableur avec les options suivantes : + <li>Récupérer le fichier <a href="${file}">observe-i18n.zip</a>. Il s'agit d'une archive comprenant les templates utilisées dans l'application ainsi que le fichier <i>csv</i> qui contient toutes les traductions de l'application. + <li>Ouvrez le fichier <i>observe-i18n.csv</i> dans un tableur avec les options suivantes : <dl> <dt>caractère séparateur</dt> <dd><strong><i>|</i></strong></dd> @@ -37,11 +37,11 @@ </dl> </li> <li>Traduisez, Améliorer, ...</li> - <li>Enfin renvoyez-le nous</li> + <li>Enfin renvoyez-le nous ce que vous avez modifié.</li> </ul> <br/> <p> - Vos modifications seront prises en compte avant la prochaine version. + Vos modifications seront prises en compte dans une version utlérieure. </p> </body> </html> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm