Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,38 @@ For detailed documentation on using Lara CLI:
- [Xcode Stringsdict Files Guide](docs/config/files/xcode-stringsdict-files.md) - Complete guide for Xcode .stringsdict plural files
- [Xcode String Catalogs Guide](docs/config/files/xcode-xcstrings-files.md) - Complete guide for Xcode .xcstrings String Catalogs
- [TXT Files Guide](docs/config/files/txt-files.md) - Complete guide for plain text files

## Lara Think

Use `--reasoning` to select Think; `--reasoning-effort` accepts `low`, `medium`,
or `high` (default **high**). Without Think, Lara Base is used.

```sh
lara-cli translate --text "Hello" --source en --target it --reasoning --reasoning-effort medium
lara-cli translate --file messages.json --source en --target it --reasoning --reasoning-effort low
lara-cli translate --reasoning --reasoning-effort high --force
```

For project translations, save the settings in `lara.yaml`:

```yaml
translation:
reasoning: true
reasoningEffort: high
```

Explicit flags override project settings. `--no-reasoning` disables Think and
discards the inherited level. An explicitly supplied level requires Think to
be enabled; `--no-reasoning --reasoning-effort low` is an error. Direct text/file
modes ignore project configuration. Use lowercase level values.

These options apply to all existing text, file and project translation paths,
including batches and retries. Use `--force` to retranslate existing project
entries after changing model or level. Think requests allow 300 seconds per
request; Base retains 30 seconds. Retries can extend total run time.

If Lara reports that reasoning was not applied, the translation is retained
and a warning is printed to stderr; stdout and translated files keep their
existing format. Usage metrics are enabled by default, subject to the opt-out
settings described in Usage Metrics above. When enabled, they record the effective
requested level and reported fallback, without translation content.
35 changes: 35 additions & 0 deletions docs/commands/translate.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ lara-cli translate [options]
| `-t, --target <locales>` | Comma-separated list of target locales to translate to |
| `-p, --paths <paths>` | Comma-separated list of specific file paths to translate (overrides config) |
| `-f, --force` | Force retranslation of all content, even if unchanged |
| `--reasoning` | Use Lara Think; defaults to high effort |
| `--no-reasoning` | Disable Think, overriding project configuration |
| `--reasoning-effort <level>` | Think effort: `low`, `medium`, or `high`; requires Think to be enabled |
| `--no-trace` | Prevent server-side storage of translated content |
| `--orphan-keys <mode>` | `keep` or `delete`. What to do with keys that exist only in target files. Overrides `translation.orphanKeys` in `lara.yaml` for this run. Cannot be combined with `--file` or `--text` |
| `-h, --help` | Display help information |
Expand Down Expand Up @@ -162,6 +165,34 @@ Use `--force` when you need to:
- Fix translation errors by regenerating all translations
- Reset translations after configuration changes

## Lara Think

By default, translations use Lara Base. Enable Lara Think for project, text, or file translations:

```bash
lara-cli translate --reasoning --reasoning-effort medium
lara-cli translate --text "Hello" --source en --target it --reasoning
lara-cli translate --file messages.json --source en --target it --reasoning --reasoning-effort low
```

For project translations, save the settings in the existing `translation` section of `lara.yaml`:

```yaml
translation:
reasoning: true
reasoningEffort: high
```

