Skip to main content
Last updated October 12, 2012 08:41, by Johan Reitzema
Feedicon  

OmegaT Maven Plugin Wiki


About

This maven plugin transfers files between maven projects and OmegaT translation projects.

Version 0.2 is available in maven central.

Plugin goals

  • copy-sources: copies files to be translated from a maven project to an OmegaT project.
  • copy-translations: copies translation results from an OmegaT project to a maven project.

Translated files from OmegaT will already include locale suffixes as used by java resource bundles.

Plugin parameters

sourceLanguage

A locale string, the language used in your unsuffixed files.

targetLanguages

A comma separated string of target locales.

translationRootPath

The path to the parent folder of your translation project. How this path is to be interpreted is determined by the translationRootType parameter below.

The structure under this root directory is assumed to be as follows:

  • A "shared-sources" directory that will contain the files copied from your maven project, to be used by all translation projects under this root.
  • A translation project directory per target language, named after its locale; so each project will look for its sources in "../shared-sources"

translationRootType

Determines how the translationRootPath parameter above is to be interpreted:

  • absolute: anywhere on your local filesystem; you might want to use a maven property configured via settings.xml if a configuration using this type is to be shared.
  • project: relative to the project currently being processed; in a multi-module project this means each module will get its own set of translation projects.
  • session: relative to the execution root; in a multi-module project this means the files from all modules will be aggregated in a translation project under the maven parent project.

omegatTargetDir

Name of the target directory used by OmegaT projects.

The default name for the folder where OmegaT generates its translations is "target", which happens to be the same as what maven uses and is likely to be on the ignore list of scm tools.

filesets

A list of fileset rules to select files and directories.

  • directory: input root folder; where to look for files to copy to the shared sources; e.g. "src/main/resources"
  • outputDirectory: the output root folder; where to copy the translation results; in most cases this will be equal to the input folder.

If either of these directories is not an absolute path, it will be relative to your pom.


Usage

mvn nl.cloudfarming.mojo:omegat-maven-plugin:copy-sources

or add a plugin group to your settings.xml:

    <pluginGroups>
		<pluginGroup>nl.cloudfarming.mojo</pluginGroup>
	</pluginGroups>
and use:
mvn omegat:copy-sources

Workflow

Ensure your translation projects are setup as specified under the translationRootPath parameter. Do not use the OmegaT import function, that's what the copy-sources goal is for.

  1. run the copy-sources goal whenever files to be translated are modified/added/removed
  2. open an OmegaT project
    1. translate
    2. save
    3. generate translations
  3. run the copy-translations goal
  4. rinse, repeat


Example configuration

In the examples below the configuration parameters are shared by both goals:

            ...
            <plugin>
                <groupId>nl.cloudfarming.mojo</groupId>
                <artifactId>omegat-maven-plugin</artifactId>
                <version>0.2</version>
                <configuration>
                    <sourceLanguage>en</sourceLanguage>
                    <targetLanguages>nl</targetLanguages>
                    <translationRootPath>translations/omegat</translationRootPath>
                    <translationRootType>session</translationRootType>
                    <filesets>
                        <fileset>
                            <directory>${basedir}/src/main/resources</directory>
                            <outputDirectory>${basedir}/src/main/resources</outputDirectory>
                            <includes>
                                <include>**/*.properties</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            ...

Example profiles

    <profiles>
        <profile>
            <id>copy-sources-to-omegat</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>nl.cloudfarming.mojo</groupId>
                        <artifactId>omegat-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-sources</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>copy-sources</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>    
        <profile>
            <id>get-translations-from-omegat</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>nl.cloudfarming.mojo</groupId>
                        <artifactId>omegat-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-translations</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-translations</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>               
    </profiles>

mvn process-classes  -Pcopy-sources-to-omegat

 
 
Close
loading
Please Confirm
Close