Crowdin and Gazelle integration

Crowdin is a complete solution to make your website or software universally accessible through translation. Crowdin advanced editor helps translators to work faster and more efficiently with our innovative translation approach." https://crowdin.com/

A Maven plugin allows crowdin integration into our projects (https://github.com/ValentinLorand/crowdin-plugin).  You can use it by adding the latest gazelle-seam version (from 2.1.0) in your pom.xml.

Global setup

To authenticate yourself to Crowdin, you need to configure your ~/.m2/settings.xml.

Your personal API key need to be generated from Crowdin server interface (https://crowdin.com/settings#api-key).

Once you have your API key, you can add the following in the settings.xml file :

<settings> 
 <servers> 
	<server> 
		<id>crowdin-gazelle</id>
		<username>4960</username>  <!-- The crowdin project id -->
		<password><!-- insert here you personal API key --></password>
	</server>
 </servers> 
 <!-- ... --> 
 <pluginGroups> 
	<pluginGroup>com.googlecode.crowdin-maven</pluginGroup> 
 </pluginGroups> 
</settings>

Managing and adding translations to a project. Ex : gazelle-tm-war

1. The pom.xml of the war module must contains the following plugin. It is provided by default by gazelle-tools or simulator-common :

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>gazelle-plugins</artifactId>
</plugin>

2. Open the pom.xml of your project, under the <properties></properties> section, add

 

<messages.mode>crowdin</messages.mode>

3.Keep your project updated with crowdin server :

mvn crowdin:pull

4. Edit the XHTML files with untranslated messages. 

5. Build your project,

mvn clean package

And look for messages in logs such as:

[WARNING] Missing translation in list.xhtml (line:20,col:51) : New simulator 

If there is parameters that must not be translated, add their name in the gazelle-plugins configuration (pom.xml)

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>gazelle-plugins</artifactId>
   <configuration>
      <ignoredParamNames>
          <ignoredParamName>displayActorFilter</ignoredParamName>
      </ignoredParamNames>
   </configuration>
</plugin>

6. When you are ready to extract new messages from xhtml, run the following command. You need to add the keyPrefix argument to the maven command. As an example you might want to run :

mvn gazelle:xhtml-messages -DkeyPrefix=net.ihe.gazelle.tm

7. A new .properties file has been added to the src/main/messages folder. This file is temporary and contains only new elements. Copy the content into the existing properties file. Then delete the temporary .properties file.


 Usage of crowdin plugin 

1. Push new messages on Crowdin server with :

mvn crowdin:push

2. If you pushed a new file on Crowdin server (new project), the encoding may be broken on translated file (later pull). See Jira issue MCA-27 on how to fix it.

3. Translate messages in Crowdin GUI. Messages that are not translated into another language will keep the original message value (english).

4. Then, you can retrieve the translations executing the command :

mvn crowdin:pull

If there are new translation, the server will need to rebuild the packge of translations. This can takes 1 minutes and after it will download the translations that your project need depending on the depencencies declared in your project poms.


Detailed informations 

src/main/messages contains properties that you want to be translated. Translations are used there only for initialization.

When new files/keys have been added to src/main/messages, you can push them to crowdin using mvn crowdin:push . It is Maven first, all elements in crowdin not in src/main/messages will be deleted from crowdin.

When translations are done on crowdin, it is needed to update package on crowdin. It can be done using mvn crowdin:export but it doesn't look to export it everytime (API throttle). So you can also update the package using "Build fresh package" on https://crowdin.com/project/gazelle/settings , "Downloads" tab.

Finally, you will have to pull new translations into your project by executing mvn crowdin:pull . It creates src/main/crowdin folder, storing used translations. Files in this folder should not be edited, it is just there for being able to build project without connecting to crowdin.

When the project is packaged, messages are aggregated and made available to the application as before (automatically done via gazelle-seam profiles).

Project migration from xml files to crowdin 

  • Use latest gazelle-seam as parent (>= 2.1.0).
  • Package your application.
  • For each module, store properties from target/generated-resources/messages-generated in a temporary folder.
  • Copy english version (en.properties) into src/main/messages, and rename it with a meaningful name.
  • Delete old xml file.
  • From project root, execute mvn crowdin:push .
  • For each already translated langage, go to translation pages (https://crowdin.com/project/gazelle/fr for french). Click on upload matching the new file, and select the backuped file. Translated elements will be added to crowdin.