The Lionbridge Content Command Line Interface (LIOX CLI) allows scripts to send files for translation and retrieve translations when they are done. A common use case for the LIOX CLI is to insert translation into an automated software development lifecycle.

Setup

The ltrans is an executable Java JAR named liox-content-cli.jar. To use it, you must have Java 7+ installed on your system and in your path.

Download

You can download the latest JAR from the following location:

Alias

To make it easier to invoke from the command line, we recommend that you create an alias command like ltrans which expands to java -jar liox-content-cli.jar

On a Mac or Linux you can do this with:

alias ltrans="java -jar liox-content-cli.jar"

Required API Variables

The CLI depends on a few API variables being set. This can be set either via environment variables or passed on the command-line.

Using Environment Variables

To use the Environment Variable method, set the following:

  • LIOX_API_ACCESS_KEY_ID: Your Lionbridge onDemand access key ID. You can get this on your profile page.
  • LIOX_API_SECRET_KEY: The secret part of your Lionbridge onDemand access key. This is also available on your profile page.
  • LIOX_API_ENDPOINT: The URL to the Lionbridge onDemand site that you are pointing to.
  • LIOX_API_DEFAULT_CURRENCY: The default currency to use.

On a Mac or Linux you can set them as such:

export LIOX_API_ACCESS_KEY_ID=<your_access_key>
export LIOX_API_SECRET_KEY=<your_secret>
export LIOX_API_ENDPOINT=https://developer-sandbox.liondemand.com/api
export LIOX_API_DEFAULT_CURRENCY=USD

Using Command-Line Options

To use the command-line method, pass the following to any of the commands below:

  • --access-key-id: Your Lionbridge onDemand access key ID. You can get this on your profile page.
  • --secret-key: The secret part of your Lionbridge onDemand access key. This is also available on your profile page.
  • --endpoint: The URL to the Lionbridge onDemand site that you are pointing to.
  • --default-currency: The default currency to use.

Basic Usage

The LIOX CLI has a hierarchical command structure that looks like

$ ltrans <object-type> <command> [OPTIONS]

For example, the command to upload a file would look like

$ ltrans file add --local-file=./foo.txt --source-locale=en-us

This would return a file id that can be used in the creation of a translation job.

$ ltrans job add --source-files=999,1000 --service=10
  --source-locale=en-us --target-locales=fr-fr,it-it,es-es

This, in turn, can be used to create a quote.

$ ltrans quote add --jobs=500

Help

To get help for any command, add the --help argument.

Version

To see the version of the Lionbridge Content CLI you are using, use the --version argument.

Example Projects

To see how the CLI can be used in your own projects, take a look at the following:

File Object

The file object can be used to add source and reference files and to retrieve translations of source files.

file add Command

The add sub-command of file uploads a file. It responds with a file ID printed to standard out.

Arguments

  • --file (required): The path to file on your file system or the URL to your file
  • --help : Shows help for this command
  • --source-locale (required): The source language of the file