- Effort accepts lowercase `low`, `medium`, or `high`. Think defaults to `high` when no effort is specified.
- Explicit CLI flags override project settings. `--no-reasoning` disables Think and discards the inherited effort. An explicitly supplied effort requires Think to be enabled, either with `--reasoning` or in project configuration; `--no-reasoning --reasoning-effort low` is an error.
- Direct `--text` and `--file` modes ignore project translation settings: enable Think with CLI flags.
- Model or effort changes do not invalidate existing translations. Use `--force` to retranslate existing project entries.
- Each Think API request has a 300-second timeout; Base requests retain 30 seconds. Files and target locales use separate requests, and a file may need multiple batches. Each retry has its own timeout, so total run time can be longer. The timeout is automatic and cannot be configured in YAML.
- If the server reports that Think was not applied, the CLI retains the returned translation and prints a warning to stderr without changing stdout or file formats. This alone does not trigger a retry or fail the command.
- When [usage metrics](../../README.md#usage-metrics) are enabled, command metadata records `reasoning`, the requested `reasoningEffort`, and `reasoningFallback: true` if a fallback was reported, without translation content.

See [Lara Think configuration](../config/structure.md#lara-think) for configuration defaults and overrides.

## No-Trace Mode

Use `--no-trace` to prevent the translation API from storing or logging your content server-side. This is useful when translating sensitive or confidential content. A no-trace run is also left out of the CLI's [usage metrics](../../README.md#usage-metrics) entirely.
Expand Down Expand Up @@ -240,6 +271,9 @@ Only [supported file formats](../config/formats.md) are accepted (JSON, PO, XML,
| `-o, --output <path>` | Output file path (only with `--file`) |
| `-m, --translation-memories <ids>` | Translation Memory IDs (comma-separated) |
| `-g, --glossaries <ids>` | Glossary IDs (comma-separated) |
| `--reasoning` | Use Lara Think; defaults to high effort |
| `--no-reasoning` | Disable Lara Think |
| `--reasoning-effort <level>` | `low`, `medium`, or `high`; requires `--reasoning` in direct mode |
| `--no-trace` | Prevent server-side storage of translated content |

### Using Translation Memories & Glossaries
Expand All @@ -263,6 +297,7 @@ Use `lara-cli memory` and `lara-cli glossary` to list available IDs.
| Translation instructions | Yes | No |
| Multiple target locales per invocation | Yes | No (one at a time) |
| Translation Memories & Glossaries | Yes | Yes |
| Lara Think | CLI flags or `translation` settings in YAML | CLI flags only |

### Prerequisites

Expand Down
17 changes: 16 additions & 1 deletion docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ glossaries:
- gls_xyz789
noTrace: false
translation:
reasoning: false
batchSize: 50
orphanKeys: keep
files:
Expand All @@ -38,11 +39,25 @@ files:

Lara CLI supports multiple file formats. See [Supported Formats](./formats.md) for a complete list and format-specific guides like [PO Files](./po-files.md).

## Lara Think

To use Think for project translations, update the existing `translation` section:

```yaml
translation:
reasoning: true
reasoningEffort: high
```

Effort accepts `low`, `medium`, or `high` and defaults to `high` when Think is enabled. Without `reasoning: true`, the CLI uses Lara Base. Explicit CLI flags override these settings; direct `--text` and `--file` modes use CLI flags instead of YAML.

See [Lara Think configuration](./structure.md#lara-think) for validation, timeout, and fallback behavior.

## Configuration Sections

The configuration is divided into several sections:

- **[Configuration Schema](./structure.md)** - Schema structure and organization of the configuration file, including [translation batching](./structure.md#translation-batching) and [orphan key handling](./structure.md#orphan-keys)
- **[Configuration Schema](./structure.md)** - Schema structure and organization of the configuration file, including [Lara Think](./structure.md#lara-think), [translation batching](./structure.md#translation-batching), and [orphan key handling](./structure.md#orphan-keys)
- **[Supported Formats](./formats.md)** - List of supported file formats
- **[Locales](./locales.md)** - Source and target language configuration
- **[Files](./files.md)** - File paths and exclusion patterns
Expand Down
34 changes: 32 additions & 2 deletions docs/config/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lara.yaml
├── memories # Translation memory settings
├── glossaries # Terminology settings
├── noTrace # No-trace mode (no server-side storage, no usage metrics)
├── translation # Translation tuning (batch size, orphan key handling)
├── translation # Translation tuning (Think, batch size, orphan key handling)
└── files # File path and processing rules
```

Expand Down Expand Up @@ -54,6 +54,8 @@ noTrace: false

# Translation tuning
translation:
reasoning: true # Enable Lara Think (default: false)
reasoningEffort: high # low | medium | high (default when Think is enabled: high)
batchSize: 50 # Max keys sent per translation request (default: 50)
orphanKeys: keep # What to do with target-only keys: keep | delete (default: keep)

Expand Down Expand Up @@ -118,6 +120,34 @@ Configuration settings follow a specific inheritance pattern:

This allows for progressive refinement of translation instructions and rules.

## Lara Think

The optional `translation.reasoning` setting selects Lara Think for project translations. It defaults to `false` (Lara Base). Existing configuration files continue to use Base without changes.

```yaml
translation:
reasoning: true
reasoningEffort: medium
```

`reasoningEffort` accepts lowercase `low`, `medium`, or `high`. Omit it to use `high` when Think is enabled. If `reasoningEffort` is set, Think must be enabled; to disable Think in YAML, set `reasoning: false` and remove `reasoningEffort`.

Explicit flags on [`translate`](../commands/translate.md#lara-think) override YAML settings:

```bash
lara-cli translate --reasoning-effort low # Override effort when Think is enabled in YAML
lara-cli translate --no-reasoning # Disable Think and discard inherited effort
lara-cli translate --reasoning --force # Retranslate existing project entries with Think
```

An explicitly supplied effort cannot be combined with `--no-reasoning`. Direct `--text` and `--file` modes ignore project translation settings and require `--reasoning` to enable Think.

Think settings are preserved across batches and retries. The timeout is 300 seconds per Think API request, compared with 30 seconds for Base. Each batch and retry has its own timeout; this is not a total timeout for a file or command, and it is not configurable in YAML.

If Lara reports that Think was not applied, the returned translation is retained and a warning is printed to stderr. The fallback alone does not trigger a retry or fail the command. When [usage metrics](../../README.md#usage-metrics) are enabled, they record the requested reasoning settings and whether a fallback occurred, without translation content.

Changing Think settings does not retranslate unchanged entries automatically: use `--force` when you want to apply the new model or effort to existing translations.

## Translation Batching

When a single file contains multiple translatable keys, Lara CLI sends them together in a single API request instead of one request per key. This reduces round trips and makes translation noticeably faster on large files.
Expand Down Expand Up @@ -181,4 +211,4 @@ Each section of the configuration has its own detailed documentation:
- [Files Configuration](./files.md)
- [Instructions Configuration](./instructions.md)
- [Translation Memories Configuration](./memories.md)
- [Glossaries Configuration](./glossaries.md)
- [Glossaries Configuration](./glossaries.md)
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@translated/lara-cli",
"type": "module",
"version": "1.7.3",
"version": "1.8.0",
"description": "CLI tool for automated i18n file translation using Lara Translate",
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,13 +44,13 @@
"@babel/types": "^7.29.0",
"@inquirer/core": "^10.3.2",
"@inquirer/prompts": "^7.10.1",
"@translated/lara": "^1.18.0",
"@translated/lara": "^1.18.2",
"commander": "^14.0.3",
"dotenv": "^17.3.1",
"fast-xml-parser": "^5.5.9",
"flat": "^6.0.1",
"gettext-parser": "^8.0.0",
"glob": "^13.0.6",
"glob": "^14.0.2",
"ora": "^8.2.0",
"picomatch": "^4.0.4",
"proper-lockfile": "^4.1.2",
Expand Down Expand Up @@ -98,6 +98,7 @@
},
"pnpm": {
"overrides": {
"minimatch@>=7.0.0 <11.0.1": "^11.0.1",
"brace-expansion@<1.1.18": "^1.1.18",
"brace-expansion@>=5.0.0 <5.0.9": "^5.0.9",
"form-data@>=4.0.0 <4.0.6": ">=4.0.6",
Expand Down
47 changes: 27 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading