dallaslu / gettext-commons

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

allow general options #43

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I’ve been using the maven plugin for some time and found it quite
useful. The point is that now I would need to pass a couple of
parameters to the xgettext application that are not included in the
configuration parameters, so I wonder if you’re thinking on adding any
way of doing that.

I modified the source code to fit my current needs but I find that
adding one more parameter that allows to pass more options to the GNU
applications would be a nice feature.

Something like the following would be great

<plugin>
   <groupId>org.xnap.commons</groupId>
   <artifactId>maven-gettext-plugin</artifactId>
   <version>1.2.0</version>
   <executions>
        <execution>
           <id>distribute-properties-files</id>
           <configuration>
                <poDirectory>src/main/po</poDirectory>
                <targetBundle>com.kinamik.vault.Messages</
targetBundle>
                <outputFormat>properties</outputFormat>
                <options>--no-location –add-comments=///</options>
           </configuration>
           <goals>
              <goal>dist</goal>
           </goals>
        </execution>
   </executions>
</plugin>

Original issue reported on code.google.com by berge...@gmail.com on 1 May 2010 at 1:54

GoogleCodeExporter commented 9 years ago
That's already possible with the <keywords> configurations, I do this as 
following for my webapp with Freemarker templating:
<properties>
        <!-- Gettext -->
        <gettext.sourceLocale>en</gettext.sourceLocale>
        <gettext.keysFile>messages.pot</gettext.keysFile>
        <!--
        Add the keywords:
        _ = 1st param is singular form
        _p = plural, 1st param is singular, 2nd param is plural form
        _noop = 1st param is singular form, this one is a special-case
        @see http://www.gnu.org/software/gettext/manual/gettext.html#Special-cases
        Set extra options to the xgettext command (without the backslashes!):
        \-\-no-location = do not write '#: filename:line' lines in PO files
        \-\-add-comments[=TAG] = place comment block with TAG (or those preceding keyword lines) in PO file
        -->
        <gettext.keywords>-k_ -k_p:1,2 -k_noop --no-location --add-comments=///</gettext.keywords>
        <gettext.poDirectory>${project.build.resourceDirectory}/locale</gettext.poDirectory>
    </properties>

     <build>
        <plugins>
            <plugin>
                    <!-- http://code.google.com/p/gettext-commons/
                         http://gettext-commons.googlecode.com/svn/maven2-plugins-site/index.html
                    -->
                    <groupId>org.xnap.commons</groupId>
                    <artifactId>maven-gettext-plugin</artifactId>
                    <version>${gettext.version}</version>
                    <configuration>
                        <targetBundle>Messages</targetBundle>
                        <sourceDirectory>${project.basedir}/src</sourceDirectory>
                        <sourceLocale>${gettext.sourceLocale}</sourceLocale>
                        <extraSourceFiles>
                            <!-- Use build specific templates directory -->
                            <directory>${freemarker.templates.dir}</directory>
                            <includes>
                                <!-- Include FreeMarker templates -->
                                <include>**/*.ftl</include>
                            </includes>
                        </extraSourceFiles>
                        <keysFile>${gettext.keysFile}</keysFile>
                        <keywords>${gettext.keywords}</keywords>
                        <poDirectory>${gettext.poDirectory}</poDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>merge</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>merge</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>dist</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>dist</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
     </build>

Original comment by pvdis...@gmail.com on 24 Jan 2011 at 2:09

GoogleCodeExporter commented 9 years ago
Awesome, this is helping me tremendously.

Would you be so kind to show some examples in your freemarker templates, 
ideally including a case with plural text? Much appreciated! 

Hank

Original comment by hankipa...@gmail.com on 29 Sep 2011 at 1:26