Language File Generator

This project defines an XML schema which holds translated text resoures in one file. This maven plugin can create the platform specific message files from this one XML file. Use it during the "generate-resources" phase to keep your language files up to date.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

de.pentabyte.tools
ArtifactId

ArtifactId

i18n-maven-plugin
Last Version

Last Version

1.2.3
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Language File Generator
This project defines an XML schema which holds translated text resoures in one file. This maven plugin can create the platform specific message files from this one XML file. Use it during the "generate-resources" phase to keep your language files up to date.
Project URL

Project URL

https://github.com/hoereth/i18n-maven-plugin
Source Code Management

Source Code Management

https://github.com/hoereth/i18n-maven-plugin

Download i18n-maven-plugin

How to add to project

<plugin>
    <groupId>de.pentabyte.tools</groupId>
    <artifactId>i18n-maven-plugin</artifactId>
    <version>1.2.3</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 2.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.6
org.apache.commons : commons-lang3 jar 3.7
commons-io : commons-io jar 2.6

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

๐Ÿ  i18n-maven-plugin

Generator for language files. Currently supported target formats: JAVA, STRINGS (Xcode), JAVASCRIPT.

Maven Goals

  • de.pentabyte.tools:i18n-maven-plugin:translate (i18n.xml => language files)
  • de.pentabyte.tools:i18n-maven-plugin:reengineer (language files => i18n.xml, only available for JAVA & STRINGS).

Motivation

Language files are designed for application performance NOT for easy maintenance. Technical translation mistakes usually remain undetected. This plugin suggests that you rather maintain your translations in a structured and bullet-proof i18n.xml table file. The plugin will then generate the language files of your choice. This is one more build step, but the following issues will be taken care of:

Correct Syntax

The plugin will create the language files for you with all their peculiarities. Examples:

  • JAVA properties: They must be Latin1 encoded. UTF-8 characters can be escaped like this: รค = \u00E4. You have to deal with edge cases like the exclamation mark or colon character - they need to be escaped with a backslash (\! \:). Logical line breaks need to be terminated with a backslash.
  • STRINGS (Xcode): They must be UTF-16 encoded.

Consistency

No more typos in the keys. No more forgotten translations. The plugin even offers a language fallback mechanism, which allows you to temporarily fill missing translations with a secondary language (see <locale-config> element of example i18n.xml file).

Redundancy

The XML design gets rid off quite a few redundancies. On top off that, the plugin provides a placeholder mechanism to avoid redundant translations. Example: "The application ${someTranslationKey.forAppName} will now exit."

Structure

No need for "fake" grouping via composite key structures. XML naturally supports nested structures. The translations of all languages will be next to each other, which helps the translator. I might even say that I started to enjoy doing translations. ;) Also, you will find the perfect location to add a description for each translation entry to further explain the intent to the translator.

Getting started

i18n.xml Table File(s)

These will be the source of your translations for any kind of programming language. You can have more than one per project. You can put it anywhere in your project, because we will usually configure the plugin to pick up all files named i18n.xml. Please see this example i18n.xml file, which is configured to result in all different kinds of language files. Editing is almost self-explanatory, if your editor supports the provided XSD schema.

Configuration

The plugin provides these configuration params:

  • tableDirectory โ€” Recursivly check for all "i18n.xml"-Tables within that directory. Default: ${basedir}
  • tableFile โ€” Path of i18n-Table. (for when you only have one)
  • inputBasename โ€” Base name of XML-Table-File(s). Default: i18n
  • targetDir โ€” Base directory of generated source code files. Use case: accessor files. Default: ${basedir}/src/main/java

Please note that you can alternatively specifiy the following parameters within the <output> element of each of your i18n.xml files:

  • outputDirectory โ€” Language Files should be written here. Defaults to directory of respective table file.
  • outputFormat โ€” JAVA_PROPERTIES, STRINGS, JAVASCRIPT
  • outputBasename โ€” Base name of language files. Defaults according to outputFormat.
  • keySeparator โ€” Keys of nested entries will be separated with this value. Default: dot.

Target Format

To get more into detail, please continue reading the appropriate README file. However, you can mix formats within one project. You will also find information about the usage of the reengineer plugin, if available:

Versions

Version
1.2.3
1.2.2
1.2.1
1.2
1.1.2
1.1.1
1.1.0
1.0.0