A command line tool to handle synchronization of the source code with translations made on Crowdin.
Maven plugin for crowdin (https://crowdin.com)
-
Git is installed and configured properly.
-
Have a valid Crowdin Project ID and its key.
-
Maven 3.2.5+ is installed
Add the Following properties in the maven settings.xml (contact an admin of crowdin to get the project key and id):
<pluginGroups>
<!-- ... -->
<pluginGroup>org.exoplatform.translation.crowdin</pluginGroup>
<!-- ... -->
</pluginGroups>
<!-- ... -->
<profile>
<id>crowdin</id>
<properties>
<exo.crowdin.project.id>exo-platform</exo.crowdin.project.id>
<exo.crowdin.project.key>YOUR KEY</exo.crowdin.project.key>
</properties>
</profile>
<!-- ... -->
<activeProfiles>
<activeProfile>crowdin</activeProfile>
</activeProfiles>Available goals are: download-translations, update-sources, update-crowdin, restore-translation (upload-translation goal exists but is never used and should probably be deleted).
| Goal | Description |
|---|---|
crowdin:download-translations |
Download the translations archive from Crowdin (defaults to /target/translation.zip). Options: * dryRun - Do not download the archive if set to true and if the archive already exist. Defaults to false. * exo.crowdin.translationsArchivePath - target path of the translations archive, defaults to /target/translations.zip |
crowdin:update-sources |
Update translations files in source project with translations from Crowdin (from the translations archive), commit and push. Options: * exo.crowdin.translationsArchivePath - translations archive, defaults to /target/translations.zip * langs - Comma-separated list of languages to update. Defaults to all which means that all the languages available in the archive are updated. Example: Activate new language/properties file by activating ONLY the new language (for example : * dryRun - Do not download the archive and not push updates to Github if set to true. Defaults to false. |
crowdin:update-crowdin |
Update all translations from source project to Crowdin. Options: * dryRun - Do not upload files to crowdin if set to true. Defaults to false. |
crowdin:restore-translation |
Restore a Crowdin project’s directory structure and translations from its zip file. This zip file should be built with 'Export Only Approved' and 'Don’t Export Untranslated' options unchecked so it will backup the untranslated and all suggested translations (not only the approved ones) as they will need to be restored also. Since this zip contains the project’s directory structure and all of its translations, it can be considered as a project’s backup and should be rebuilt (with 'Build Fresh Package' under Crowdin’s 'Downloads' tab) and kept safe before doing any activity that may mess up the project. Can also be used to clone a Crowdin project from its zip file (by changing the project’s API key to point to another project) - see How-tos. If you want to decide what to be uploaded to Crowdin, you can: first run with 'Dprepare=true' option to get the plugin stops after preparing the extracted folder for you to modify, e.g to remove some languages or projects you don’t want to upload. When you’re done, let the plugin continues by running with '-Dcontinue=true' option, it will upload your modified folder instead of the original zip. Options: * dryRun - Do not do any communication with Crowdin if set to true. Defaults to false. It is useful to see the evolution of the process. Combined with maven debug option -X, it displays actual REST calls and XmlPath queries. |
Here are the tasks done by the goals:
-
crowdin:update-sources
-
for each language and each localization file declared in translations.properties file…
-
if the file is an XML file, convert the properties file from Crowdin to an XML file
-
use the english version (en) as a skeleton and fill it with translations from Crowdin in the given language
-
save the filled file at its source location
-
commit the changes
-
if not in dry run, push the changes in the current branch
-
-
-
crowdin:update-crowdin
-
load the translations file of the project
-
browse them to identify master files and translations
-
create new folders, upload new master files and translations (new entries in the properties)
-
update master files content on Crowdin (add new keys, rename existing keys, delete keys)
-
delete old folders and files (old entries in the properties and not exist in file system)
-
In development mode, a test Crowdin project is used, called crowdin-maven-plugin-dev : https://crowdin.com/project/crowdin-maven-plugin-dev.
In order to use it in a project instead of the default one, get the project id and key and update the pom.xml accordingly, or pass these properties directly in the command line:
mvn -Dexo.crowdin.project.id=<project-id> -Dexo.crowdin.project.key=<project-key> org.exoplatform.translation.crowdin:crowdin-maven-plugin:1.2.0:download-translationsDebugging local code can be done with surefire debugging option (and dryRun enabled to not apply the changes):
mvn -Dexo.crowdin.project.id=<project-id> -Dexo.crowdin.project.key=<project-key> org.exoplatform.translation.crowdin:crowdin-maven-plugin:1.2.x-SNAPSHOT:upload-translation -DdryRun=true -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE"-
http://code.google.com/p/rest-assured/wiki/Usage?ts=1317978378&updated=Usage#Example_1_-_JSON
-
http://blog.jayway.com/2011/10/09/simple-parsing-of-complex-json-and-xml-documents-in-java/
-
http://rest-assured.googlecode.com/svn/tags/1.6/apidocs/com/jayway/restassured/path/xml/XmlPath.html
-
http://maven.apache.org/developers/mojo-api-specification.html