@the-i18n-kit/cli 4.9.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 +368 -0
- package/dist/_shared-Dv1EW2gy.js +248 -0
- package/dist/_shared-Dv1EW2gy.js.map +1 -0
- package/dist/add-BvXrJkqZ.js +40 -0
- package/dist/add-BvXrJkqZ.js.map +1 -0
- package/dist/bin-Cs-dvpEC.d.ts +1 -0
- package/dist/bin.js +11 -0
- package/dist/bin.js.map +1 -0
- package/dist/check-9dcNfHtC.js +49 -0
- package/dist/check-9dcNfHtC.js.map +1 -0
- package/dist/cli-CiX4llY1.js +82 -0
- package/dist/cli-CiX4llY1.js.map +1 -0
- package/dist/config/framework/stubs/next-intl-routing-DEwC7Bbk.d.ts +19 -0
- package/dist/config/framework/stubs/next-intl-routing-DEwC7Bbk.d.ts.map +1 -0
- package/dist/config/framework/stubs/next-intl-routing.js +22 -0
- package/dist/config/framework/stubs/next-intl-routing.js.map +1 -0
- package/dist/config/framework/stubs/unplugin-vue-i18n-D9yaDzRk.d.ts +25 -0
- package/dist/config/framework/stubs/unplugin-vue-i18n-D9yaDzRk.d.ts.map +1 -0
- package/dist/config/framework/stubs/unplugin-vue-i18n.js +26 -0
- package/dist/config/framework/stubs/unplugin-vue-i18n.js.map +1 -0
- package/dist/define-config-4ubtfvUy.js +14 -0
- package/dist/define-config-4ubtfvUy.js.map +1 -0
- package/dist/define-config-Dhg13592.d.ts +142 -0
- package/dist/define-config-Dhg13592.d.ts.map +1 -0
- package/dist/define-config-lQrIpPSK.d.ts +2 -0
- package/dist/define-config.d.ts +1 -0
- package/dist/define-config.js +2 -0
- package/dist/detect-Dr2skxeL.js +17 -0
- package/dist/detect-Dr2skxeL.js.map +1 -0
- package/dist/empty-p0wct8Hk.js +36 -0
- package/dist/empty-p0wct8Hk.js.map +1 -0
- package/dist/errors-coI1dhw1.js +33 -0
- package/dist/errors-coI1dhw1.js.map +1 -0
- package/dist/find-duplicates-DuI8niF7.js +31 -0
- package/dist/find-duplicates-DuI8niF7.js.map +1 -0
- package/dist/get-BskDC2wT.js +41 -0
- package/dist/get-BskDC2wT.js.map +1 -0
- package/dist/index-BtSA6-iT.d.ts +1130 -0
- package/dist/index-BtSA6-iT.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/init-D7r6iX3q.js +33 -0
- package/dist/init-D7r6iX3q.js.map +1 -0
- package/dist/list-dirs-BHk38JXZ.js +17 -0
- package/dist/list-dirs-BHk38JXZ.js.map +1 -0
- package/dist/missing-0gSZKTgt.js +51 -0
- package/dist/missing-0gSZKTgt.js.map +1 -0
- package/dist/operations-BCJd7in3.js +6464 -0
- package/dist/operations-BCJd7in3.js.map +1 -0
- package/dist/php-reader-DcgOAhTw.js +2 -0
- package/dist/php-reader-DuZ0Hyl_.js +32 -0
- package/dist/php-reader-DuZ0Hyl_.js.map +1 -0
- package/dist/providers-BAwPjeCy.js +482 -0
- package/dist/providers-BAwPjeCy.js.map +1 -0
- package/dist/remove-DR_mRiMA.js +41 -0
- package/dist/remove-DR_mRiMA.js.map +1 -0
- package/dist/remove-orphans-CcA3XQHJ.js +57 -0
- package/dist/remove-orphans-CcA3XQHJ.js.map +1 -0
- package/dist/rename-CWLfThC1.js +45 -0
- package/dist/rename-CWLfThC1.js.map +1 -0
- package/dist/scaffold-BahXKbo9.js +39 -0
- package/dist/scaffold-BahXKbo9.js.map +1 -0
- package/dist/scan-CTxs3kl7.js +31 -0
- package/dist/scan-CTxs3kl7.js.map +1 -0
- package/dist/search-BonEgmSt.js +49 -0
- package/dist/search-BonEgmSt.js.map +1 -0
- package/dist/status-C_5Khw14.js +45 -0
- package/dist/status-C_5Khw14.js.map +1 -0
- package/dist/stdout-guard-sJHFWVem.js +20 -0
- package/dist/stdout-guard-sJHFWVem.js.map +1 -0
- package/dist/translate-CnXvBi5O.js +92 -0
- package/dist/translate-CnXvBi5O.js.map +1 -0
- package/dist/translate-key-DwO9XZMc.js +73 -0
- package/dist/translate-key-DwO9XZMc.js.map +1 -0
- package/dist/update-HR8MvPlI.js +40 -0
- package/dist/update-HR8MvPlI.js.map +1 -0
- package/dist/write-CAD9xQDy.js +47 -0
- package/dist/write-CAD9xQDy.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { i as removeOrphanKeys } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/remove-orphans.ts
|
|
7
|
+
var remove_orphans_default = createCommand({
|
|
8
|
+
name: "remove-orphans",
|
|
9
|
+
description: "Find and remove orphan translation keys not referenced in source code",
|
|
10
|
+
args: {
|
|
11
|
+
layer: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Filter to a specific layer"
|
|
14
|
+
},
|
|
15
|
+
locale: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Locale to check (default: project default)"
|
|
18
|
+
},
|
|
19
|
+
dryRun: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
description: "Preview without removing (default: true)",
|
|
22
|
+
default: true
|
|
23
|
+
},
|
|
24
|
+
outputFile: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "Write full output to this file path and return only a summary (useful for large outputs)"
|
|
27
|
+
},
|
|
28
|
+
codequalityOutput: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Also write the orphan findings as a GitLab Code Quality (CodeClimate) JSON report to this file path"
|
|
31
|
+
},
|
|
32
|
+
failOnOrphans: {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
description: "Exit 2 when any orphan key is found (CI gate)",
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
gates: [{
|
|
39
|
+
flag: "failOnOrphans",
|
|
40
|
+
counter: "orphanCount",
|
|
41
|
+
threshold: 0
|
|
42
|
+
}],
|
|
43
|
+
async run(args) {
|
|
44
|
+
return removeOrphanKeys({
|
|
45
|
+
layer: args.layer,
|
|
46
|
+
locale: args.locale,
|
|
47
|
+
dryRun: args.dryRun,
|
|
48
|
+
projectDir: args.projectDir,
|
|
49
|
+
outputFile: args.outputFile,
|
|
50
|
+
codequalityOutput: args.codequalityOutput
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { remove_orphans_default as default };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=remove-orphans-CcA3XQHJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-orphans-CcA3XQHJ.js","names":[],"sources":["../src/commands/remove-orphans.ts"],"sourcesContent":["import { createCommand } from './_shared.js'\nimport { removeOrphanKeys } from '../core/operations.js'\n\nexport default createCommand({\n name: 'remove-orphans',\n description: 'Find and remove orphan translation keys not referenced in source code',\n args: {\n layer: { type: 'string', description: 'Filter to a specific layer' },\n locale: { type: 'string', description: 'Locale to check (default: project default)' },\n dryRun: { type: 'boolean', description: 'Preview without removing (default: true)', default: true },\n outputFile: { type: 'string', description: 'Write full output to this file path and return only a summary (useful for large outputs)' },\n codequalityOutput: { type: 'string', description: 'Also write the orphan findings as a GitLab Code Quality (CodeClimate) JSON report to this file path' },\n failOnOrphans: { type: 'boolean', description: 'Exit 2 when any orphan key is found (CI gate)', default: false },\n },\n gates: [{ flag: 'failOnOrphans', counter: 'orphanCount', threshold: 0 }],\n async run(args) {\n return removeOrphanKeys({\n layer: args.layer,\n locale: args.locale,\n dryRun: args.dryRun,\n projectDir: args.projectDir,\n outputFile: args.outputFile,\n codequalityOutput: args.codequalityOutput,\n })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,yBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAA8B;EACpE,QAAQ;GAAE,MAAM;GAAU,aAAa;GAA8C;EACrF,QAAQ;GAAE,MAAM;GAAW,aAAa;GAA4C,SAAS;GAAM;EACnG,YAAY;GAAE,MAAM;GAAU,aAAa;GAA4F;EACvI,mBAAmB;GAAE,MAAM;GAAU,aAAa;GAAuG;EACzJ,eAAe;GAAE,MAAM;GAAW,aAAa;GAAiD,SAAS;GAAO;EACjH;CACD,OAAO,CAAC;EAAE,MAAM;EAAiB,SAAS;EAAe,WAAW;EAAG,CAAC;CACxE,MAAM,IAAI,MAAM;AACd,SAAO,iBAAiB;GACtB,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,YAAY,KAAK;GACjB,YAAY,KAAK;GACjB,mBAAmB,KAAK;GACzB,CAAC;;CAEL,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { u as renameTranslationKey } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/rename.ts
|
|
7
|
+
var rename_default = createCommand({
|
|
8
|
+
name: "rename",
|
|
9
|
+
description: "Rename/move a translation key across all locale files",
|
|
10
|
+
args: {
|
|
11
|
+
layer: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Layer name",
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
oldKey: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "Current key path",
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
newKey: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "New key path",
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
dryRun: {
|
|
27
|
+
type: "boolean",
|
|
28
|
+
description: "Preview changes without writing",
|
|
29
|
+
default: false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
async run(args) {
|
|
33
|
+
return renameTranslationKey({
|
|
34
|
+
layer: args.layer,
|
|
35
|
+
oldKey: args.oldKey,
|
|
36
|
+
newKey: args.newKey,
|
|
37
|
+
dryRun: args.dryRun,
|
|
38
|
+
projectDir: args.projectDir
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
export { rename_default as default };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=rename-CWLfThC1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-CWLfThC1.js","names":[],"sources":["../src/commands/rename.ts"],"sourcesContent":["import { createCommand } from './_shared.js'\nimport { renameTranslationKey } from '../core/operations.js'\n\nexport default createCommand({\n name: 'rename',\n description: 'Rename/move a translation key across all locale files',\n args: {\n layer: { type: 'string', description: 'Layer name', required: true },\n oldKey: { type: 'string', description: 'Current key path', required: true },\n newKey: { type: 'string', description: 'New key path', required: true },\n dryRun: { type: 'boolean', description: 'Preview changes without writing', default: false },\n },\n async run(args) {\n return renameTranslationKey({\n layer: args.layer,\n oldKey: args.oldKey,\n newKey: args.newKey,\n dryRun: args.dryRun,\n projectDir: args.projectDir,\n })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,iBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAAc,UAAU;GAAM;EACpE,QAAQ;GAAE,MAAM;GAAU,aAAa;GAAoB,UAAU;GAAM;EAC3E,QAAQ;GAAE,MAAM;GAAU,aAAa;GAAgB,UAAU;GAAM;EACvE,QAAQ;GAAE,MAAM;GAAW,aAAa;GAAmC,SAAS;GAAO;EAC5F;CACD,MAAM,IAAI,MAAM;AACd,SAAO,qBAAqB;GAC1B,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,YAAY,KAAK;GAClB,CAAC;;CAEL,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { d as scaffoldLocaleFiles } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { o as splitList, t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/scaffold.ts
|
|
7
|
+
var scaffold_default = createCommand({
|
|
8
|
+
name: "scaffold",
|
|
9
|
+
description: "Create empty locale files for new languages",
|
|
10
|
+
args: {
|
|
11
|
+
locales: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Comma-separated locale codes to scaffold"
|
|
14
|
+
},
|
|
15
|
+
layer: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Filter to a specific layer"
|
|
18
|
+
},
|
|
19
|
+
dryRun: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
description: "Preview without writing",
|
|
22
|
+
default: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
async run(args) {
|
|
26
|
+
const locales = splitList(args.locales);
|
|
27
|
+
if (locales && locales.length === 0) throw new Error("No locales provided. Pass comma-separated locale codes via --locales");
|
|
28
|
+
return scaffoldLocaleFiles({
|
|
29
|
+
locales,
|
|
30
|
+
layer: args.layer,
|
|
31
|
+
dryRun: args.dryRun,
|
|
32
|
+
projectDir: args.projectDir
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { scaffold_default as default };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=scaffold-BahXKbo9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold-BahXKbo9.js","names":[],"sources":["../src/commands/scaffold.ts"],"sourcesContent":["import { createCommand, splitList } from './_shared.js'\nimport { scaffoldLocaleFiles } from '../core/operations.js'\n\nexport default createCommand({\n name: 'scaffold',\n description: 'Create empty locale files for new languages',\n args: {\n locales: { type: 'string', description: 'Comma-separated locale codes to scaffold' },\n layer: { type: 'string', description: 'Filter to a specific layer' },\n dryRun: { type: 'boolean', description: 'Preview without writing', default: false },\n },\n async run(args) {\n const locales = splitList(args.locales)\n if (locales && locales.length === 0) {\n throw new Error('No locales provided. Pass comma-separated locale codes via --locales')\n }\n return scaffoldLocaleFiles({ locales, layer: args.layer, dryRun: args.dryRun, projectDir: args.projectDir })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,mBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,SAAS;GAAE,MAAM;GAAU,aAAa;GAA4C;EACpF,OAAO;GAAE,MAAM;GAAU,aAAa;GAA8B;EACpE,QAAQ;GAAE,MAAM;GAAW,aAAa;GAA2B,SAAS;GAAO;EACpF;CACD,MAAM,IAAI,MAAM;EACd,MAAM,UAAU,UAAU,KAAK,QAAQ;AACvC,MAAI,WAAW,QAAQ,WAAW,EAChC,OAAM,IAAI,MAAM,uEAAuE;AAEzF,SAAO,oBAAoB;GAAE;GAAS,OAAO,KAAK;GAAO,QAAQ,KAAK;GAAQ,YAAY,KAAK;GAAY,CAAC;;CAE/G,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { a as scanCodeUsage } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { o as splitList, t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/scan.ts
|
|
7
|
+
var scan_default = createCommand({
|
|
8
|
+
name: "scan",
|
|
9
|
+
description: "Scan source code for translation key usage (file paths + line numbers)",
|
|
10
|
+
args: {
|
|
11
|
+
keys: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Comma-separated keys to filter by"
|
|
14
|
+
},
|
|
15
|
+
outputFile: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Write full output to file, return summary only"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async run(args) {
|
|
21
|
+
return scanCodeUsage({
|
|
22
|
+
keys: splitList(args.keys),
|
|
23
|
+
projectDir: args.projectDir,
|
|
24
|
+
outputFile: args.outputFile
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { scan_default as default };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=scan-CTxs3kl7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-CTxs3kl7.js","names":[],"sources":["../src/commands/scan.ts"],"sourcesContent":["import { createCommand, splitList } from './_shared.js'\nimport { scanCodeUsage } from '../core/operations.js'\n\nexport default createCommand({\n name: 'scan',\n description: 'Scan source code for translation key usage (file paths + line numbers)',\n args: {\n keys: { type: 'string', description: 'Comma-separated keys to filter by' },\n outputFile: { type: 'string', description: 'Write full output to file, return summary only' },\n },\n async run(args) {\n return scanCodeUsage({\n keys: splitList(args.keys),\n projectDir: args.projectDir,\n outputFile: args.outputFile,\n })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,eAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,MAAM;GAAE,MAAM;GAAU,aAAa;GAAqC;EAC1E,YAAY;GAAE,MAAM;GAAU,aAAa;GAAkD;EAC9F;CACD,MAAM,IAAI,MAAM;AACd,SAAO,cAAc;GACnB,MAAM,UAAU,KAAK,KAAK;GAC1B,YAAY,KAAK;GACjB,YAAY,KAAK;GAClB,CAAC;;CAEL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { b as searchTranslations } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/search.ts
|
|
7
|
+
var search_default = createCommand({
|
|
8
|
+
name: "search",
|
|
9
|
+
description: "Search translation files by key or value",
|
|
10
|
+
args: {
|
|
11
|
+
query: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Search query (matched case-insensitively against keys and values)",
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
in: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "Where to search: keys, values, or both",
|
|
19
|
+
default: "both"
|
|
20
|
+
},
|
|
21
|
+
layer: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Filter to a specific layer"
|
|
24
|
+
},
|
|
25
|
+
locale: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Filter to a specific locale"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
async run(args) {
|
|
31
|
+
const searchIn = [
|
|
32
|
+
"keys",
|
|
33
|
+
"values",
|
|
34
|
+
"both"
|
|
35
|
+
].includes(args.in) ? args.in : void 0;
|
|
36
|
+
if (args.in && !searchIn) throw new Error(`Invalid --in value: "${args.in}". Must be one of: keys, values, both`);
|
|
37
|
+
return searchTranslations({
|
|
38
|
+
query: args.query,
|
|
39
|
+
searchIn,
|
|
40
|
+
layer: args.layer,
|
|
41
|
+
locale: args.locale,
|
|
42
|
+
projectDir: args.projectDir
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { search_default as default };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=search-BonEgmSt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-BonEgmSt.js","names":[],"sources":["../src/commands/search.ts"],"sourcesContent":["import { createCommand } from './_shared.js'\nimport { searchTranslations } from '../core/operations.js'\n\nexport default createCommand({\n name: 'search',\n description: 'Search translation files by key or value',\n args: {\n query: { type: 'string', description: 'Search query (matched case-insensitively against keys and values)', required: true },\n in: { type: 'string', description: 'Where to search: keys, values, or both', default: 'both' },\n layer: { type: 'string', description: 'Filter to a specific layer' },\n locale: { type: 'string', description: 'Filter to a specific locale' },\n },\n async run(args) {\n const validSearchIn = ['keys', 'values', 'both'] as const\n const searchIn = validSearchIn.includes(args.in as typeof validSearchIn[number])\n ? (args.in as 'keys' | 'values' | 'both')\n : undefined\n if (args.in && !searchIn) {\n throw new Error(`Invalid --in value: \"${args.in}\". Must be one of: keys, values, both`)\n }\n return searchTranslations({\n query: args.query,\n searchIn,\n layer: args.layer,\n locale: args.locale,\n projectDir: args.projectDir,\n })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,iBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAAqE,UAAU;GAAM;EAC3H,IAAI;GAAE,MAAM;GAAU,aAAa;GAA0C,SAAS;GAAQ;EAC9F,OAAO;GAAE,MAAM;GAAU,aAAa;GAA8B;EACpE,QAAQ;GAAE,MAAM;GAAU,aAAa;GAA+B;EACvE;CACD,MAAM,IAAI,MAAM;EAEd,MAAM,WADgB;GAAC;GAAQ;GAAU;GAAO,CACjB,SAAS,KAAK,GAAmC,GAC3E,KAAK,KACN,KAAA;AACJ,MAAI,KAAK,MAAM,CAAC,SACd,OAAM,IAAI,MAAM,wBAAwB,KAAK,GAAG,uCAAuC;AAEzF,SAAO,mBAAmB;GACxB,OAAO,KAAK;GACZ;GACA,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,YAAY,KAAK;GAClB,CAAC;;CAEL,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { o as getTranslationStatus } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/status.ts
|
|
7
|
+
var status_default = createCommand({
|
|
8
|
+
name: "status",
|
|
9
|
+
description: "Translation coverage per locale and per layer, with an overall completion percentage",
|
|
10
|
+
args: {
|
|
11
|
+
layer: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Filter to a specific layer"
|
|
14
|
+
},
|
|
15
|
+
ref: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Reference locale (default: project default)"
|
|
18
|
+
},
|
|
19
|
+
outputFile: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Write the full breakdown to this file path and return only a summary"
|
|
22
|
+
},
|
|
23
|
+
failUnder: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Exit 2 when overall completion is below this percentage (CI gate)"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
gates: [{
|
|
29
|
+
flag: "failUnder",
|
|
30
|
+
counter: "completionPercent",
|
|
31
|
+
direction: "below"
|
|
32
|
+
}],
|
|
33
|
+
async run(args) {
|
|
34
|
+
return getTranslationStatus({
|
|
35
|
+
layer: args.layer,
|
|
36
|
+
referenceLocale: args.ref,
|
|
37
|
+
projectDir: args.projectDir,
|
|
38
|
+
outputFile: args.outputFile
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
export { status_default as default };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=status-C_5Khw14.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-C_5Khw14.js","names":[],"sources":["../src/commands/status.ts"],"sourcesContent":["import { createCommand } from './_shared.js'\nimport { getTranslationStatus } from '../core/operations.js'\n\nexport default createCommand({\n name: 'status',\n description: 'Translation coverage per locale and per layer, with an overall completion percentage',\n args: {\n layer: { type: 'string', description: 'Filter to a specific layer' },\n ref: { type: 'string', description: 'Reference locale (default: project default)' },\n outputFile: { type: 'string', description: 'Write the full breakdown to this file path and return only a summary' },\n failUnder: { type: 'string', description: 'Exit 2 when overall completion is below this percentage (CI gate)' },\n },\n // Threshold comes from the flag's own value; `direction: below` is what\n // makes this a floor rather than a ceiling (see resolveExitCode).\n gates: [{ flag: 'failUnder', counter: 'completionPercent', direction: 'below' }],\n async run(args) {\n return getTranslationStatus({\n layer: args.layer,\n referenceLocale: args.ref,\n projectDir: args.projectDir,\n outputFile: args.outputFile,\n })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,iBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAA8B;EACpE,KAAK;GAAE,MAAM;GAAU,aAAa;GAA+C;EACnF,YAAY;GAAE,MAAM;GAAU,aAAa;GAAwE;EACnH,WAAW;GAAE,MAAM;GAAU,aAAa;GAAqE;EAChH;CAGD,OAAO,CAAC;EAAE,MAAM;EAAa,SAAS;EAAqB,WAAW;EAAS,CAAC;CAChF,MAAM,IAAI,MAAM;AACd,SAAO,qBAAqB;GAC1B,OAAO,KAAK;GACZ,iBAAiB,KAAK;GACtB,YAAY,KAAK;GACjB,YAAY,KAAK;GAClB,CAAC;;CAEL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/utils/stdout-guard.ts
|
|
2
|
+
const realStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
3
|
+
/**
|
|
4
|
+
* Redirect all subsequent process.stdout writes to stderr. Third-party code
|
|
5
|
+
* loaded during config detection (e.g. Nuxt modules like nuxt-site-config)
|
|
6
|
+
* logs straight to stdout, which corrupts the machine-readable JSON output
|
|
7
|
+
* that CI pipes into jq. Command results still reach the real stdout via
|
|
8
|
+
* writeResult below.
|
|
9
|
+
*/
|
|
10
|
+
function guardStdout() {
|
|
11
|
+
process.stdout.write = ((...args) => process.stderr.write(...args));
|
|
12
|
+
}
|
|
13
|
+
/** Write to the real stdout, bypassing the guard. */
|
|
14
|
+
function writeResult(text) {
|
|
15
|
+
realStdoutWrite(text);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { writeResult as n, guardStdout as t };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=stdout-guard-sJHFWVem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdout-guard-sJHFWVem.js","names":[],"sources":["../src/utils/stdout-guard.ts"],"sourcesContent":["const realStdoutWrite = process.stdout.write.bind(process.stdout)\n\n/**\n * Redirect all subsequent process.stdout writes to stderr. Third-party code\n * loaded during config detection (e.g. Nuxt modules like nuxt-site-config)\n * logs straight to stdout, which corrupts the machine-readable JSON output\n * that CI pipes into jq. Command results still reach the real stdout via\n * writeResult below.\n */\nexport function guardStdout(): void {\n process.stdout.write = ((...args: Parameters<typeof process.stdout.write>) =>\n process.stderr.write(...args)) as typeof process.stdout.write\n}\n\n/** Write to the real stdout, bypassing the guard. */\nexport function writeResult(text: string): void {\n realStdoutWrite(text)\n}\n"],"mappings":";AAAA,MAAM,kBAAkB,QAAQ,OAAO,MAAM,KAAK,QAAQ,OAAO;;;;;;;;AASjE,SAAgB,cAAoB;AAClC,SAAQ,OAAO,UAAU,GAAG,SAC1B,QAAQ,OAAO,MAAM,GAAG,KAAK;;;AAIjC,SAAgB,YAAY,MAAoB;AAC9C,iBAAgB,KAAK"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { C as translateMissing } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { a as resolveProviderTranslateFn, i as providerArgs, o as splitList, t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/translate.ts
|
|
7
|
+
/**
|
|
8
|
+
* Locales that lost at least one key, sorted for a stable message.
|
|
9
|
+
* A bare `totalFailed: 141` says nothing about which languages shipped
|
|
10
|
+
* incomplete — this is what makes the count actionable in a CI log.
|
|
11
|
+
* Reads the full and the compact shapes, since either may reach here.
|
|
12
|
+
*/
|
|
13
|
+
function localesWithFailures(result) {
|
|
14
|
+
const perLayer = "layers" in result ? Object.values(result.layers) : [result];
|
|
15
|
+
const locales = /* @__PURE__ */ new Set();
|
|
16
|
+
for (const layer of perLayer) {
|
|
17
|
+
for (const [locale, entry] of Object.entries(layer.results ?? {})) if (entry.failed.length > 0) locales.add(locale);
|
|
18
|
+
for (const entry of layer.summary.byLocale ?? []) if (entry.failed > 0) locales.add(entry.locale);
|
|
19
|
+
}
|
|
20
|
+
return [...locales].sort();
|
|
21
|
+
}
|
|
22
|
+
var translate_default = createCommand({
|
|
23
|
+
name: "translate",
|
|
24
|
+
description: "Find missing translations and translate them via LLM. Requires --provider and --model for auto-translation.",
|
|
25
|
+
args: {
|
|
26
|
+
layer: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Layer name (default: all locale-backed layers, aggregated)"
|
|
29
|
+
},
|
|
30
|
+
ref: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Reference locale (default: project default)"
|
|
33
|
+
},
|
|
34
|
+
targets: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Comma-separated target locales (default: all except ref)"
|
|
37
|
+
},
|
|
38
|
+
keys: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Comma-separated keys to translate (default: all missing)"
|
|
41
|
+
},
|
|
42
|
+
batchSize: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "Batch size (default: 50)"
|
|
45
|
+
},
|
|
46
|
+
...providerArgs,
|
|
47
|
+
dryRun: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
description: "Preview what would be translated",
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
failOnFailed: {
|
|
53
|
+
type: "boolean",
|
|
54
|
+
description: "Exit 2 when any key failed to translate (CI gate)",
|
|
55
|
+
default: false
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
gates: [{
|
|
59
|
+
flag: "failOnFailed",
|
|
60
|
+
counter: "totalFailed",
|
|
61
|
+
threshold: 0
|
|
62
|
+
}],
|
|
63
|
+
async run(args) {
|
|
64
|
+
let batchSize;
|
|
65
|
+
if (args.batchSize) {
|
|
66
|
+
const num = Number(args.batchSize);
|
|
67
|
+
if (!Number.isInteger(num) || num <= 0 || String(num) !== args.batchSize) throw new Error(`Invalid --batchSize: "${args.batchSize}". Must be a positive integer`);
|
|
68
|
+
batchSize = num;
|
|
69
|
+
}
|
|
70
|
+
const translateFn = await resolveProviderTranslateFn(args);
|
|
71
|
+
const result = await translateMissing({
|
|
72
|
+
layer: args.layer,
|
|
73
|
+
referenceLocale: args.ref,
|
|
74
|
+
targetLocales: splitList(args.targets),
|
|
75
|
+
keys: splitList(args.keys),
|
|
76
|
+
batchSize,
|
|
77
|
+
dryRun: args.dryRun,
|
|
78
|
+
projectDir: args.projectDir,
|
|
79
|
+
translateFn
|
|
80
|
+
});
|
|
81
|
+
if (result.summary.mode === "agent") result.summary.message = "No provider configured — nothing was translated. Pass --provider and --model (API key via --apiKey or the OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY env vars) to translate automatically.";
|
|
82
|
+
else if (result.summary.totalFailed > 0) {
|
|
83
|
+
const affected = localesWithFailures(result);
|
|
84
|
+
result.summary.message = `${result.summary.totalFailed} key(s) failed to translate` + (affected.length > 0 ? ` (locales: ${affected.join(", ")})` : "") + ". Those keys remain missing — re-run to retry them. Pass --fail-on-failed to make this exit 2 in CI.";
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//#endregion
|
|
90
|
+
export { translate_default as default };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=translate-CnXvBi5O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate-CnXvBi5O.js","names":[],"sources":["../src/commands/translate.ts"],"sourcesContent":["import { createCommand, splitList, providerArgs, resolveProviderTranslateFn } from './_shared.js'\nimport { translateMissing } from '../core/operations.js'\nimport type { TranslateMissingOutcome, TranslateMissingResult } from '../core/types.js'\n\n/**\n * Locales that lost at least one key, sorted for a stable message.\n * A bare `totalFailed: 141` says nothing about which languages shipped\n * incomplete — this is what makes the count actionable in a CI log.\n * Reads the full and the compact shapes, since either may reach here.\n */\nexport function localesWithFailures(result: TranslateMissingOutcome): string[] {\n const perLayer: TranslateMissingResult[] = 'layers' in result\n ? Object.values(result.layers)\n : [result]\n\n const locales = new Set<string>()\n for (const layer of perLayer) {\n for (const [locale, entry] of Object.entries(layer.results ?? {})) {\n if (entry.failed.length > 0) locales.add(locale)\n }\n for (const entry of layer.summary.byLocale ?? []) {\n if (entry.failed > 0) locales.add(entry.locale)\n }\n }\n return [...locales].sort()\n}\n\nexport default createCommand({\n name: 'translate',\n description: 'Find missing translations and translate them via LLM. Requires --provider and --model for auto-translation.',\n args: {\n layer: { type: 'string', description: 'Layer name (default: all locale-backed layers, aggregated)' },\n ref: { type: 'string', description: 'Reference locale (default: project default)' },\n targets: { type: 'string', description: 'Comma-separated target locales (default: all except ref)' },\n keys: { type: 'string', description: 'Comma-separated keys to translate (default: all missing)' },\n batchSize: { type: 'string', description: 'Batch size (default: 50)' },\n ...providerArgs,\n dryRun: { type: 'boolean', description: 'Preview what would be translated', default: false },\n failOnFailed: { type: 'boolean', description: 'Exit 2 when any key failed to translate (CI gate)', default: false },\n },\n // Without this gate a partly failed run is indistinguishable from a clean one:\n // isTotalFailure only reports exit 1 when NOTHING was translated, so a run that\n // wrote 795 keys and lost 141 exits 0 and its partial result gets committed.\n // Opt-in rather than default, because providers fail transiently and a red\n // pipeline on every flake is a red pipeline nobody reads.\n gates: [{ flag: 'failOnFailed', counter: 'totalFailed', threshold: 0 }],\n async run(args) {\n let batchSize: number | undefined\n if (args.batchSize) {\n const num = Number(args.batchSize)\n if (!Number.isInteger(num) || num <= 0 || String(num) !== args.batchSize) {\n throw new Error(`Invalid --batchSize: \"${args.batchSize}\". Must be a positive integer`)\n }\n batchSize = num\n }\n\n const translateFn = await resolveProviderTranslateFn(args)\n\n const result = await translateMissing({\n layer: args.layer,\n referenceLocale: args.ref,\n targetLocales: splitList(args.targets),\n keys: splitList(args.keys),\n batchSize,\n dryRun: args.dryRun,\n projectDir: args.projectDir,\n translateFn,\n })\n\n // CLI-owned guidance: agent mode here just means no provider was given.\n // Single-layer and all-layers results both carry summary.mode, so this\n // needs no narrowing.\n if (result.summary.mode === 'agent') {\n result.summary.message = 'No provider configured — nothing was translated. Pass --provider and --model '\n + '(API key via --apiKey or the OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY env vars) '\n + 'to translate automatically.'\n } else if (result.summary.totalFailed > 0) {\n // A partial failure exits 0 unless --fail-on-failed was passed, so without\n // this the only trace of it is a count nobody reads. Re-running is the\n // fix: the keys are still missing, so the next run retries them.\n const affected = localesWithFailures(result)\n result.summary.message = `${result.summary.totalFailed} key(s) failed to translate`\n + (affected.length > 0 ? ` (locales: ${affected.join(', ')})` : '')\n + '. Those keys remain missing — re-run to retry them. '\n + 'Pass --fail-on-failed to make this exit 2 in CI.'\n }\n return result\n },\n})\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,oBAAoB,QAA2C;CAC7E,MAAM,WAAqC,YAAY,SACnD,OAAO,OAAO,OAAO,OAAO,GAC5B,CAAC,OAAO;CAEZ,MAAM,0BAAU,IAAI,KAAa;AACjC,MAAK,MAAM,SAAS,UAAU;AAC5B,OAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,MAAM,WAAW,EAAE,CAAC,CAC/D,KAAI,MAAM,OAAO,SAAS,EAAG,SAAQ,IAAI,OAAO;AAElD,OAAK,MAAM,SAAS,MAAM,QAAQ,YAAY,EAAE,CAC9C,KAAI,MAAM,SAAS,EAAG,SAAQ,IAAI,MAAM,OAAO;;AAGnD,QAAO,CAAC,GAAG,QAAQ,CAAC,MAAM;;AAG5B,IAAA,oBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAA8D;EACpG,KAAK;GAAE,MAAM;GAAU,aAAa;GAA+C;EACnF,SAAS;GAAE,MAAM;GAAU,aAAa;GAA4D;EACpG,MAAM;GAAE,MAAM;GAAU,aAAa;GAA4D;EACjG,WAAW;GAAE,MAAM;GAAU,aAAa;GAA4B;EACtE,GAAG;EACH,QAAQ;GAAE,MAAM;GAAW,aAAa;GAAoC,SAAS;GAAO;EAC5F,cAAc;GAAE,MAAM;GAAW,aAAa;GAAqD,SAAS;GAAO;EACpH;CAMD,OAAO,CAAC;EAAE,MAAM;EAAgB,SAAS;EAAe,WAAW;EAAG,CAAC;CACvE,MAAM,IAAI,MAAM;EACd,IAAI;AACJ,MAAI,KAAK,WAAW;GAClB,MAAM,MAAM,OAAO,KAAK,UAAU;AAClC,OAAI,CAAC,OAAO,UAAU,IAAI,IAAI,OAAO,KAAK,OAAO,IAAI,KAAK,KAAK,UAC7D,OAAM,IAAI,MAAM,yBAAyB,KAAK,UAAU,+BAA+B;AAEzF,eAAY;;EAGd,MAAM,cAAc,MAAM,2BAA2B,KAAK;EAE1D,MAAM,SAAS,MAAM,iBAAiB;GACpC,OAAO,KAAK;GACZ,iBAAiB,KAAK;GACtB,eAAe,UAAU,KAAK,QAAQ;GACtC,MAAM,UAAU,KAAK,KAAK;GAC1B;GACA,QAAQ,KAAK;GACb,YAAY,KAAK;GACjB;GACD,CAAC;AAKF,MAAI,OAAO,QAAQ,SAAS,QAC1B,QAAO,QAAQ,UAAU;WAGhB,OAAO,QAAQ,cAAc,GAAG;GAIzC,MAAM,WAAW,oBAAoB,OAAO;AAC5C,UAAO,QAAQ,UAAU,GAAG,OAAO,QAAQ,YAAY,gCAClD,SAAS,SAAS,IAAI,cAAc,SAAS,KAAK,KAAK,CAAC,KAAK,MAC9D;;AAGN,SAAO;;CAEV,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { S as translateKey } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { a as resolveProviderTranslateFn, i as providerArgs, o as splitList, t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/translate-key.ts
|
|
7
|
+
var translate_key_default = createCommand({
|
|
8
|
+
name: "translate-key",
|
|
9
|
+
description: "Translate a single key from a source locale into target locales. Supports LLM translation with --provider.",
|
|
10
|
+
args: {
|
|
11
|
+
layer: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Layer name",
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
key: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "Dot-separated translation key",
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
sourceLocale: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Source locale code/language/file",
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
sourceValue: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Optional source value to write before translating"
|
|
29
|
+
},
|
|
30
|
+
targets: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Comma-separated target locales, or \"all\"/omitted for all except source"
|
|
33
|
+
},
|
|
34
|
+
overwrite: {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
description: "Overwrite existing target translations (default true)",
|
|
37
|
+
default: true
|
|
38
|
+
},
|
|
39
|
+
dryRun: {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
description: "Preview without writing or translating",
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
includePreview: {
|
|
45
|
+
type: "boolean",
|
|
46
|
+
description: "Include translated values in output",
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
...providerArgs
|
|
50
|
+
},
|
|
51
|
+
async run(args) {
|
|
52
|
+
const targetLocales = args.targets === "all" ? "all" : splitList(args.targets);
|
|
53
|
+
const translateFn = await resolveProviderTranslateFn(args);
|
|
54
|
+
const result = await translateKey({
|
|
55
|
+
layer: args.layer,
|
|
56
|
+
key: args.key,
|
|
57
|
+
sourceLocale: args.sourceLocale,
|
|
58
|
+
sourceValue: args.sourceValue,
|
|
59
|
+
targetLocales,
|
|
60
|
+
overwrite: args.overwrite,
|
|
61
|
+
dryRun: args.dryRun,
|
|
62
|
+
includePreview: args.includePreview,
|
|
63
|
+
projectDir: args.projectDir,
|
|
64
|
+
translateFn
|
|
65
|
+
});
|
|
66
|
+
if (result.mode === "agent" && result.skipped.some((s) => s.reason === "no-provider")) result.message = "No provider configured — nothing was translated. Pass --provider and --model (API key via --apiKey or the OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY env vars) to translate automatically.";
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//#endregion
|
|
71
|
+
export { translate_key_default as default };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=translate-key-DwO9XZMc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate-key-DwO9XZMc.js","names":[],"sources":["../src/commands/translate-key.ts"],"sourcesContent":["import { createCommand, splitList, providerArgs, resolveProviderTranslateFn } from './_shared.js'\nimport { translateKey } from '../core/operations.js'\n\nexport default createCommand({\n name: 'translate-key',\n description: 'Translate a single key from a source locale into target locales. Supports LLM translation with --provider.',\n args: {\n layer: { type: 'string', description: 'Layer name', required: true },\n key: { type: 'string', description: 'Dot-separated translation key', required: true },\n sourceLocale: { type: 'string', description: 'Source locale code/language/file', required: true },\n sourceValue: { type: 'string', description: 'Optional source value to write before translating' },\n targets: { type: 'string', description: 'Comma-separated target locales, or \"all\"/omitted for all except source' },\n overwrite: { type: 'boolean', description: 'Overwrite existing target translations (default true)', default: true },\n dryRun: { type: 'boolean', description: 'Preview without writing or translating', default: false },\n includePreview: { type: 'boolean', description: 'Include translated values in output', default: false },\n ...providerArgs,\n },\n async run(args) {\n const targetLocales = args.targets === 'all' ? 'all' : splitList(args.targets)\n\n const translateFn = await resolveProviderTranslateFn(args)\n\n const result = await translateKey({\n layer: args.layer,\n key: args.key,\n sourceLocale: args.sourceLocale,\n sourceValue: args.sourceValue,\n targetLocales,\n overwrite: args.overwrite,\n dryRun: args.dryRun,\n includePreview: args.includePreview,\n projectDir: args.projectDir,\n translateFn,\n })\n\n // CLI-owned guidance: agent mode here just means no provider was given\n if (result.mode === 'agent' && result.skipped.some(s => s.reason === 'no-provider')) {\n result.message = 'No provider configured — nothing was translated. Pass --provider and --model '\n + '(API key via --apiKey or the OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY env vars) '\n + 'to translate automatically.'\n }\n return result\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,wBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAAc,UAAU;GAAM;EACpE,KAAK;GAAE,MAAM;GAAU,aAAa;GAAiC,UAAU;GAAM;EACrF,cAAc;GAAE,MAAM;GAAU,aAAa;GAAoC,UAAU;GAAM;EACjG,aAAa;GAAE,MAAM;GAAU,aAAa;GAAqD;EACjG,SAAS;GAAE,MAAM;GAAU,aAAa;GAA0E;EAClH,WAAW;GAAE,MAAM;GAAW,aAAa;GAAyD,SAAS;GAAM;EACnH,QAAQ;GAAE,MAAM;GAAW,aAAa;GAA0C,SAAS;GAAO;EAClG,gBAAgB;GAAE,MAAM;GAAW,aAAa;GAAuC,SAAS;GAAO;EACvG,GAAG;EACJ;CACD,MAAM,IAAI,MAAM;EACd,MAAM,gBAAgB,KAAK,YAAY,QAAQ,QAAQ,UAAU,KAAK,QAAQ;EAE9E,MAAM,cAAc,MAAM,2BAA2B,KAAK;EAE1D,MAAM,SAAS,MAAM,aAAa;GAChC,OAAO,KAAK;GACZ,KAAK,KAAK;GACV,cAAc,KAAK;GACnB,aAAa,KAAK;GAClB;GACA,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,gBAAgB,KAAK;GACrB,YAAY,KAAK;GACjB;GACD,CAAC;AAGF,MAAI,OAAO,SAAS,WAAW,OAAO,QAAQ,MAAK,MAAK,EAAE,WAAW,cAAc,CACjF,QAAO,UAAU;AAInB,SAAO;;CAEV,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { f as updateTranslations } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { r as parseJsonArg, t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/update.ts
|
|
7
|
+
var update_default = createCommand({
|
|
8
|
+
name: "update",
|
|
9
|
+
description: "Update existing translation keys (skips keys that do not exist)",
|
|
10
|
+
args: {
|
|
11
|
+
layer: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Layer name",
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
translations: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "JSON: { \"key\": { \"en\": \"val\", \"de\": \"val\" } }",
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
dryRun: {
|
|
22
|
+
type: "boolean",
|
|
23
|
+
description: "Preview changes without writing",
|
|
24
|
+
default: false
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
async run(args) {
|
|
28
|
+
const translations = parseJsonArg(args.translations, "translations");
|
|
29
|
+
return updateTranslations({
|
|
30
|
+
layer: args.layer,
|
|
31
|
+
translations,
|
|
32
|
+
dryRun: args.dryRun,
|
|
33
|
+
projectDir: args.projectDir
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { update_default as default };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=update-HR8MvPlI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-HR8MvPlI.js","names":[],"sources":["../src/commands/update.ts"],"sourcesContent":["import { createCommand, parseJsonArg } from './_shared.js'\nimport { updateTranslations } from '../core/operations.js'\n\nexport default createCommand({\n name: 'update',\n description: 'Update existing translation keys (skips keys that do not exist)',\n args: {\n layer: { type: 'string', description: 'Layer name', required: true },\n translations: { type: 'string', description: 'JSON: { \"key\": { \"en\": \"val\", \"de\": \"val\" } }', required: true },\n dryRun: { type: 'boolean', description: 'Preview changes without writing', default: false },\n },\n async run(args) {\n const translations = parseJsonArg<Record<string, Record<string, string>>>(args.translations, 'translations')\n return updateTranslations({ layer: args.layer, translations, dryRun: args.dryRun, projectDir: args.projectDir })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,iBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAAc,UAAU;GAAM;EACpE,cAAc;GAAE,MAAM;GAAU,aAAa;GAAiD,UAAU;GAAM;EAC9G,QAAQ;GAAE,MAAM;GAAW,aAAa;GAAmC,SAAS;GAAO;EAC5F;CACD,MAAM,IAAI,MAAM;EACd,MAAM,eAAe,aAAqD,KAAK,cAAc,eAAe;AAC5G,SAAO,mBAAmB;GAAE,OAAO,KAAK;GAAO;GAAc,QAAQ,KAAK;GAAQ,YAAY,KAAK;GAAY,CAAC;;CAEnH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "./stdout-guard-sJHFWVem.js";
|
|
2
|
+
import { p as writeTranslations } from "./operations-BCJd7in3.js";
|
|
3
|
+
import "./providers-BAwPjeCy.js";
|
|
4
|
+
import "./php-reader-DuZ0Hyl_.js";
|
|
5
|
+
import { r as parseJsonArg, t as createCommand } from "./_shared-Dv1EW2gy.js";
|
|
6
|
+
//#region src/commands/write.ts
|
|
7
|
+
var write_default = createCommand({
|
|
8
|
+
name: "write",
|
|
9
|
+
description: "Write translation keys (add/update/upsert). Default mode: upsert.",
|
|
10
|
+
args: {
|
|
11
|
+
layer: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Layer name",
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
translations: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "JSON: { \"key\": { \"en\": \"val\", \"de\": \"val\" } }",
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
mode: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Write mode: add | update | upsert (default: upsert)",
|
|
24
|
+
default: "upsert"
|
|
25
|
+
},
|
|
26
|
+
dryRun: {
|
|
27
|
+
type: "boolean",
|
|
28
|
+
description: "Preview changes without writing",
|
|
29
|
+
default: false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
async run(args) {
|
|
33
|
+
const translations = parseJsonArg(args.translations, "translations");
|
|
34
|
+
const mode = args.mode;
|
|
35
|
+
return writeTranslations({
|
|
36
|
+
layer: args.layer,
|
|
37
|
+
translations,
|
|
38
|
+
mode,
|
|
39
|
+
dryRun: args.dryRun,
|
|
40
|
+
projectDir: args.projectDir
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
export { write_default as default };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=write-CAD9xQDy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-CAD9xQDy.js","names":[],"sources":["../src/commands/write.ts"],"sourcesContent":["import { createCommand, parseJsonArg } from './_shared.js'\nimport { writeTranslations } from '../core/operations.js'\n\nexport default createCommand({\n name: 'write',\n description: 'Write translation keys (add/update/upsert). Default mode: upsert.',\n args: {\n layer: { type: 'string', description: 'Layer name', required: true },\n translations: { type: 'string', description: 'JSON: { \"key\": { \"en\": \"val\", \"de\": \"val\" } }', required: true },\n mode: { type: 'string', description: 'Write mode: add | update | upsert (default: upsert)', default: 'upsert' },\n dryRun: { type: 'boolean', description: 'Preview changes without writing', default: false },\n },\n async run(args) {\n const translations = parseJsonArg<Record<string, Record<string, string>>>(args.translations, 'translations')\n const mode = args.mode as 'add' | 'update' | 'upsert'\n return writeTranslations({ layer: args.layer, translations, mode, dryRun: args.dryRun, projectDir: args.projectDir })\n },\n})\n"],"mappings":";;;;;;AAGA,IAAA,gBAAe,cAAc;CAC3B,MAAM;CACN,aAAa;CACb,MAAM;EACJ,OAAO;GAAE,MAAM;GAAU,aAAa;GAAc,UAAU;GAAM;EACpE,cAAc;GAAE,MAAM;GAAU,aAAa;GAAiD,UAAU;GAAM;EAC9G,MAAM;GAAE,MAAM;GAAU,aAAa;GAAuD,SAAS;GAAU;EAC/G,QAAQ;GAAE,MAAM;GAAW,aAAa;GAAmC,SAAS;GAAO;EAC5F;CACD,MAAM,IAAI,MAAM;EACd,MAAM,eAAe,aAAqD,KAAK,cAAc,eAAe;EAC5G,MAAM,OAAO,KAAK;AAClB,SAAO,kBAAkB;GAAE,OAAO,KAAK;GAAO;GAAc;GAAM,QAAQ,KAAK;GAAQ,YAAY,KAAK;GAAY,CAAC;;CAExH,CAAC"}
|