Wiki

Clone wiki

require-i18n-plugin / Home

require-i18n Maven plugin wiki

Welcome to the wiki page for the require-i18n Maven plugin.

Current Version : 1.0.2 - 21st March 2013

Previous versions : 1.0 - 20th March 2013

Download the code

$ git clone https://bitbucket.org/gary_jones/require-i18n-plugin.git

or 
$ git clone git@bitbucket.org:gary_jones/require-i18n-plugin.git

Plugin features

This Maven plugin will take the Java properties files contained in <propertiesDir> and generate the Require.js i18n modules into the directory specified by <requireI18NDir>

Properties Files

All properties files should conform to one of the following formats:

#!java

<name>.properties
<name>_<lang>.properties
<name>_<lang>_<locale>_<variant>.properties

<lang>, <locale> and <variant> are optional.

The plugin checks for the "_" character as the language/locale/variant separator character on properties files and creates Require.js sub-directories using "-" character as the separator.

The plugin will search sub-directories recursively for all properties files from <propertiesDir> downwards.

Require.JS Information

The Require.js formats for files is described on the Require.js website:

Require.JS I18N Documentation

As described on is site the require top level module is created as follows:

#!javascript

//my/nls/colors.js contents:
define({
    "root": true,
    "fr-fr": true,
    "fr-fr-paris": true
});

and the root bundle will look like this:

#!javascript

//Contents of my/nls/root/colors.js
define({
    "red": "red",
    "blue": "blue",
    "green": "green"
});

Require sub-directories will take the form (all lower case):

#!javascript

<lang>-<locale>-<variant>

and will be located in <requireI18NDir>/nls

The Maven configuration is:

#!xml

            <plugin>
                <groupId>com.intellectfactory.maven.plugins</groupId>
                <artifactId>require-i18n-plugin</artifactId>
                <version>1.0.2</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <propertiesDir>${project.basedir}/src/main/resources/themes/default</propertiesDir>
                    <requireI18NDir>${project.basedir}/src/main/webapp/resources/js</requireI18NDir>
                </configuration>
            </plugin>

Executing the plugin

Given the above Maven configuration the plugin will be executed after the compile goal of your project

Alternatively, you can execute the goal directly using:

mvn require-i18n:generate

Feel free to download or modify the code.

It is designed to be as simple as possible.

If you need help or want to improve the code please feel free to contact me on garyj.intellect@gmail.com

Updated