@ai-translate/cli 0.3.0 → 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 +20 -9
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-Bb6vfpFm.mjs → src-SwBEpdIU.mjs} +542 -55
- package/dist/src-SwBEpdIU.mjs.map +1 -0
- package/package.json +5 -5
- package/dist/src-Bb6vfpFm.mjs.map +0 -1
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
|
-
|
|
10
|
+
npx ai-translate init
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
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,16 +56,18 @@ 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 localization resources and
|
|
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 --
|
|
65
|
+
ai-translate init --locale fr --locale pl
|
|
66
|
+
ai-translate init --no-install
|
|
67
|
+
ai-translate init --package-manager pnpm
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
Recognises **next-intl**, **i18next** (including Expo/React Native projects using `react-i18next`), 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.
|
|
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.
|
|
69
71
|
|
|
70
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.
|
|
71
73
|
|
|
@@ -76,15 +78,24 @@ projects with different source languages, and excludes generated native output.
|
|
|
76
78
|
|
|
77
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.
|
|
78
80
|
|
|
79
|
-
|
|
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.
|
|
80
88
|
|
|
81
89
|
| Flag | Effect |
|
|
82
90
|
| --- | --- |
|
|
83
|
-
| `--preview` |
|
|
91
|
+
| `--preview` | Show the complete setup plan without writes or installation. |
|
|
84
92
|
| `--integration <id>` | Choose between setups when a project matches more than one. |
|
|
85
|
-
| `--force` |
|
|
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. |
|
|
86
97
|
|
|
87
|
-
Exits non-zero when nothing is recognised, when a named integration was not detected,
|
|
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.
|
|
88
99
|
|
|
89
100
|
### `sync`
|
|
90
101
|
|
package/dist/bin.mjs
CHANGED
package/dist/index.d.mts.map
CHANGED
|
@@ -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;;;;
|
|
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-
|
|
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 };
|