Commands

Core Commands

The Lara CLI provides several commands to handle different translation scenarios and manage your translation resources.

translate

Use the translate command to perform translations between Supported Languages pairs. This command supports both text and file-based translations with advanced options to refine output quality.

Supported options:

  • --text (string): The text content to translate.
  • --source (optional string): ISO code of the source language (e.g., "fr-FR"). If omitted, automatic language detection will be used.
  • --target (string): ISO code of the target language (e.g., "en-US").
  • --context (optional string): Contextual information to guide translation (e.g., domain, tone, situation).
  • --instructions (optional string array): One or more translation instructions (e.g., "Use formal tone", "Avoid slang").
  • --memory (optional string): ID of translation memory to use for consistent terminology.
  • --glossary (optional string): ID of glossary to apply for domain-specific terms.
  • --file (optional string): Path to file for translation instead of direct text input.

Example:

lara translate --text "Hello, world!" --source en-US --target fr-FR

Response:

Bonjour, le monde !

Example with context:

lara translate --text "la terra è rossa" --target en-US --context "Conversation with a tennis player"

Response:

The clay is red.

Translation Memory Commands

The Lara CLI provides commands to list, create, and manage translation memories, which are essential for maintaining consistency and improving translation quality across projects.

memory list

Lists all translation memories linked to your account with their details.

Example:

lara memory list

Response:

[
  {
    "id": "mem_XYZ",
    "name": "Product Documentation",
    "ownerId": "acc_XYZ",
    "collaboratorsCount": 3,
    "createdAt": "2025-01-15T10:24:19.867Z",
    "updatedAt": "2025-01-20T15:30:42.881Z"
  }
]

memory create

Creates a new translation memory and links it to your account.

Supported options:

  • --name (string): Name of the new memory.
  • --external-id (optional string): ID of the memory to import from MyMemory (e.g., 'ext_my_[MyMemory ID]').

Example:

lara memory create --name "Marketing Content"

Response:

{
  "id": "mem_ABC123",
  "name": "Marketing Content",
  "ownerId": "acc_XYZ",
  "createdAt": "2025-01-26T14:22:10.123Z"
}

memory update

Updates an existing translation memory name.

Supported options:

  • --id (string): ID of the memory to update.
  • --name (string): The new name for the memory.

Example:

lara memory update --id mem_ABC123 --name "Marketing & Sales Content"

memory delete

Deletes a translation memory from your account.

Supported options:

  • --id (string): ID of the memory to delete.

Example:

lara memory delete --id mem_ABC123

memory add-translation

Adds a translation unit to an existing memory.

Supported options:

  • --id (string): ID of the memory where to add the translation unit.
  • --source (string): Source language code.
  • --target (string): Target language code.
  • --sentence (string): The source sentence.
  • --translation (string): The translated sentence.
  • --tuid (optional string): Translation Unit unique identifier.

Example:

lara memory add-translation --id mem_ABC123 --source en-US --target es-ES --sentence "Welcome" --translation "Bienvenido"

memory import-tmx

Imports a TMX file into a translation memory.

Supported options:

  • --id (string): ID of the memory to update.
  • --file (string): The path of the TMX file to upload.
  • --gzip (optional boolean): Indicates if the file is compressed (.gz).

Example:

lara memory import-tmx --id mem_ABC123 --file ./translations.tmx

Response:

{
  "id": "job_DEF456",
  "size": 1250,
  "progress": 0
}

memory check-import

Checks the status of a TMX file import job.

Supported options:

  • --job-id (string): The ID of the import job.

Example:

lara memory check-import --job-id job_DEF456

Response:

{
  "id": "job_DEF456",
  "size": 1250,
  "progress": 1
}

Translation Workflow

The CLI's primary function is the translate command, which accepts text or file input along with language specifications and optional parameters for context and instructions.

For instance, if you're translating technical documentation and need a formal tone, you can specify this in the command. The CLI will ensure that the translation maintains the appropriate register and terminology consistency throughout.

Batch Processing Example

Command:

lara translate --file ./docs/readme.md --source en-US --target de-DE --context "Technical documentation" --instructions "Use formal tone" --memory mem_ABC123

This command translates an entire markdown file while maintaining technical terminology from your translation memory and applying formal language style.


Glossary Command

The glossary command lists all Glossaries available in your Lara account. Glossaries ensure consistent and accurate translations for domain-specific terminology.

Usage

lara-cli glossary [options]

Options

OptionDescription
-h, --helpDisplay help information

Example Output

ℹ Found 3 Glossaries:

  ID: gls_abc123def456
  Name: Legal Terminology EN-ES

  ID: gls_xyz789uvw012
  Name: Medical Terms Database

  ID: gls_mno345pqr678
  Name: Product Names & Brands

Prerequisites

Before using the glossary command:

  1. Set up your Lara API credentials in a .env file:

    LARA_ACCESS_KEY_ID=your_access_key_id
    LARA_ACCESS_KEY_SECRET=your_access_key_secret
  2. Have at least one Glossary created in your Lara account

Using Glossaries

After identifying available Glossaries, you can:

  1. During initialization: Add glossaries when running lara-cli init

    lara-cli init
    # You'll be prompted to select Glossaries
  2. Non-interactive initialization: Specify glossaries directly

    lara-cli init --glossaries "gls_abc123, gls_def456" --non-interactive
  3. Manual configuration: Add to your lara.yaml file

    glossaries:
      - gls_abc123
      - gls_def456

For detailed documentation on using Lara Cli:

Commands