cedx/phing-smartling

Phing tasks dedicated to the synchronization of translations with the Smartling service.


Keywords
i18n, translation, build, task, phing, smartling, php
License
MIT

Documentation

Phing-Smartling

Runtime Release License Downloads Coverage Build

Phing tasks dedicated to the synchronization of translations with the Smartling service, based on the File API v2.

Getting Started

If you haven't used Phing before, be sure to check out the related documentation, as it explains how to create a build.xml as well as install and use user tasks. Once you're familiar with that process, you may install the provided classes.

Installing via Composer

From a command prompt, run:

$ composer require --dev cedx/phing-smartling

Once the build tasks have been installed, they may be enabled inside your build.xml.

Usage

All file-based tasks require at least four attributes:

  • string fileUri : A value that uniquely identifies the remote file.
  • string projectId : The project identifier.
  • string userId : The identifier used to identify the API user.
  • string userSecret : The secret used to authenticate the API user.

Download the message translations from the Smartling service

This task takes a file pattern as input, indicating the target path of the downloaded files. The {{locale}} placeholder will be replaced by the locale of each file.

<taskdef classname="Phing\Smartling\Tasks\DownloadTask" name="smartlingDownload"/>

<target name="i18n:download">
  <smartlingDownload filePattern="path/to/i18n/{{locale}}.json"
    fileUri="/Phing-Smartling/messages.json"
    locales="es-ES,fr-FR,ja-JP,zh-CN"
    projectId="FooBar"
    userId="MyUserIdentifier"
    userSecret="MyTokenSecret"
  />
</target>

The supported attributes are:

  • string filePattern (required) : The pattern indicating the target path of the downloaded files.
  • string locales (required) : The locales to be downloaded, as a comma-separated list.
  • bool includeOriginalStrings = false : A value indicating whether to return the original string when no translation is available.
  • string retrievalType = "published" : The desired format for the download.

Upload the message source to the Smartling service

This task takes a file path as input, specifying the message source to be uploaded.

<taskdef classname="Phing\Smartling\Tasks\UploadTask" name="smartlingUpload"/>

<target name="i18n:upload">
  <smartlingUpload file="path/to/i18n/en-US.json"
    fileUri="/Phing-Smartling/messages.json"
    projectId="FooBar"
    userId="MyUserIdentifier"
    userSecret="MyTokenSecret"
  />
</target>

The supported attributes are:

  • string file (required) : The path to the message source.
  • bool authorize = false : A value indicating whether content in the file is authorized in all locales.
  • string callbackUrl = "" : The URL of the callback called when the file is 100% published for a locale.
  • string fileType = "" : The file type. If empty, will be guessed from the extension of the input file.

Examples

You can find a more detailled sample in the example folder:
Sample Phing tasks

See also

License

Phing-Smartling is distributed under the Apache License, version 2.0.