New issue 49 by pvdissel: maven-gettext-plugin missing sourceExtensions
option
http://code.google.com/p/gettext-commons/issues/detail?id=49
I needed to make the gettext plugin run on other extension than .java, so I
added the sourceExtensions option to the GettextMojo.
Attached is a patch created on svn revision 214.
The sourceExtensions can be used as following in the pom configuration:
<build>
<plugins>
<plugin>
<groupId>org.xnap.commons</groupId>
<artifactId>maven-gettext-plugin</artifactId>
<version>${gettext.version}</version>
<configuration>
<targetBundle>com.upc.saleslayer.frontend.Messages</targetBundle>
<sourceDirectory>${project.build.sourceDirectory}/../</sourceDirectory>
<sourceLocale>${gettext.sourceLocale}</sourceLocale>
<sourceExtensions>
<param>java</param>
<param>ftl</param>
</sourceExtensions>
<keysFile>${gettext.keysFile}</keysFile>
<keywords>${gettext.keywords}</keywords>
<poDirectory>${gettext.poDirectory}</poDirectory>
</configuration>
</plugin>
When the sourceExtensions option is not configured in the POM, the java
extension is added by default. When "java" is not set as extension, it will
also be added to the sourceExtensions list by default. So "java" files are
ALWAYS included in the gettext source list.
Hopefully this can be included in the next version of the
maven-gettext-plugin.
Thanks
Attachments:
pom.xml-r214.patch 1.7 KB
GettextMojo.java-r214.patch 2.6 KB
BTW. the attached pom.xml patch changes the version of the plugin to
1.2.1-tricode. This is purely so I can use the changed plugin directly in
my project without conflicting with your version numbering. When you apply
this patch, please update the version to 1.2.2 or something :) I'll then
step back to the original versioning in my dependencies list.
Thank you for your contribution!
What other types of files are you trying to internationalize?
The maven gettext plugin handles only Java files so far and more changes
would be needed to support other languages which might also be also outside
the scope of this project.
When xgettext is invoked from the maven plugin the parameter
--language=Java is passed to it which tells it to expect java files as
input. Also the output of the maven plugin are either properties files or
Java classes which only make sense for Java.
At the moment I'm using the gettext plugin to internationalize FreeMarker
template files (it's based on JSP so at the end it's just Java :)). As long
as the translation methods in the template engine are formed like normale
Java method calls, it works. To get this working I wrote some viewHelper
methods for FreeMarker, so now I just use ${_("text to be translated")} for
singulars and ${_p("got one", "got two or more", 3)} for plurals (with
support for MessageFormat argument replacement).
Hi,
I just released version 1.2.3 of the maven-gettext-plugin that supports
files with different file endings.
I went with using Maven's FileSet type for specifying extra files that
should be parsed by xgettext. The optional extra argument is:
<extraSourceFiles>
<directory>${basedir}</directory>
<includes>
<include>**/*.jsp</include>
</includes>
<excludes>
<exclude>**/*.txt</exclude>
</excludes>
</extraSourceFiles>
I hope this is useful.
Comment #5 on issue 49 by bergerfx: maven-gettext-plugin missing
sourceExtensions option
http://code.google.com/p/gettext-commons/issues/detail?id=49
(No comment was entered for this change.)
Perfect, thanks. I'll upgrade my dependencies to use your new version.