@ai-translate/cli 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,10 +7,10 @@ See the [project README](../../README.md) for what the toolkit does and how a sy
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install --save-dev @ai-translate/cli
10
+ npx ai-translate init
11
11
  ```
12
12
 
13
- Requires Node 20.19 or newer.
13
+ Automatic setup with the default provider requires Node 22 or newer. The CLI itself supports Node 20.19 or newer.
14
14
 
15
15
  ## Configuration
16
16
 
@@ -56,25 +56,46 @@ This is how a provider API key normally reaches your config, for example `apiKey
56
56
 
57
57
  ### `init`
58
58
 
59
- Detects the project's Next.js localization setup and writes `ai-translate.config.ts` for it. This is the only command that runs without an existing config.
59
+ Detects the project's localization resources, writes its config, and installs the required dependencies using the project's npm, pnpm, Yarn, or Bun. Adds missing translation scripts, `.env.example`, and ignore entries for local secrets and `node_modules`. Swift-only projects get a private tooling manifest. This command runs without an existing config.
60
60
 
61
61
  ```bash
62
62
  ai-translate init
63
63
  ai-translate init --preview
64
64
  ai-translate init --integration i18next
65
+ ai-translate init --locale fr --locale pl
66
+ ai-translate init --no-install
67
+ ai-translate init --package-manager pnpm
65
68
  ```
66
69
 
67
- Recognises **next-intl** and **i18next** (including `react-i18next` and `next-i18next`), inferring the message layout, the locale list, and the source locale, then printing the evidence behind each conclusion.
70
+ Recognises **next-intl**, **i18next** (including Expo/React Native projects using `react-i18next`), **Expo native locale mappings**, and **Apple localization** (`.xcstrings` catalogs and `.lproj/*.strings` tables). Detection infers source and target languages from resources and Xcode settings and prints the evidence behind each conclusion. Independent setups with the same source language become one configuration, retaining each catalog's message format. Overlapping detections or conflicting source locales require an explicit `--integration` choice.
68
71
 
69
- It writes exactly one file and nothing else. Installing packages, setting `OPENAI_API_KEY`, and reviewing the model choice are printed as next steps rather than done for you, so running it against an unfamiliar repository is safe.
72
+ For an Xcode or Apple Swift package project without resources, `init` writes a starter config with explicit extraction instructions. Create and populate a String Catalog with Xcode, then configure your target languages. `init` does not extract hardcoded Swift, JavaScript, or Rust text and never invents target languages. Expo and Tauri projects without localization resources must externalize their text first.
73
+
74
+ Native configs use explicit file includes; an empty starter uses `include: []`.
75
+ After creating or repairing resources, review `init --preview` and update the
76
+ includes. Detection partitions mixed Base/source tables, reports neighboring
77
+ projects with different source languages, and excludes generated native output.
78
+
79
+ Custom detectors use the platform-neutral `@ai-translate/integrations` interfaces. Adapter plans declare the package, factory export, and literal options, so adding a platform does not require changing the CLI's config renderer. `@ai-translate/next` retains its existing detection APIs for compatibility.
80
+
81
+ `--preview` shows the full plan without writes or network calls. `--no-install` creates setup files and prints the remaining install command. Installation disables lifecycle scripts. Required `@ai-translate/*` registry packages are refreshed to `@latest` so older adapters cannot silently ignore new config options. Existing runtime, development, and optional dependency categories are preserved. Unrelated dependency versions and scripts are preserved; custom workspace, file, link, Git, and alias sources are kept with a notice. Declared dependencies are installed even in a fresh clone. A failed install keeps setup files so the command can be retried. Identical configs can be resumed; replacing a changed config requires `--force`. All supported config extensions are protected.
82
+
83
+ After installation, init loads the generated config and validates source resources without making translation requests. Missing target translations are expected at this stage.
84
+
85
+ The CLI never invents credentials or target languages. Set the provider key in your shell or `.env.local`, and use repeated `--locale` options if languages cannot be inferred. It does not start paid translation calls during setup. Unknown package managers and ambiguous lockfiles require `--package-manager`; workspace package managers are inherited.
86
+
87
+ Expo detection reads committed `expo.locales` mappings in `app.json` or a static exported `app.config.ts` / `.js` object. Computed config is not executed. Shared i18next UI and native metadata can be translated in the same configuration.
70
88
 
71
89
  | Flag | Effect |
72
90
  | --- | --- |
73
- | `--preview` | Print the config that would be written and touch nothing. |
91
+ | `--preview` | Show the complete setup plan without writes or installation. |
74
92
  | `--integration <id>` | Choose between setups when a project matches more than one. |
75
- | `--force` | Overwrite an existing `ai-translate.config.ts`. Refuses without it. |
93
+ | `--force` | Replace a changed existing config, preserving its filename. |
94
+ | `--locale <locale>` | Set a target locale; repeat for multiple languages. |
95
+ | `--package-manager <name>` | Select npm, pnpm, yarn, or bun explicitly. |
96
+ | `--no-install` | Prepare setup files and print the dependency install command. |
76
97
 
77
- Exits non-zero when nothing is recognised, when a named integration was not detected, or when a config already exists and `--force` was not passed.
98
+ Exits non-zero when nothing is recognised, when a named integration was not detected, when a changed config exists without `--force`, or when installation or source validation fails.
78
99
 
79
100
  ### `sync`
80
101
 
@@ -88,6 +109,10 @@ ai-translate sync --locale de --catalog messages
88
109
 
89
110
  Writes happen inside a staged transaction: files and state are committed together only if the run converges, so an interrupted or failing sync leaves your content untouched. When semantic audits reject a translation, the run retries it up to `validation.semanticRepairAttempts` times before failing.
90
111
 
112
+ Before committing, the CLI verifies that live files still match the snapshots it
113
+ staged. If a developer or Xcode saved a file during translation, the run aborts
114
+ without replacing those edits. Rerun to translate from the updated resources.
115
+
91
116
  Exits non-zero if any entry failed, if audits did not converge, or if a `--dry-run` exceeded the configured `validation.dryRunBudget`.
92
117
 
93
118
  ### `check`
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as runCli } from "./src-Cnnq284f.mjs";
2
+ import { n as runCli } from "./src-SwBEpdIU.mjs";
3
3
  //#region src/bin.ts
4
4
  const exitCode = await runCli();
5
5
  process.exit(exitCode);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/index.ts"],"mappings":";;;wBA4BgB,eAAe,aAAa;wBAiBtB,aAAa,cAAc,QAAQ;wBA+BnC,WACpB,aACA,wBACC;EAAU,QAAQ;EAAmB;;;;wBCkflB,OACpB,0BACA,eACC"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/index.ts"],"mappings":";;;wBA4BgB,eAAe,aAAa;wBAiBtB,aAAa,cAAc,QAAQ;wBA+BnC,WACpB,aACA,wBACC;EAAU,QAAQ;EAAmB;;;;wBCqgBlB,OACpB,0BACA,eACC"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as loadEnvFiles, i as loadConfig, n as runCli, r as findConfigPath, t as defineConfig } from "./src-Cnnq284f.mjs";
1
+ import { a as loadEnvFiles, i as loadConfig, n as runCli, r as findConfigPath, t as defineConfig } from "./src-SwBEpdIU.mjs";
2
2
  export { defineConfig, findConfigPath, loadConfig, loadEnvFiles, runCli };