lyonplus / gettext-commons

Automatically exported from code.google.com/p/gettext-commons
GNU Lesser General Public License v2.1
0 stars 0 forks source link

maven-gettext-plugin missing sourceExtensions option #49

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

Original issue reported on code.google.com by pvdis...@gmail.com on 19 Jul 2010 at 3:19

Attachments:

GoogleCodeExporter commented 8 years ago
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.

Original comment by pvdis...@gmail.com on 20 Jul 2010 at 8:06

GoogleCodeExporter commented 8 years ago
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.

Original comment by berge...@gmail.com on 27 Jul 2010 at 4:09

GoogleCodeExporter commented 8 years ago
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). 

Original comment by pvdis...@gmail.com on 27 Jul 2010 at 5:29

GoogleCodeExporter commented 8 years ago
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.

Original comment by berge...@gmail.com on 26 Aug 2010 at 5:16

GoogleCodeExporter commented 8 years ago

Original comment by berge...@gmail.com on 26 Aug 2010 at 5:17

GoogleCodeExporter commented 8 years ago
Perfect, thanks. I'll upgrade my dependencies to use your new version.

Original comment by pvdis...@gmail.com on 6 Sep 2010 at 11:22