@scoutello/i18n-magic 0.24.1 → 0.25.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/dist/cli.js +18 -23
- package/dist/cli.js.map +1 -1
- package/dist/commands/check-missing.d.ts +1 -1
- package/dist/commands/check-missing.d.ts.map +1 -1
- package/dist/commands/check-missing.js +3 -7
- package/dist/commands/check-missing.js.map +1 -1
- package/dist/commands/clean.d.ts +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +6 -10
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/replace.d.ts +1 -1
- package/dist/commands/replace.d.ts.map +1 -1
- package/dist/commands/replace.js +11 -15
- package/dist/commands/replace.js.map +1 -1
- package/dist/commands/scan.d.ts +1 -1
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +11 -15
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/sync-locales.d.ts +1 -1
- package/dist/commands/sync-locales.d.ts.map +1 -1
- package/dist/commands/sync-locales.js +11 -15
- package/dist/commands/sync-locales.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/languges.js +1 -4
- package/dist/lib/languges.js.map +1 -1
- package/dist/lib/types.js +1 -2
- package/dist/lib/utils.d.ts +4 -4
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +51 -69
- package/dist/lib/utils.js.map +1 -1
- package/package.json +5 -4
- package/src/cli.ts +7 -7
- package/src/commands/check-missing.ts +2 -2
- package/src/commands/clean.ts +2 -2
- package/src/commands/replace.ts +2 -2
- package/src/commands/scan.ts +3 -3
- package/src/commands/sync-locales.ts +2 -2
- package/src/index.ts +7 -7
- package/src/lib/utils.ts +7 -5
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const replace_1 = require("./commands/replace");
|
|
13
|
-
const scan_1 = require("./commands/scan");
|
|
14
|
-
const sync_locales_1 = require("./commands/sync-locales");
|
|
15
|
-
const utils_1 = require("./lib/utils");
|
|
16
|
-
const program = new commander_1.Command();
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import OpenAI from "openai";
|
|
5
|
+
import { checkMissing } from "./commands/check-missing.js";
|
|
6
|
+
import { removeUnusedKeys } from "./commands/clean.js";
|
|
7
|
+
import { replaceTranslation } from "./commands/replace.js";
|
|
8
|
+
import { translateMissing } from "./commands/scan.js";
|
|
9
|
+
import { syncLocales } from "./commands/sync-locales.js";
|
|
10
|
+
import { loadConfig } from "./lib/utils.js";
|
|
11
|
+
const program = new Command();
|
|
17
12
|
program
|
|
18
13
|
.name("i18n-magic")
|
|
19
14
|
.description("CLI to help you manage your locales JSON with translations, replacements, etc. with OpenAI.")
|
|
@@ -24,27 +19,27 @@ const commands = [
|
|
|
24
19
|
{
|
|
25
20
|
name: "scan",
|
|
26
21
|
description: "Scan for missing translations, get prompted for each, translate it to the other locales and save it to the JSON file.",
|
|
27
|
-
action:
|
|
22
|
+
action: translateMissing,
|
|
28
23
|
},
|
|
29
24
|
{
|
|
30
25
|
name: "replace",
|
|
31
26
|
description: "Replace a translation based on the key, and translate it to the other locales and save it to the JSON file.",
|
|
32
|
-
action:
|
|
27
|
+
action: replaceTranslation,
|
|
33
28
|
},
|
|
34
29
|
{
|
|
35
30
|
name: "check-missing",
|
|
36
31
|
description: "Check if there are any missing translations. Useful for a CI/CD pipeline or husky hook.",
|
|
37
|
-
action:
|
|
32
|
+
action: checkMissing,
|
|
38
33
|
},
|
|
39
34
|
{
|
|
40
35
|
name: "sync",
|
|
41
36
|
description: "Sync the translations from the default locale to the other locales. Useful for a CI/CD pipeline or husky hook.",
|
|
42
|
-
action:
|
|
37
|
+
action: syncLocales,
|
|
43
38
|
},
|
|
44
39
|
{
|
|
45
40
|
name: "clean",
|
|
46
41
|
description: "Remove unused translations from all locales. Useful for a CI/CD pipeline or husky hook.",
|
|
47
|
-
action:
|
|
42
|
+
action: removeUnusedKeys,
|
|
48
43
|
},
|
|
49
44
|
];
|
|
50
45
|
for (const command of commands) {
|
|
@@ -57,10 +52,10 @@ for (const command of commands) {
|
|
|
57
52
|
.argument("[key]", "translation key to replace");
|
|
58
53
|
}
|
|
59
54
|
cmd.action(async (arg, options) => {
|
|
60
|
-
const res =
|
|
55
|
+
const res = dotenv.config({
|
|
61
56
|
path: program.opts().env || ".env",
|
|
62
57
|
});
|
|
63
|
-
const config = await
|
|
58
|
+
const config = await loadConfig({
|
|
64
59
|
configPath: program.opts().config,
|
|
65
60
|
});
|
|
66
61
|
const isGemini = config.model?.includes("gemini");
|
|
@@ -74,7 +69,7 @@ for (const command of commands) {
|
|
|
74
69
|
console.error(`Please provide a${isGemini ? " Gemini" : "n OpenAI"} API key in your .env file or config, called ${keyType}.`);
|
|
75
70
|
process.exit(1);
|
|
76
71
|
}
|
|
77
|
-
const openai = new
|
|
72
|
+
const openai = new OpenAI({
|
|
78
73
|
apiKey: key,
|
|
79
74
|
...(isGemini && {
|
|
80
75
|
baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/",
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,YAAY,E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GAAG;YACX,GAAG,CAAC,QAAQ,IAAI;gBACd,OAAO,EAAE,0DAA0D;aACpE,CAAC;SACH,CAAC,CAAA;QAEF,2DAA2D;QAC3D,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,4DAA4D;YAC5D,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAA;YAC5D,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-missing.d.ts","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"check-missing.d.ts","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,YAAY,GAAU,QAAQ,aAAa,kBAOvD,CAAA"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("../lib/utils");
|
|
5
|
-
const checkMissing = async (config) => {
|
|
6
|
-
const newKeys = await (0, utils_1.getMissingKeys)(config);
|
|
1
|
+
import { getMissingKeys } from "../lib/utils.js";
|
|
2
|
+
export const checkMissing = async (config) => {
|
|
3
|
+
const newKeys = await getMissingKeys(config);
|
|
7
4
|
if (newKeys.length > 0) {
|
|
8
5
|
console.error("Error: Missing translations found!");
|
|
9
6
|
process.exit(1);
|
|
10
7
|
}
|
|
11
8
|
};
|
|
12
|
-
exports.checkMissing = checkMissing;
|
|
13
9
|
//# sourceMappingURL=check-missing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-missing.js","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check-missing.js","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAA"}
|
package/dist/commands/clean.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAQpD,eAAO,MAAM,gBAAgB,GAAU,QAAQ,aAAa,kBAsF3D,CAAA"}
|
package/dist/commands/clean.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.removeUnusedKeys = void 0;
|
|
4
|
-
const utils_1 = require("../lib/utils");
|
|
5
|
-
const removeUnusedKeys = async (config) => {
|
|
1
|
+
import { getKeysWithNamespaces, getPureKey, loadLocalesFile, writeLocalesFile, } from "../lib/utils.js";
|
|
2
|
+
export const removeUnusedKeys = async (config) => {
|
|
6
3
|
const { globPatterns, namespaces, defaultNamespace, locales, loadPath, savePath, } = config;
|
|
7
4
|
// Get all keys with their associated namespaces from the codebase
|
|
8
|
-
const keysWithNamespaces = await
|
|
5
|
+
const keysWithNamespaces = await getKeysWithNamespaces({
|
|
9
6
|
globPatterns,
|
|
10
7
|
defaultNamespace,
|
|
11
8
|
});
|
|
@@ -21,7 +18,7 @@ const removeUnusedKeys = async (config) => {
|
|
|
21
18
|
if (!keysByNamespace[namespace]) {
|
|
22
19
|
keysByNamespace[namespace] = new Set();
|
|
23
20
|
}
|
|
24
|
-
const pureKey =
|
|
21
|
+
const pureKey = getPureKey(key, namespace, namespace === defaultNamespace);
|
|
25
22
|
if (pureKey) {
|
|
26
23
|
keysByNamespace[namespace].add(pureKey);
|
|
27
24
|
}
|
|
@@ -33,7 +30,7 @@ const removeUnusedKeys = async (config) => {
|
|
|
33
30
|
// Process each locale
|
|
34
31
|
for (const locale of locales) {
|
|
35
32
|
// Load existing keys for this locale and namespace
|
|
36
|
-
const existingKeys = await
|
|
33
|
+
const existingKeys = await loadLocalesFile(loadPath, locale, namespace);
|
|
37
34
|
const existingKeysCount = Object.keys(existingKeys).length;
|
|
38
35
|
stats.total += existingKeysCount;
|
|
39
36
|
// Create a new object with only the keys that are used
|
|
@@ -50,7 +47,7 @@ const removeUnusedKeys = async (config) => {
|
|
|
50
47
|
stats.removed += removedCount;
|
|
51
48
|
// Only write the file if keys were removed
|
|
52
49
|
if (removedCount > 0) {
|
|
53
|
-
await
|
|
50
|
+
await writeLocalesFile(savePath, locale, namespace, cleanedKeys);
|
|
54
51
|
console.log(`✓ Removed ${removedCount} unused keys from ${locale}:${namespace} (${Object.keys(cleanedKeys).length} keys remaining)`);
|
|
55
52
|
}
|
|
56
53
|
else {
|
|
@@ -65,5 +62,4 @@ const removeUnusedKeys = async (config) => {
|
|
|
65
62
|
console.log(`✅ No unused keys found in the project (${stats.total} total keys)`);
|
|
66
63
|
}
|
|
67
64
|
};
|
|
68
|
-
exports.removeUnusedKeys = removeUnusedKeys;
|
|
69
65
|
//# sourceMappingURL=clean.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC9D,MAAM,EACJ,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAA;IAEV,kEAAkE;IAClE,MAAM,kBAAkB,GAAG,MAAM,qBAAqB,CAAC;QACrD,YAAY;QACZ,gBAAgB;KACjB,CAAC,CAAA;IAEF,4BAA4B;IAC5B,MAAM,KAAK,GAAG;QACZ,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;KACX,CAAA;IAED,0BAA0B;IAC1B,MAAM,eAAe,GAAgC,EAAE,CAAA;IAEvD,KAAK,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,kBAAkB,EAAE,CAAC;QACpE,KAAK,MAAM,SAAS,IAAI,aAAa,EAAE,CAAC;YACtC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;gBAChC,eAAe,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,EAAE,CAAA;YACxC,CAAC;YAED,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,KAAK,g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,IAAI,CAAC,WAAW,CAAC,CAAC,MAC3B,kBAAkB,CACnB,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,2BAA2B,MAAM,IAAI,SAAS,EAAE,CAAC,CAAA;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,aAAa,KAAK,CAAC,OAAO,wBAAwB,KAAK,CAAC,KAAK,cAAc,CAC5E,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CACT,0CAA0C,KAAK,CAAC,KAAK,cAAc,CACpE,CAAA;IACH,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/commands/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/commands/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AA6BpD,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,aAAa,EACrB,MAAM,MAAM,kBAqHb,CAAA"}
|
package/dist/commands/replace.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceTranslation = void 0;
|
|
4
|
-
const utils_1 = require("../lib/utils");
|
|
1
|
+
import { getKeysWithNamespaces, getPureKey, getTextInput, loadLocalesFile, translateKey, writeLocalesFile, } from "../lib/utils.js";
|
|
5
2
|
const getKeyToReplace = async (allAvailableKeys) => {
|
|
6
|
-
const keyToReplace = await
|
|
3
|
+
const keyToReplace = await getTextInput("Enter the key to replace the translation for: ");
|
|
7
4
|
if (!allAvailableKeys[keyToReplace]) {
|
|
8
5
|
console.log(`The key "${keyToReplace}" does not exist.`);
|
|
9
6
|
return await getKeyToReplace(allAvailableKeys);
|
|
@@ -12,17 +9,17 @@ const getKeyToReplace = async (allAvailableKeys) => {
|
|
|
12
9
|
console.log(`The key "${keyToReplace}" exists in namespaces: ${namespaces.join(", ")}.`);
|
|
13
10
|
return { key: keyToReplace, namespaces };
|
|
14
11
|
};
|
|
15
|
-
const replaceTranslation = async (config, key) => {
|
|
12
|
+
export const replaceTranslation = async (config, key) => {
|
|
16
13
|
const { loadPath, savePath, defaultLocale, defaultNamespace, namespaces, locales, globPatterns, context, openai, } = config;
|
|
17
14
|
// Find all keys with their namespaces from the codebase
|
|
18
|
-
const keysWithNamespaces = await
|
|
15
|
+
const keysWithNamespaces = await getKeysWithNamespaces({
|
|
19
16
|
globPatterns,
|
|
20
17
|
defaultNamespace,
|
|
21
18
|
});
|
|
22
19
|
// Build a map of all available keys across all namespaces
|
|
23
20
|
const allAvailableKeys = {};
|
|
24
21
|
for (const namespace of namespaces) {
|
|
25
|
-
const keys = await
|
|
22
|
+
const keys = await loadLocalesFile(loadPath, defaultLocale, namespace);
|
|
26
23
|
for (const [keyName, value] of Object.entries(keys)) {
|
|
27
24
|
if (!allAvailableKeys[keyName]) {
|
|
28
25
|
allAvailableKeys[keyName] = [];
|
|
@@ -37,7 +34,7 @@ const replaceTranslation = async (config, key) => {
|
|
|
37
34
|
keyToReplace = key;
|
|
38
35
|
// Determine which namespaces this key should be updated in based on usage
|
|
39
36
|
const keyUsage = keysWithNamespaces.filter((k) => {
|
|
40
|
-
const pureKey =
|
|
37
|
+
const pureKey = getPureKey(k.key, defaultNamespace, true);
|
|
41
38
|
return pureKey === key || k.key === key;
|
|
42
39
|
});
|
|
43
40
|
if (keyUsage.length > 0) {
|
|
@@ -68,12 +65,12 @@ const replaceTranslation = async (config, key) => {
|
|
|
68
65
|
}
|
|
69
66
|
// Show current translations across namespaces
|
|
70
67
|
for (const namespace of targetNamespaces) {
|
|
71
|
-
const keys = await
|
|
68
|
+
const keys = await loadLocalesFile(loadPath, defaultLocale, namespace);
|
|
72
69
|
if (keys[keyToReplace]) {
|
|
73
70
|
console.log(`Current translation in ${defaultLocale} (${namespace}): "${keys[keyToReplace]}"`);
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
|
-
const newTranslation = await
|
|
73
|
+
const newTranslation = await getTextInput("Enter the new translation: ");
|
|
77
74
|
// Update the key in all relevant namespaces and locales
|
|
78
75
|
for (const namespace of targetNamespaces) {
|
|
79
76
|
for (const locale of locales) {
|
|
@@ -82,7 +79,7 @@ const replaceTranslation = async (config, key) => {
|
|
|
82
79
|
newValue = newTranslation;
|
|
83
80
|
}
|
|
84
81
|
else {
|
|
85
|
-
const translation = await
|
|
82
|
+
const translation = await translateKey({
|
|
86
83
|
context,
|
|
87
84
|
inputLanguage: defaultLocale,
|
|
88
85
|
outputLanguage: locale,
|
|
@@ -94,12 +91,11 @@ const replaceTranslation = async (config, key) => {
|
|
|
94
91
|
});
|
|
95
92
|
newValue = translation[keyToReplace];
|
|
96
93
|
}
|
|
97
|
-
const existingKeys = await
|
|
94
|
+
const existingKeys = await loadLocalesFile(loadPath, locale, namespace);
|
|
98
95
|
existingKeys[keyToReplace] = newValue;
|
|
99
|
-
await
|
|
96
|
+
await writeLocalesFile(savePath, locale, namespace, existingKeys);
|
|
100
97
|
console.log(`Updated "${keyToReplace}" in ${locale} (${namespace}): "${newValue}"`);
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
100
|
};
|
|
104
|
-
exports.replaceTranslation = replaceTranslation;
|
|
105
101
|
//# sourceMappingURL=replace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../../src/commands/replace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../../src/commands/replace.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,YAA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oBACrC,OAAO;oBACP,aAAa,EAAE,aAAa;oBAC5B,cAAc,EAAE,MAAM;oBACtB,MAAM,EAAE;wBACN,CAAC,YAAY,CAAC,EAAE,cAAc;qBAC/B;oBACD,MAAM;oBACN,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAC,CAAA;gBAEF,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC,CAAA;YACtC,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;YACvE,YAAY,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAA;YACrC,MAAM,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,CAAA;YAEjE,OAAO,CAAC,GAAG,CACT,YAAY,YAAY,QAAQ,MAAM,KAAK,SAAS,OAAO,QAAQ,GAAG,CACvE,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/dist/commands/scan.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAWpD,eAAO,MAAM,gBAAgB,GAAU,QAAQ,aAAa,kBA8F3D,CAAA"}
|
package/dist/commands/scan.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("../lib/utils");
|
|
5
|
-
const clean_1 = require("./clean");
|
|
6
|
-
const translateMissing = async (config) => {
|
|
1
|
+
import { checkAllKeysExist, getMissingKeys, getTextInput, loadLocalesFile, translateKey, writeLocalesFile, } from "../lib/utils.js";
|
|
2
|
+
import { removeUnusedKeys } from "./clean.js";
|
|
3
|
+
export const translateMissing = async (config) => {
|
|
7
4
|
const { loadPath, savePath, defaultLocale, namespaces, locales, context, openai, disableTranslation, autoClear, } = config;
|
|
8
5
|
// Run clean command first if autoClear is enabled
|
|
9
6
|
if (autoClear) {
|
|
10
7
|
console.log("🧹 Auto-clearing unused translations before scanning...");
|
|
11
|
-
await
|
|
8
|
+
await removeUnusedKeys(config);
|
|
12
9
|
console.log("✅ Auto-clear completed. Now scanning for missing translations...\n");
|
|
13
10
|
}
|
|
14
|
-
const newKeys = await
|
|
11
|
+
const newKeys = await getMissingKeys(config);
|
|
15
12
|
if (newKeys.length === 0) {
|
|
16
13
|
console.log("No new keys found.");
|
|
17
|
-
await
|
|
14
|
+
await checkAllKeysExist(config);
|
|
18
15
|
return;
|
|
19
16
|
}
|
|
20
17
|
console.log(`${newKeys.length} keys are missing. Please provide the values for the following keys in ${defaultLocale}:`);
|
|
21
18
|
const newKeysWithDefaultLocale = [];
|
|
22
19
|
for (const newKey of newKeys) {
|
|
23
|
-
const answer = await
|
|
20
|
+
const answer = await getTextInput(newKey.key);
|
|
24
21
|
newKeysWithDefaultLocale.push({
|
|
25
22
|
key: newKey.key,
|
|
26
23
|
namespace: newKey.namespace,
|
|
@@ -38,7 +35,7 @@ const translateMissing = async (config) => {
|
|
|
38
35
|
translatedValues = newKeysObject;
|
|
39
36
|
}
|
|
40
37
|
else {
|
|
41
|
-
translatedValues = await
|
|
38
|
+
translatedValues = await translateKey({
|
|
42
39
|
inputLanguage: defaultLocale,
|
|
43
40
|
outputLanguage: locale,
|
|
44
41
|
context,
|
|
@@ -48,7 +45,7 @@ const translateMissing = async (config) => {
|
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
for (const namespace of namespaces) {
|
|
51
|
-
const existingKeys = await
|
|
48
|
+
const existingKeys = await loadLocalesFile(loadPath, locale, namespace);
|
|
52
49
|
const relevantKeys = newKeysWithDefaultLocale.filter((key) => key.namespace === namespace);
|
|
53
50
|
if (relevantKeys.length === 0) {
|
|
54
51
|
continue;
|
|
@@ -56,11 +53,10 @@ const translateMissing = async (config) => {
|
|
|
56
53
|
for (const key of relevantKeys) {
|
|
57
54
|
existingKeys[key.key] = translatedValues[key.key];
|
|
58
55
|
}
|
|
59
|
-
|
|
56
|
+
writeLocalesFile(savePath, locale, namespace, existingKeys);
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
|
-
await
|
|
59
|
+
await checkAllKeysExist(config);
|
|
63
60
|
console.log(`Successfully translated ${newKeys.length} keys.`);
|
|
64
61
|
};
|
|
65
|
-
exports.translateMissing = translateMissing;
|
|
66
62
|
//# sourceMappingURL=scan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC9D,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,UAAU,EACV,OAAO,EACP,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,SAAS,GACV,GAAG,MAAM,CAAA;IAEV,kDAAkD;IAClD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAA;QACtE,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC9B,OAAO,CAAC,GAAG,CACT,oEAAoE,CACrE,CAAA;IACH,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,cAAc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aAAa;gBACrB,MAAM;gBACN,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;YAEvE,MAAM,YAAY,GAAG,wBAAwB,CAAC,MAAM,CAClD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,CACrC,CAAA;YAED,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9B,SAAQ;YACV,CAAC;YAED,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;gBAC/B,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnD,CAAC;YAED,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAED,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAE/B,OAAO,CAAC,GAAG,CAAC,2BAA2B,OAAO,CAAC,MAAM,QAAQ,CAAC,CAAA;AAChE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-locales.d.ts","sourceRoot":"","sources":["../../src/commands/sync-locales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sync-locales.d.ts","sourceRoot":"","sources":["../../src/commands/sync-locales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAQpD,eAAO,MAAM,WAAW,GAAU,QAAQ,aAAa,kBAwHtD,CAAA"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.syncLocales = void 0;
|
|
4
|
-
const utils_1 = require("../lib/utils");
|
|
5
|
-
const syncLocales = async (config) => {
|
|
1
|
+
import { TranslationError, loadLocalesFile, translateKey, writeLocalesFile, } from "../lib/utils.js";
|
|
2
|
+
export const syncLocales = async (config) => {
|
|
6
3
|
const { loadPath, savePath, defaultLocale, namespaces, locales, context, openai, } = config;
|
|
7
4
|
try {
|
|
8
5
|
for (const namespace of namespaces) {
|
|
9
6
|
let defaultLocaleKeys;
|
|
10
7
|
try {
|
|
11
|
-
defaultLocaleKeys = await
|
|
8
|
+
defaultLocaleKeys = await loadLocalesFile(loadPath, defaultLocale, namespace);
|
|
12
9
|
}
|
|
13
10
|
catch (error) {
|
|
14
|
-
throw new
|
|
11
|
+
throw new TranslationError(`Failed to load default locale file for namespace "${namespace}"`, defaultLocale, namespace, error instanceof Error ? error : undefined);
|
|
15
12
|
}
|
|
16
13
|
for (const locale of locales) {
|
|
17
14
|
if (locale === defaultLocale)
|
|
18
15
|
continue;
|
|
19
16
|
let localeKeys;
|
|
20
17
|
try {
|
|
21
|
-
localeKeys = await
|
|
18
|
+
localeKeys = await loadLocalesFile(loadPath, locale, namespace);
|
|
22
19
|
}
|
|
23
20
|
catch (error) {
|
|
24
21
|
console.warn(`Warning: Could not load locale file for ${locale} (namespace: ${namespace}). Creating new file.`);
|
|
@@ -36,7 +33,7 @@ const syncLocales = async (config) => {
|
|
|
36
33
|
console.log(`Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`);
|
|
37
34
|
let translatedValues;
|
|
38
35
|
try {
|
|
39
|
-
translatedValues = await
|
|
36
|
+
translatedValues = await translateKey({
|
|
40
37
|
inputLanguage: defaultLocale,
|
|
41
38
|
outputLanguage: locale,
|
|
42
39
|
context,
|
|
@@ -46,7 +43,7 @@ const syncLocales = async (config) => {
|
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
45
|
catch (error) {
|
|
49
|
-
throw new
|
|
46
|
+
throw new TranslationError(`Failed to translate keys for locale "${locale}" (namespace: ${namespace})`, locale, namespace, error instanceof Error ? error : undefined);
|
|
50
47
|
}
|
|
51
48
|
// Merge translated values with existing ones
|
|
52
49
|
const updatedLocaleKeys = {
|
|
@@ -54,10 +51,10 @@ const syncLocales = async (config) => {
|
|
|
54
51
|
...translatedValues,
|
|
55
52
|
};
|
|
56
53
|
try {
|
|
57
|
-
await
|
|
54
|
+
await writeLocalesFile(savePath, locale, namespace, updatedLocaleKeys);
|
|
58
55
|
}
|
|
59
56
|
catch (error) {
|
|
60
|
-
throw new
|
|
57
|
+
throw new TranslationError(`Failed to save translations for locale "${locale}" (namespace: ${namespace})`, locale, namespace, error instanceof Error ? error : undefined);
|
|
61
58
|
}
|
|
62
59
|
console.log(`Successfully translated and saved ${Object.keys(missingKeys).length} keys for ${locale} (namespace: ${namespace})`);
|
|
63
60
|
}
|
|
@@ -68,11 +65,10 @@ const syncLocales = async (config) => {
|
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
catch (error) {
|
|
71
|
-
if (error instanceof
|
|
68
|
+
if (error instanceof TranslationError) {
|
|
72
69
|
throw error;
|
|
73
70
|
}
|
|
74
|
-
throw new
|
|
71
|
+
throw new TranslationError("An unexpected error occurred during translation", undefined, undefined, error instanceof Error ? error : undefined);
|
|
75
72
|
}
|
|
76
73
|
};
|
|
77
|
-
exports.syncLocales = syncLocales;
|
|
78
74
|
//# sourceMappingURL=sync-locales.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-locales.js","sourceRoot":"","sources":["../../src/commands/sync-locales.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-locales.js","sourceRoot":"","sources":["../../src/commands/sync-locales.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,MAAqB,EAA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A;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,GAAG,CACT,6BAA6B,MAAM,gBAAgB,SAAS,GAAG,CAChE,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YACtC,MAAM,KAAK,CAAA;QACb,CAAC;QACD,MAAM,IAAI,gBAAgB,CACxB,iDAAiD,EACjD,SAAS,EACT,SAAS,EACT,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAA;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { checkMissing } from "./commands/check-missing";
|
|
2
|
-
export { removeUnusedKeys } from "./commands/clean";
|
|
3
|
-
export { replaceTranslation } from "./commands/replace";
|
|
4
|
-
export { translateMissing } from "./commands/scan";
|
|
5
|
-
export { syncLocales } from "./commands/sync-locales";
|
|
6
|
-
export { loadConfig } from "./lib/utils";
|
|
7
|
-
export type { CommandType, Configuration, GlobPatternConfig, } from "./lib/types";
|
|
1
|
+
export { checkMissing } from "./commands/check-missing.js";
|
|
2
|
+
export { removeUnusedKeys } from "./commands/clean.js";
|
|
3
|
+
export { replaceTranslation } from "./commands/replace.js";
|
|
4
|
+
export { translateMissing } from "./commands/scan.js";
|
|
5
|
+
export { syncLocales } from "./commands/sync-locales.js";
|
|
6
|
+
export { loadConfig } from "./lib/utils.js";
|
|
7
|
+
export type { CommandType, Configuration, GlobPatternConfig, } from "./lib/types.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAI3C,YAAY,EACV,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadConfig = exports.syncLocales = exports.translateMissing = exports.replaceTranslation = exports.removeUnusedKeys = exports.checkMissing = void 0;
|
|
4
1
|
// Export command functions for programmatic usage
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "replaceTranslation", { enumerable: true, get: function () { return replace_1.replaceTranslation; } });
|
|
11
|
-
var scan_1 = require("./commands/scan");
|
|
12
|
-
Object.defineProperty(exports, "translateMissing", { enumerable: true, get: function () { return scan_1.translateMissing; } });
|
|
13
|
-
var sync_locales_1 = require("./commands/sync-locales");
|
|
14
|
-
Object.defineProperty(exports, "syncLocales", { enumerable: true, get: function () { return sync_locales_1.syncLocales; } });
|
|
2
|
+
export { checkMissing } from "./commands/check-missing.js";
|
|
3
|
+
export { removeUnusedKeys } from "./commands/clean.js";
|
|
4
|
+
export { replaceTranslation } from "./commands/replace.js";
|
|
5
|
+
export { translateMissing } from "./commands/scan.js";
|
|
6
|
+
export { syncLocales } from "./commands/sync-locales.js";
|
|
15
7
|
// Export utility functions
|
|
16
|
-
|
|
17
|
-
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return utils_1.loadConfig; } });
|
|
8
|
+
export { loadConfig } from "./lib/utils.js";
|
|
18
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,2BAA2B;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/lib/languges.js
CHANGED
package/dist/lib/languges.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"languges.js","sourceRoot":"","sources":["../../src/lib/languges.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"languges.js","sourceRoot":"","sources":["../../src/lib/languges.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;QACE,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,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AE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,IAAI;KACZ;CACF,CAAA"}
|
package/dist/lib/types.js
CHANGED
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type OpenAI from "openai";
|
|
2
|
-
import type { Configuration, GlobPatternConfig } from "./types";
|
|
3
|
-
export declare const loadConfig: ({ configPath, }
|
|
4
|
-
configPath
|
|
5
|
-
}) => any
|
|
2
|
+
import type { Configuration, GlobPatternConfig } from "./types.js";
|
|
3
|
+
export declare const loadConfig: ({ configPath, }?: {
|
|
4
|
+
configPath?: string;
|
|
5
|
+
}) => Promise<any>;
|
|
6
6
|
export declare function removeDuplicatesFromArray<T>(arr: T[]): T[];
|
|
7
7
|
export declare const translateKey: ({ inputLanguage, context, object, openai, outputLanguage, model, }: {
|
|
8
8
|
object: Record<string, string>;
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAGhC,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAGhC,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAElE,eAAO,MAAM,UAAU,GAAU,kBAE9B;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,iBAkB9B,CAAA;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE1D;AAED,eAAO,MAAM,YAAY,GAAU,oEAOhC;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,oCAyDA,CAAA;AAED,eAAO,MAAM,eAAe,GAC1B,UACI,MAAM,GACN,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAC5E,QAAQ,MAAM,EACd,WAAW,MAAM,oCA4BlB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,UACI,MAAM,GACN,CAAC,CACC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,M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AHpB,OAAO,EAAE,MAAM,EACR,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,KAAK;CAKvB"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
14
|
-
const languges_1 = require("./languges");
|
|
15
|
-
const loadConfig = ({ configPath = "i18n-magic.js", }) => {
|
|
16
|
-
const filePath = node_path_1.default.join(process.cwd(), configPath);
|
|
17
|
-
if (!node_fs_1.default.existsSync(filePath)) {
|
|
1
|
+
import glob from "fast-glob";
|
|
2
|
+
import { Parser } from "i18next-scanner";
|
|
3
|
+
import { minimatch } from "minimatch";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import prompts from "prompts";
|
|
7
|
+
import { languages } from "./languges.js";
|
|
8
|
+
export const loadConfig = async ({ configPath = "i18n-magic.js", } = {}) => {
|
|
9
|
+
const filePath = path.join(process.cwd(), configPath);
|
|
10
|
+
if (!fs.existsSync(filePath)) {
|
|
18
11
|
console.error("Config file does not exist:", filePath);
|
|
19
12
|
process.exit(1);
|
|
20
13
|
}
|
|
21
14
|
try {
|
|
22
|
-
|
|
15
|
+
// Use dynamic import for ESM compatibility
|
|
16
|
+
const configModule = await import(`file://${filePath}`);
|
|
17
|
+
const config = configModule.default || configModule;
|
|
23
18
|
// Validate config if needed
|
|
24
19
|
return config;
|
|
25
20
|
}
|
|
@@ -28,11 +23,10 @@ const loadConfig = ({ configPath = "i18n-magic.js", }) => {
|
|
|
28
23
|
process.exit(1);
|
|
29
24
|
}
|
|
30
25
|
};
|
|
31
|
-
|
|
32
|
-
function removeDuplicatesFromArray(arr) {
|
|
26
|
+
export function removeDuplicatesFromArray(arr) {
|
|
33
27
|
return arr.filter((item, index) => arr.indexOf(item) === index);
|
|
34
28
|
}
|
|
35
|
-
const translateKey = async ({ inputLanguage, context, object, openai, outputLanguage, model, }) => {
|
|
29
|
+
export const translateKey = async ({ inputLanguage, context, object, openai, outputLanguage, model, }) => {
|
|
36
30
|
// Split object into chunks of 100 keys
|
|
37
31
|
const entries = Object.entries(object);
|
|
38
32
|
const chunks = [];
|
|
@@ -40,8 +34,8 @@ const translateKey = async ({ inputLanguage, context, object, openai, outputLang
|
|
|
40
34
|
chunks.push(entries.slice(i, i + 100));
|
|
41
35
|
}
|
|
42
36
|
let result = {};
|
|
43
|
-
const existingInput =
|
|
44
|
-
const existingOutput =
|
|
37
|
+
const existingInput = languages.find((l) => l.value === inputLanguage);
|
|
38
|
+
const existingOutput = languages.find((l) => l.value === outputLanguage);
|
|
45
39
|
const input = existingInput?.label || inputLanguage;
|
|
46
40
|
const output = existingOutput?.label || outputLanguage;
|
|
47
41
|
// Translate each chunk
|
|
@@ -77,18 +71,17 @@ const translateKey = async ({ inputLanguage, context, object, openai, outputLang
|
|
|
77
71
|
}
|
|
78
72
|
return result;
|
|
79
73
|
};
|
|
80
|
-
|
|
81
|
-
const loadLocalesFile = async (loadPath, locale, namespace) => {
|
|
74
|
+
export const loadLocalesFile = async (loadPath, locale, namespace) => {
|
|
82
75
|
if (typeof loadPath === "string") {
|
|
83
76
|
const resolvedPath = loadPath
|
|
84
77
|
.replace("{{lng}}", locale)
|
|
85
78
|
.replace("{{ns}}", namespace);
|
|
86
79
|
// Check if file exists, return empty object if it doesn't
|
|
87
|
-
if (!
|
|
80
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
88
81
|
console.log(`📄 Creating new namespace file: ${resolvedPath}`);
|
|
89
82
|
return {};
|
|
90
83
|
}
|
|
91
|
-
const content =
|
|
84
|
+
const content = fs.readFileSync(resolvedPath, "utf-8");
|
|
92
85
|
try {
|
|
93
86
|
const json = JSON.parse(content);
|
|
94
87
|
return json;
|
|
@@ -99,24 +92,22 @@ const loadLocalesFile = async (loadPath, locale, namespace) => {
|
|
|
99
92
|
}
|
|
100
93
|
return loadPath(locale, namespace);
|
|
101
94
|
};
|
|
102
|
-
|
|
103
|
-
const writeLocalesFile = async (savePath, locale, namespace, data) => {
|
|
95
|
+
export const writeLocalesFile = async (savePath, locale, namespace, data) => {
|
|
104
96
|
if (typeof savePath === "string") {
|
|
105
97
|
const resolvedSavePath = savePath
|
|
106
98
|
.replace("{{lng}}", locale)
|
|
107
99
|
.replace("{{ns}}", namespace);
|
|
108
100
|
// Ensure directory exists
|
|
109
|
-
const dir =
|
|
110
|
-
if (!
|
|
111
|
-
|
|
101
|
+
const dir = path.dirname(resolvedSavePath);
|
|
102
|
+
if (!fs.existsSync(dir)) {
|
|
103
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
112
104
|
}
|
|
113
|
-
|
|
105
|
+
fs.writeFileSync(resolvedSavePath, JSON.stringify(data, null, 2));
|
|
114
106
|
return;
|
|
115
107
|
}
|
|
116
108
|
await savePath(locale, namespace, data);
|
|
117
109
|
};
|
|
118
|
-
|
|
119
|
-
const getPureKey = (key, namespace, isDefault) => {
|
|
110
|
+
export const getPureKey = (key, namespace, isDefault) => {
|
|
120
111
|
const splitted = key.split(":");
|
|
121
112
|
if (splitted.length === 1) {
|
|
122
113
|
if (isDefault) {
|
|
@@ -129,18 +120,16 @@ const getPureKey = (key, namespace, isDefault) => {
|
|
|
129
120
|
}
|
|
130
121
|
return null;
|
|
131
122
|
};
|
|
132
|
-
exports.getPureKey = getPureKey;
|
|
133
123
|
/**
|
|
134
124
|
* Extracts all glob patterns from the configuration, handling both string and object formats
|
|
135
125
|
*/
|
|
136
|
-
const extractGlobPatterns = (globPatterns) => {
|
|
126
|
+
export const extractGlobPatterns = (globPatterns) => {
|
|
137
127
|
return globPatterns.map((pattern) => typeof pattern === "string" ? pattern : pattern.pattern);
|
|
138
128
|
};
|
|
139
|
-
exports.extractGlobPatterns = extractGlobPatterns;
|
|
140
129
|
/**
|
|
141
130
|
* Gets the namespaces associated with a specific file path based on glob pattern configuration
|
|
142
131
|
*/
|
|
143
|
-
const getNamespacesForFile = (filePath, globPatterns, defaultNamespace) => {
|
|
132
|
+
export const getNamespacesForFile = (filePath, globPatterns, defaultNamespace) => {
|
|
144
133
|
const matchingNamespaces = [];
|
|
145
134
|
// Normalize the file path - remove leading ./ if present
|
|
146
135
|
const normalizedFilePath = filePath.replace(/^\.\//, "");
|
|
@@ -149,10 +138,10 @@ const getNamespacesForFile = (filePath, globPatterns, defaultNamespace) => {
|
|
|
149
138
|
// Normalize the pattern - remove leading ./ if present
|
|
150
139
|
const normalizedPattern = pattern.pattern.replace(/^\.\//, "");
|
|
151
140
|
// Try matching with both the original and normalized paths/patterns
|
|
152
|
-
const isMatch =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
141
|
+
const isMatch = minimatch(filePath, pattern.pattern) ||
|
|
142
|
+
minimatch(normalizedFilePath, pattern.pattern) ||
|
|
143
|
+
minimatch(filePath, normalizedPattern) ||
|
|
144
|
+
minimatch(normalizedFilePath, normalizedPattern);
|
|
156
145
|
// Debug logging to help identify the issue
|
|
157
146
|
if (process.env.DEBUG_NAMESPACE_MATCHING) {
|
|
158
147
|
console.log(`Checking file: ${filePath} (normalized: ${normalizedFilePath})`);
|
|
@@ -171,11 +160,10 @@ const getNamespacesForFile = (filePath, globPatterns, defaultNamespace) => {
|
|
|
171
160
|
? [...new Set(matchingNamespaces)]
|
|
172
161
|
: [defaultNamespace];
|
|
173
162
|
};
|
|
174
|
-
exports.getNamespacesForFile = getNamespacesForFile;
|
|
175
163
|
/**
|
|
176
164
|
* Gets all glob patterns that should be used for a specific namespace
|
|
177
165
|
*/
|
|
178
|
-
const getGlobPatternsForNamespace = (namespace, globPatterns) => {
|
|
166
|
+
export const getGlobPatternsForNamespace = (namespace, globPatterns) => {
|
|
179
167
|
const patterns = [];
|
|
180
168
|
for (const pattern of globPatterns) {
|
|
181
169
|
if (typeof pattern === "string") {
|
|
@@ -189,17 +177,16 @@ const getGlobPatternsForNamespace = (namespace, globPatterns) => {
|
|
|
189
177
|
}
|
|
190
178
|
return patterns;
|
|
191
179
|
};
|
|
192
|
-
exports.getGlobPatternsForNamespace = getGlobPatternsForNamespace;
|
|
193
180
|
/**
|
|
194
181
|
* Extracts keys with their associated namespaces based on the files they're found in
|
|
195
182
|
*/
|
|
196
|
-
const getKeysWithNamespaces = async ({ globPatterns, defaultNamespace, }) => {
|
|
197
|
-
const parser = new
|
|
183
|
+
export const getKeysWithNamespaces = async ({ globPatterns, defaultNamespace, }) => {
|
|
184
|
+
const parser = new Parser({
|
|
198
185
|
nsSeparator: false,
|
|
199
186
|
keySeparator: false,
|
|
200
187
|
});
|
|
201
|
-
const allPatterns =
|
|
202
|
-
const files = await (
|
|
188
|
+
const allPatterns = extractGlobPatterns(globPatterns);
|
|
189
|
+
const files = await glob([...allPatterns, "!**/node_modules/**"]);
|
|
203
190
|
// Debug logging
|
|
204
191
|
if (process.env.DEBUG_NAMESPACE_MATCHING) {
|
|
205
192
|
console.log(`Found ${files.length} files matching patterns:`);
|
|
@@ -212,13 +199,13 @@ const getKeysWithNamespaces = async ({ globPatterns, defaultNamespace, }) => {
|
|
|
212
199
|
}
|
|
213
200
|
const keysWithNamespaces = [];
|
|
214
201
|
for (const file of files) {
|
|
215
|
-
const content =
|
|
202
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
216
203
|
const fileKeys = [];
|
|
217
204
|
parser.parseFuncFromString(content, { list: ["t"] }, (key) => {
|
|
218
205
|
fileKeys.push(key);
|
|
219
206
|
});
|
|
220
207
|
// Get namespaces for this file
|
|
221
|
-
const fileNamespaces =
|
|
208
|
+
const fileNamespaces = getNamespacesForFile(file, globPatterns, defaultNamespace);
|
|
222
209
|
// Debug logging
|
|
223
210
|
if (process.env.DEBUG_NAMESPACE_MATCHING && fileKeys.length > 0) {
|
|
224
211
|
console.log(`File: ${file}`);
|
|
@@ -237,9 +224,8 @@ const getKeysWithNamespaces = async ({ globPatterns, defaultNamespace, }) => {
|
|
|
237
224
|
}
|
|
238
225
|
return keysWithNamespaces;
|
|
239
226
|
};
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
const keysWithNamespaces = await (0, exports.getKeysWithNamespaces)({
|
|
227
|
+
export const getMissingKeys = async ({ globPatterns, namespaces, defaultNamespace, defaultLocale, loadPath, }) => {
|
|
228
|
+
const keysWithNamespaces = await getKeysWithNamespaces({
|
|
243
229
|
globPatterns,
|
|
244
230
|
defaultNamespace,
|
|
245
231
|
});
|
|
@@ -252,7 +238,7 @@ const getMissingKeys = async ({ globPatterns, namespaces, defaultNamespace, defa
|
|
|
252
238
|
if (!keysByNamespace[namespace]) {
|
|
253
239
|
keysByNamespace[namespace] = new Set();
|
|
254
240
|
}
|
|
255
|
-
const pureKey =
|
|
241
|
+
const pureKey = getPureKey(key, namespace, namespace === defaultNamespace);
|
|
256
242
|
if (pureKey) {
|
|
257
243
|
keysByNamespace[namespace].add(pureKey);
|
|
258
244
|
}
|
|
@@ -264,7 +250,7 @@ const getMissingKeys = async ({ globPatterns, namespaces, defaultNamespace, defa
|
|
|
264
250
|
}
|
|
265
251
|
// Check for missing keys in each namespace
|
|
266
252
|
for (const namespace of namespaces) {
|
|
267
|
-
const existingKeys = await
|
|
253
|
+
const existingKeys = await loadLocalesFile(loadPath, defaultLocale, namespace);
|
|
268
254
|
console.log(Object.keys(existingKeys).length, "existing keys in", namespace);
|
|
269
255
|
const keysForNamespace = keysByNamespace[namespace] || new Set();
|
|
270
256
|
console.log(`🔍 Checking ${keysForNamespace.size} keys for namespace ${namespace}`);
|
|
@@ -276,9 +262,8 @@ const getMissingKeys = async ({ globPatterns, namespaces, defaultNamespace, defa
|
|
|
276
262
|
}
|
|
277
263
|
return newKeys;
|
|
278
264
|
};
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
const input = await (0, prompts_1.default)({
|
|
265
|
+
export const getTextInput = async (prompt) => {
|
|
266
|
+
const input = await prompts({
|
|
282
267
|
name: "value",
|
|
283
268
|
type: "text",
|
|
284
269
|
message: prompt,
|
|
@@ -292,17 +277,16 @@ const getTextInput = async (prompt) => {
|
|
|
292
277
|
});
|
|
293
278
|
return input.value;
|
|
294
279
|
};
|
|
295
|
-
|
|
296
|
-
const checkAllKeysExist = async ({ namespaces, defaultLocale, loadPath, locales, context, openai, savePath, disableTranslation, model, }) => {
|
|
280
|
+
export const checkAllKeysExist = async ({ namespaces, defaultLocale, loadPath, locales, context, openai, savePath, disableTranslation, model, }) => {
|
|
297
281
|
if (disableTranslation) {
|
|
298
282
|
return;
|
|
299
283
|
}
|
|
300
284
|
for (const namespace of namespaces) {
|
|
301
|
-
const defaultLocaleKeys = await
|
|
285
|
+
const defaultLocaleKeys = await loadLocalesFile(loadPath, defaultLocale, namespace);
|
|
302
286
|
for (const locale of locales) {
|
|
303
287
|
if (locale === defaultLocale)
|
|
304
288
|
continue;
|
|
305
|
-
const localeKeys = await
|
|
289
|
+
const localeKeys = await loadLocalesFile(loadPath, locale, namespace);
|
|
306
290
|
const missingKeys = {};
|
|
307
291
|
// Check which keys from default locale are missing in current locale
|
|
308
292
|
for (const [key, value] of Object.entries(defaultLocaleKeys)) {
|
|
@@ -313,7 +297,7 @@ const checkAllKeysExist = async ({ namespaces, defaultLocale, loadPath, locales,
|
|
|
313
297
|
// If there are missing keys, translate them
|
|
314
298
|
if (Object.keys(missingKeys).length > 0) {
|
|
315
299
|
console.log(`Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`);
|
|
316
|
-
const translatedValues = await
|
|
300
|
+
const translatedValues = await translateKey({
|
|
317
301
|
inputLanguage: defaultLocale,
|
|
318
302
|
outputLanguage: locale,
|
|
319
303
|
context,
|
|
@@ -327,14 +311,13 @@ const checkAllKeysExist = async ({ namespaces, defaultLocale, loadPath, locales,
|
|
|
327
311
|
...translatedValues,
|
|
328
312
|
};
|
|
329
313
|
// Save the updated translations
|
|
330
|
-
|
|
314
|
+
writeLocalesFile(savePath, locale, namespace, updatedLocaleKeys);
|
|
331
315
|
console.log(`✓ Translated and saved missing keys for ${locale} (namespace: ${namespace})`);
|
|
332
316
|
}
|
|
333
317
|
}
|
|
334
318
|
}
|
|
335
319
|
};
|
|
336
|
-
|
|
337
|
-
class TranslationError extends Error {
|
|
320
|
+
export class TranslationError extends Error {
|
|
338
321
|
constructor(message, locale, namespace, cause) {
|
|
339
322
|
super(message);
|
|
340
323
|
this.locale = locale;
|
|
@@ -343,5 +326,4 @@ class TranslationError extends Error {
|
|
|
343
326
|
this.name = "TranslationError";
|
|
344
327
|
}
|
|
345
328
|
}
|
|
346
|
-
exports.TranslationError = TranslationError;
|
|
347
329
|
//# sourceMappingURL=utils.js.map
|
package/dist/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;;;;AA8BA,8DAEC;AAhCD,0DAA4B;AAC5B,qDAAwC;AACxC,yCAAqC;AACrC,sDAAwB;AACxB,0DAA4B;AAE5B,sDAA6B;AAC7B,yCAAsC;AAG/B,MAAM,UAAU,GAAG,CAAC,EACzB,UAAU,GAAG,eAAe,GACL,EAAE,EAAE;IAC3B,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;IAErD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAA;QACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,QA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,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,GAAG,CACT,SAAS,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,oBAAoB,MAAM,gBAAgB,SAAS,GAAG,CAC/F,CAAA;gBAED,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC;oBAC1C,aAAa,EAAE,aAAa;oBAC5B,cAAc,EAAE,MAAM;oBACtB,OAAO;oBACP,MAAM,EAAE,WAAW;oBACnB,MAAM;oBACN,KAAK;iBACN,CAAC,CAAA;gBAEF,6CAA6C;gBAC7C,MAAM,iBAAiB,GAAG;oBACxB,GAAG,UAAU;oBACb,GAAG,gBAAgB;iBACpB,CAAA;gBAED,gCAAgC;gBAChC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;gBAChE,OAAO,CAAC,GAAG,CACT,2CAA2C,MAAM,gBAAgB,SAAS,GAAG,CAC9E,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YACE,OAAe,EACR,MAAe,EACf,SAAkB,EAClB,KAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJP,WAAM,GAAN,MAAM,CAAS;QACf,cAAS,GAAT,SAAS,CAAS;QAClB,UAAK,GAAL,KAAK,CAAQ;QAGpB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAChC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scoutello/i18n-magic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Intelligent CLI toolkit that automates internationalization workflows with AI-powered translations for JavaScript/TypeScript projects",
|
|
@@ -32,20 +32,21 @@
|
|
|
32
32
|
"name": "scoutello",
|
|
33
33
|
"url": "https://github.com/BjoernRave"
|
|
34
34
|
},
|
|
35
|
+
"type": "module",
|
|
35
36
|
"main": "dist/index.js",
|
|
36
37
|
"typings": "dist/index.d.ts",
|
|
37
38
|
"types": "dist/index.d.ts",
|
|
38
39
|
"bin": "dist/cli.js",
|
|
39
40
|
"exports": {
|
|
40
41
|
".": {
|
|
41
|
-
"
|
|
42
|
+
"import": "./dist/index.js",
|
|
42
43
|
"types": "./dist/index.d.ts"
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
"files": ["dist", "src"],
|
|
46
47
|
"scripts": {
|
|
47
48
|
"analyze": "size-limit --why",
|
|
48
|
-
"build": "tsc && echo '#!/usr/bin/env node' | cat - dist/cli.js > temp && mv temp dist/cli.js",
|
|
49
|
+
"build": "tsc && echo '#!/usr/bin/env node' | cat - dist/cli.js > temp && mv temp dist/cli.js && chmod +x dist/cli.js",
|
|
49
50
|
"lint": "biome check src/",
|
|
50
51
|
"prepare": "npm run build",
|
|
51
52
|
"size": "size-limit",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"dotenv": "^16.5.0",
|
|
69
70
|
"fast-glob": "^3.3.3",
|
|
70
71
|
"i18next-scanner": "^4.6.0",
|
|
71
|
-
"minimatch": "^10.0.
|
|
72
|
+
"minimatch": "^10.0.3",
|
|
72
73
|
"prompts": "^2.4.2",
|
|
73
74
|
"zod": "^3.24.2"
|
|
74
75
|
},
|
package/src/cli.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Command } from "commander"
|
|
2
2
|
import dotenv from "dotenv"
|
|
3
3
|
import OpenAI from "openai"
|
|
4
|
-
import { checkMissing } from "./commands/check-missing"
|
|
5
|
-
import { removeUnusedKeys } from "./commands/clean"
|
|
4
|
+
import { checkMissing } from "./commands/check-missing.js"
|
|
5
|
+
import { removeUnusedKeys } from "./commands/clean.js"
|
|
6
6
|
|
|
7
|
-
import { replaceTranslation } from "./commands/replace"
|
|
8
|
-
import { translateMissing } from "./commands/scan"
|
|
9
|
-
import { syncLocales } from "./commands/sync-locales"
|
|
10
|
-
import type { CommandType, Configuration } from "./lib/types"
|
|
11
|
-
import { loadConfig } from "./lib/utils"
|
|
7
|
+
import { replaceTranslation } from "./commands/replace.js"
|
|
8
|
+
import { translateMissing } from "./commands/scan.js"
|
|
9
|
+
import { syncLocales } from "./commands/sync-locales.js"
|
|
10
|
+
import type { CommandType, Configuration } from "./lib/types.js"
|
|
11
|
+
import { loadConfig } from "./lib/utils.js"
|
|
12
12
|
|
|
13
13
|
const program = new Command()
|
|
14
14
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Configuration } from "../lib/types"
|
|
2
|
-
import { getMissingKeys } from "../lib/utils"
|
|
1
|
+
import type { Configuration } from "../lib/types.js"
|
|
2
|
+
import { getMissingKeys } from "../lib/utils.js"
|
|
3
3
|
|
|
4
4
|
export const checkMissing = async (config: Configuration) => {
|
|
5
5
|
const newKeys = await getMissingKeys(config)
|
package/src/commands/clean.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Configuration } from "../lib/types"
|
|
1
|
+
import type { Configuration } from "../lib/types.js"
|
|
2
2
|
import {
|
|
3
3
|
getKeysWithNamespaces,
|
|
4
4
|
getPureKey,
|
|
5
5
|
loadLocalesFile,
|
|
6
6
|
writeLocalesFile,
|
|
7
|
-
} from "../lib/utils"
|
|
7
|
+
} from "../lib/utils.js"
|
|
8
8
|
|
|
9
9
|
export const removeUnusedKeys = async (config: Configuration) => {
|
|
10
10
|
const {
|
package/src/commands/replace.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Configuration } from "../lib/types"
|
|
1
|
+
import type { Configuration } from "../lib/types.js"
|
|
2
2
|
import {
|
|
3
3
|
getKeysWithNamespaces,
|
|
4
4
|
getPureKey,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
loadLocalesFile,
|
|
7
7
|
translateKey,
|
|
8
8
|
writeLocalesFile,
|
|
9
|
-
} from "../lib/utils"
|
|
9
|
+
} from "../lib/utils.js"
|
|
10
10
|
|
|
11
11
|
const getKeyToReplace = async (
|
|
12
12
|
allAvailableKeys: Record<string, { namespace: string; value: string }[]>,
|
package/src/commands/scan.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Configuration } from "../lib/types"
|
|
1
|
+
import type { Configuration } from "../lib/types.js"
|
|
2
2
|
import {
|
|
3
3
|
checkAllKeysExist,
|
|
4
4
|
getMissingKeys,
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
loadLocalesFile,
|
|
7
7
|
translateKey,
|
|
8
8
|
writeLocalesFile,
|
|
9
|
-
} from "../lib/utils"
|
|
10
|
-
import { removeUnusedKeys } from "./clean"
|
|
9
|
+
} from "../lib/utils.js"
|
|
10
|
+
import { removeUnusedKeys } from "./clean.js"
|
|
11
11
|
|
|
12
12
|
export const translateMissing = async (config: Configuration) => {
|
|
13
13
|
const {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Configuration } from "../lib/types"
|
|
1
|
+
import type { Configuration } from "../lib/types.js"
|
|
2
2
|
import {
|
|
3
3
|
TranslationError,
|
|
4
4
|
loadLocalesFile,
|
|
5
5
|
translateKey,
|
|
6
6
|
writeLocalesFile,
|
|
7
|
-
} from "../lib/utils"
|
|
7
|
+
} from "../lib/utils.js"
|
|
8
8
|
|
|
9
9
|
export const syncLocales = async (config: Configuration) => {
|
|
10
10
|
const {
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Export command functions for programmatic usage
|
|
2
|
-
export { checkMissing } from "./commands/check-missing"
|
|
3
|
-
export { removeUnusedKeys } from "./commands/clean"
|
|
2
|
+
export { checkMissing } from "./commands/check-missing.js"
|
|
3
|
+
export { removeUnusedKeys } from "./commands/clean.js"
|
|
4
4
|
|
|
5
|
-
export { replaceTranslation } from "./commands/replace"
|
|
6
|
-
export { translateMissing } from "./commands/scan"
|
|
7
|
-
export { syncLocales } from "./commands/sync-locales"
|
|
5
|
+
export { replaceTranslation } from "./commands/replace.js"
|
|
6
|
+
export { translateMissing } from "./commands/scan.js"
|
|
7
|
+
export { syncLocales } from "./commands/sync-locales.js"
|
|
8
8
|
|
|
9
9
|
// Export utility functions
|
|
10
|
-
export { loadConfig } from "./lib/utils"
|
|
10
|
+
export { loadConfig } from "./lib/utils.js"
|
|
11
11
|
|
|
12
12
|
// Export types
|
|
13
13
|
|
|
@@ -15,4 +15,4 @@ export type {
|
|
|
15
15
|
CommandType,
|
|
16
16
|
Configuration,
|
|
17
17
|
GlobPatternConfig,
|
|
18
|
-
} from "./lib/types"
|
|
18
|
+
} from "./lib/types.js"
|
package/src/lib/utils.ts
CHANGED
|
@@ -5,12 +5,12 @@ import fs from "node:fs"
|
|
|
5
5
|
import path from "node:path"
|
|
6
6
|
import type OpenAI from "openai"
|
|
7
7
|
import prompts from "prompts"
|
|
8
|
-
import { languages } from "./languges"
|
|
9
|
-
import type { Configuration, GlobPatternConfig } from "./types"
|
|
8
|
+
import { languages } from "./languges.js"
|
|
9
|
+
import type { Configuration, GlobPatternConfig } from "./types.js"
|
|
10
10
|
|
|
11
|
-
export const loadConfig = ({
|
|
11
|
+
export const loadConfig = async ({
|
|
12
12
|
configPath = "i18n-magic.js",
|
|
13
|
-
}: { configPath
|
|
13
|
+
}: { configPath?: string } = {}) => {
|
|
14
14
|
const filePath = path.join(process.cwd(), configPath)
|
|
15
15
|
|
|
16
16
|
if (!fs.existsSync(filePath)) {
|
|
@@ -19,7 +19,9 @@ export const loadConfig = ({
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
// Use dynamic import for ESM compatibility
|
|
23
|
+
const configModule = await import(`file://${filePath}`)
|
|
24
|
+
const config = configModule.default || configModule
|
|
23
25
|
// Validate config if needed
|
|
24
26
|
return config
|
|
25
27
|
} catch (error) {
|