Output

  • file id: The ID that can be used to reference the file

  • Example Usage

    This example shows uploading an English language file named foo.txt from the current directory. This file can be used as a source file or reference file by using the returned ID of 999.

    $ ltrans file add --file=./foo.txt --source-locale=en-us
    999
    

    file download-targets Command

    Downloads the translated files for a specific language.

    Arguments

    • --file (required): The ID of the source file. This should have been returned when uploading the file.
    • --help : Shows help for this command
    • --output-dir (required): The path on the local file system where the translated file should be saved.
    • --target-locale (required): The locale of the translation you want to download.

    Output

    A status as to whether the download was successful or not.

    Example Usage

    This example shows downloading the French translation of the file with ID 999 and saving it in the ‘translations’ sub-directory of the current directory.

    $ ltrans file download-target --file=999 --target-locale=fr-fr --output-dir=./translations
    Success!
    

    file info Command

    The info sub-command of file gets details about a file. It responds with the status and other attributes of the file.

    Arguments

    • --file (required): The ID of the file you want information about.
    • --help : Shows help for this command

    Output

    Returns the attributes of the specified file.

    Example Usage

    This example shows retrieving information about the file with the ID 999.

    $ ltrans file info --file=999
    status: Analyzed
    created: 2014-01-25T10:32:02Z
    

    Job Object

    The job object represents a translation job which takes source files as inputs and returns translations when it is complete.

    job add Command

    The add sub-command of job adds a job. It responds with a job ID printed to standard out.

    Arguments

    • --help : Shows help for this command
    • --job-complete-endpoint : List of URLs, and/or email address for notifications
    • --reference-files : Comma delimited list of IDs of the files that will be used as reference files
    • --service (required): The service to use
    • --source-files (required): Comma delimited list of IDs of the files to be translated
    • --source-locale (required): The language of the source files
    • --target-locales (required): Comma delimited of locales that you want to translate into

    Output

  • job id: The ID that can be used to reference the job

  • Example Usage

    This example shows adding a job using the English files with IDs 999 and 1000 and requesting them to be translated to French, Italian and Spanish using the service with ID 10.

    $ ltrans job add --source-files=999,1000 --source-locale=en-us --target-locales=fr-fr,it-it,es-es --service=10
    555
    

    job info Command

    The info subcommand returns information about the job. By default it will return YAML structured data.

    Arguments

    • --help : Shows help for this command
    • --job (required): The ID of the job. This should have been returned when adding the job.

    Output

    Details of the request job in YAML format.

    Example Usage

    This example shows retrieving information about the job with the ID of 555.

    $ ltrans job info --job=555
    status: complete
    source-files: 999, 1000
    completion-date: 2014-01-25T10:32:02Z
    due-date: 2014-01-25T10:32:02Z
    

    Locale Object

    The local object represents the locales supported the translation API.

    locale list Command

    The list sub-command returns a list of all supported Locales.

    Arguments

    • --help : Shows help for this command

    Output

  • All the supported locales

  • Example Usage

    This example shows retrieving the list of locales support by onDemand.

    $ ltrans locale list
    locales:
      - name: Arabic (Morocco)
        code: ar-ma
      - name: Arabic (United Arab Emirates)
        code: ar-ae
    ...etc...
    

    Quote Object

    The quote object represents group of one or more jobs. Quotes are used for pricing and purchasing jobs.

    quote add Command

    The add sub-command of quote adds a quote. It responds with a quote ID printed to standard out.

    Arguments

    • --currency (required): The currency that you want the quote priced in. The valid currencies are: AUD, CAD, CHF, CNY, EUR, GBP, INR, PLN, SEK, SGD, USD
    • --help : Shows help for this command
    • --jobs (required): Comma delimited list of IDs of the jobs to be quoted
    • --quote-ready-endpoint : List of URLs, and/or email address for notifications

    Output

  • quote id: The ID that can be used to reference the quote

  • Example Usage

    The example shows adding a quote that references the job with ID 555 and uses US dollars as the currency.

    $ ltrans quote add --jobs=555 --currency=USD
    333
    

    quote authorize Command

    The authorize is used to pay for the quote. Work on jobs is not started until the quote is authorized. At the moment, only purchase order transactions are supported. To use a PO, you need to register it with your onDemand sales representative.

    If you want to pay with a credit card, you can use the quote id to get to the review page on the onDemand Portal and pay for the project there.

    Arguments

    • --help : Shows help for this command
    • --po-number (required): The number of the purchase order that will be used to pay for the project.
    • --quote (required): The ID of the quote. This should have been returned when adding the quote.
    • --quote-paid-endpoint : List of URLs, and/or email address for notifications

    Output

    The result of authorizing the quote.

    Example Usage

    This example shows authorizing a quote with the ID 333 using the purchase order ‘001’

    $ ltrans quote authorize --quote=333 --po-number=001
    Success!
    

    quote info Command

    The info subcommand returns information about the quote. By default it will return YAML structured data.

    Arguments

    • --help : Shows help for this command
    • --quote (required): The ID of the quote. This should have been returned when adding the quote.

    Output

    Details of the request quote in YAML format.

    Example Usage

    This example shows retrieving information about the quote with ID 333.

    $ ltrans quote info --quote=333
    status: Pending
    created: Tue Dec 13 17:45:52 EST 2016
    jobs: 555
    totalPrice: 1.71
    

    Service Object

    The service object represents the different services provided by the API.

    service info Command

    The info command returns information about a single service.

    Arguments

    • --help : Shows help for this command
    • --service (required): The ID of the service you want info on

    Output

    Information about the requested Service

    Example Usage

    This example shows retrieving information about the service with ID 144

    $ ltrans service info --id=144
    name: Machine Translation
    id: 144
    targetLanguages: de-de, en-gb, en-us, es-es, fr-ca, fr-fr, it-it, ja-jp, ko-kr, zh-cn, zh-tw
    sourceLanguages: de-de, en-gb, en-us, es-es, fr-fr, it-it, ja-jp, ko-kr, pt-br, zh-cn, zh-tw
    validTypes: csv, docx, html, ini, json, po, pptx, properties, txt, xlsx, xml, yml, zip
    

    service list Command

    The list command is used to retrieve a list of all Services supported by the API.

    Arguments

    • --help : Shows help for this command

    Output

  • A list of all Serices supported by the API.

  • Example Usage

    This example shows retrieving all the services provided by onDemand.

    $ ltrans service list
    services:
    - name: Fashion + Apparel API
      id: 155
      validTypes:
      targetLanguages: de-de, en-gb, es-es, fr-fr, it-it
      sourceLanguages: de-de, en-gb
    - name: 'Single XLIFF "XXX" translation '
      id: 156
    ...etc...
    

    Back to top

    Reflow Maven skin by Andrius Velykis.