ItEr22S04ArquitecturaServidorItEr21S04: [FixBug] Added gettext commons library to ganttzk-demo
This commit is contained in:
parent
e1f863e282
commit
b3b1918359
3 changed files with 80 additions and 0 deletions
|
|
@ -13,9 +13,33 @@
|
|||
|
||||
<build>
|
||||
<finalName>ganttzk-demo-webapp</finalName>
|
||||
|
||||
<!--
|
||||
Gettext Commons plugin
|
||||
goals:
|
||||
merge: parses source code and generates keys.pot
|
||||
dist: generates binary Resoruce Bundle (Messages_XX.class)
|
||||
-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.xnap.commons</groupId>
|
||||
<artifactId>maven-gettext-plugin</artifactId>
|
||||
<configuration>
|
||||
<targetBundle>i18n.Messages</targetBundle>
|
||||
<poDirectory>${project.build.sourceDirectory}/../resources/i18n</poDirectory>
|
||||
<keywords>-k_</keywords>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- Gettext commons -->
|
||||
<dependency>
|
||||
<groupId>org.xnap.commons</groupId>
|
||||
<artifactId>gettext-commons</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
|
@ -69,6 +93,16 @@
|
|||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
Apache Commons IO (required by Commons Fileupload but
|
||||
declared as optional it commons-fileupload.pom)
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package org.navalplanner.web;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.xnap.commons.i18n.I18n;
|
||||
import org.xnap.commons.i18n.I18nFactory;
|
||||
import org.zkoss.util.Locales;
|
||||
|
||||
|
||||
public class I18nHelper {
|
||||
|
||||
private static HashMap<Locale, I18n> localesCache = new HashMap<Locale, I18n>();
|
||||
|
||||
public static I18n getI18n() {
|
||||
if (localesCache.keySet().contains(Locales.getCurrent())) {
|
||||
return localesCache.get(Locales.getCurrent());
|
||||
}
|
||||
|
||||
I18n i18n = I18nFactory.getI18n(I18nHelper.class, Locales
|
||||
.getCurrent(),
|
||||
org.xnap.commons.i18n.I18nFactory.FALLBACK);
|
||||
localesCache.put(Locales.getCurrent(), i18n);
|
||||
|
||||
return i18n;
|
||||
}
|
||||
|
||||
public static String _(String str) {
|
||||
return getI18n().tr(str);
|
||||
}
|
||||
}
|
||||
15
ganttzk-demo-webapp/src/main/webapp/WEB-INF/tld/i18n.tld
Normal file
15
ganttzk-demo-webapp/src/main/webapp/WEB-INF/tld/i18n.tld
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<taglib>
|
||||
<uri>http://org.navalplanner.web/i18n</uri>
|
||||
<description>
|
||||
</description>
|
||||
<function>
|
||||
<name>_</name>
|
||||
<function-class>org.navalplanner.web.I18nHelper</function-class>
|
||||
<function-signature>
|
||||
java.lang.String _(java.lang.String name)
|
||||
</function-signature>
|
||||
<description>
|
||||
</description>
|
||||
</function>
|
||||
</taglib>
|
||||
Loading…
Add table
Reference in a new issue