@scoutello/i18n-magic 0.16.0 → 0.19.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.
Files changed (64) hide show
  1. package/README.md +207 -19
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +101 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/check-missing.d.ts +1 -0
  7. package/dist/commands/check-missing.d.ts.map +1 -0
  8. package/dist/commands/check-missing.js +13 -0
  9. package/dist/commands/check-missing.js.map +1 -0
  10. package/dist/commands/clean.d.ts +1 -0
  11. package/dist/commands/clean.d.ts.map +1 -0
  12. package/dist/commands/clean.js +82 -0
  13. package/dist/commands/clean.js.map +1 -0
  14. package/dist/commands/create-pruned-namespace-automated.d.ts +20 -0
  15. package/dist/commands/create-pruned-namespace-automated.d.ts.map +1 -0
  16. package/dist/commands/create-pruned-namespace-automated.js +98 -0
  17. package/dist/commands/create-pruned-namespace-automated.js.map +1 -0
  18. package/dist/commands/create-pruned-namespace.d.ts +3 -0
  19. package/dist/commands/create-pruned-namespace.d.ts.map +1 -0
  20. package/dist/commands/create-pruned-namespace.js +123 -0
  21. package/dist/commands/create-pruned-namespace.js.map +1 -0
  22. package/dist/commands/replace.d.ts +1 -0
  23. package/dist/commands/replace.d.ts.map +1 -0
  24. package/dist/commands/replace.js +58 -0
  25. package/dist/commands/replace.js.map +1 -0
  26. package/dist/commands/scan.d.ts +1 -0
  27. package/dist/commands/scan.d.ts.map +1 -0
  28. package/dist/commands/scan.js +70 -0
  29. package/dist/commands/scan.js.map +1 -0
  30. package/dist/commands/sync-locales.d.ts +1 -0
  31. package/dist/commands/sync-locales.d.ts.map +1 -0
  32. package/dist/commands/sync-locales.js +78 -0
  33. package/dist/commands/sync-locales.js.map +1 -0
  34. package/dist/i18n-magic.cjs.development.js +348 -130
  35. package/dist/i18n-magic.cjs.development.js.map +1 -1
  36. package/dist/i18n-magic.cjs.production.min.js +1 -1
  37. package/dist/i18n-magic.cjs.production.min.js.map +1 -1
  38. package/dist/i18n-magic.esm.js +339 -130
  39. package/dist/i18n-magic.esm.js.map +1 -1
  40. package/dist/index.d.ts +11 -1
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +22 -9
  43. package/dist/index.js.map +1 -0
  44. package/dist/lib/languges.d.ts +1 -0
  45. package/dist/lib/languges.d.ts.map +1 -0
  46. package/dist/lib/languges.js +146 -0
  47. package/dist/lib/languges.js.map +1 -0
  48. package/dist/lib/types.d.ts +7 -1
  49. package/dist/lib/types.d.ts.map +1 -0
  50. package/dist/lib/types.js +3 -0
  51. package/dist/lib/types.js.map +1 -0
  52. package/dist/lib/utils.d.ts +20 -1
  53. package/dist/lib/utils.d.ts.map +1 -0
  54. package/dist/lib/utils.js +264 -0
  55. package/dist/lib/utils.js.map +1 -0
  56. package/package.json +38 -14
  57. package/src/cli.ts +117 -0
  58. package/src/commands/clean.ts +4 -1
  59. package/src/commands/create-pruned-namespace-automated.ts +165 -0
  60. package/src/commands/create-pruned-namespace.ts +168 -0
  61. package/src/commands/scan.ts +12 -0
  62. package/src/index.ts +23 -113
  63. package/src/lib/types.ts +7 -1
  64. package/src/lib/utils.ts +59 -2
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.languages = void 0;
4
+ exports.languages = [
5
+ {
6
+ label: "Deutsch",
7
+ name: "German",
8
+ value: "de",
9
+ },
10
+ {
11
+ label: "English",
12
+ name: "English",
13
+ value: "en",
14
+ },
15
+ {
16
+ label: "Español",
17
+ name: "Spanish",
18
+ value: "es",
19
+ },
20
+ {
21
+ label: "Français",
22
+ name: "French",
23
+ value: "fr",
24
+ },
25
+ {
26
+ label: "Dansk",
27
+ name: "Danish",
28
+ value: "dk",
29
+ },
30
+ {
31
+ label: "中文",
32
+ name: "Chinese",
33
+ value: "cn",
34
+ },
35
+ {
36
+ label: "Русский",
37
+ name: "Russian",
38
+ value: "ru",
39
+ },
40
+ {
41
+ label: "Italiano",
42
+ name: "Italian",
43
+ value: "it",
44
+ },
45
+ {
46
+ label: "Nederlands",
47
+ name: "Dutch",
48
+ value: "nl",
49
+ },
50
+ {
51
+ label: "Português",
52
+ name: "Portuguese",
53
+ value: "pt",
54
+ },
55
+ {
56
+ label: "Türkçe",
57
+ name: "Turkish",
58
+ value: "tr",
59
+ },
60
+ {
61
+ label: "Polski",
62
+ name: "Polish",
63
+ value: "pl",
64
+ },
65
+ {
66
+ label: "Українська",
67
+ name: "Ukrainian",
68
+ value: "ua",
69
+ },
70
+ {
71
+ label: "Suomi",
72
+ name: "Finnish",
73
+ value: "fi",
74
+ },
75
+ {
76
+ label: "Norsk",
77
+ name: "Norwegian",
78
+ value: "no",
79
+ },
80
+ {
81
+ label: "Svenska",
82
+ name: "Swedish",
83
+ value: "sv",
84
+ },
85
+ {
86
+ label: "Čeština",
87
+ name: "Czech",
88
+ value: "cz",
89
+ },
90
+ {
91
+ label: "Ελληνικά",
92
+ name: "Greek",
93
+ value: "gr",
94
+ },
95
+ {
96
+ label: "日本語",
97
+ name: "Japanese",
98
+ value: "jp",
99
+ },
100
+ {
101
+ label: "한국어",
102
+ name: "Korean",
103
+ value: "kr",
104
+ },
105
+ {
106
+ label: "Română",
107
+ name: "Romanian",
108
+ value: "ro",
109
+ },
110
+ {
111
+ label: "Hrvatski",
112
+ name: "Croatian",
113
+ value: "hr",
114
+ },
115
+ {
116
+ label: "Magyar",
117
+ name: "Hungarian",
118
+ value: "hu",
119
+ },
120
+ {
121
+ label: "Slovensky",
122
+ name: "Slovak",
123
+ value: "sk",
124
+ },
125
+ {
126
+ label: "हिन्दी",
127
+ name: "Hindi",
128
+ value: "hi",
129
+ },
130
+ {
131
+ label: "தமிழ்",
132
+ name: "Tamil",
133
+ value: "ta",
134
+ },
135
+ {
136
+ label: "Bahasa Indonesia",
137
+ name: "Indonesian",
138
+ value: "id",
139
+ },
140
+ {
141
+ label: "Tiếng Việt",
142
+ name: "Vietnamese",
143
+ value: "vn",
144
+ },
145
+ ];
146
+ //# sourceMappingURL=languges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languges.js","sourceRoot":"","sources":["../../src/lib/languges.ts"],"names":[],"mappings":";;;AAAa,QAAA,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,QAAQ;QACd,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,IAAI;QACX,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,SAAS;QACf,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;KACZ;IACD;QACE,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,WAAW;QACjB,KAAK,E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Z;CACF,CAAA"}
@@ -1,6 +1,10 @@
1
1
  import type OpenAI from "openai";
2
2
  import type { ChatModel } from "openai/resources/chat/chat";
3
3
  type Model = ChatModel | "gemini-2.5-pro-exp-03-25" | "gemini-2.0-flash" | "gemini-2.0-flash-lite";
4
+ export interface GlobPatternConfig {
5
+ pattern: string;
6
+ namespaces: string[];
7
+ }
4
8
  export interface Configuration {
5
9
  loadPath: string | ((locale: string, namespace: string) => Promise<Record<string, string>>);
6
10
  savePath: string | ((locale: string, namespace: string, data: Record<string, string>) => Promise<void>);
@@ -8,9 +12,10 @@ export interface Configuration {
8
12
  defaultNamespace: string;
9
13
  namespaces: string[];
10
14
  locales: string[];
11
- globPatterns: string[];
15
+ globPatterns: (string | GlobPatternConfig)[];
12
16
  context?: string;
13
17
  disableTranslation?: boolean;
18
+ autoClear?: boolean;
14
19
  OPENAI_API_KEY?: string;
15
20
  GEMINI_API_KEY?: string;
16
21
  model?: Model;
@@ -22,3 +27,4 @@ export interface CommandType {
22
27
  action: (config: Configuration, ...args: any[]) => Promise<void>;
23
28
  }
24
29
  export {};
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,KAAK,KAAK,GACN,SAAS,GACT,0BAA0B,GAC1B,kBAAkB,GAClB,uBAAuB,CAAA;AAE3B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EACJ,MAAM,GACN,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAC5E,QAAQ,EACJ,MAAM,GACN,CAAC,CACC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,EAAE,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAA;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACjE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import type OpenAI from "openai";
2
- import type { Configuration } from "./types";
2
+ import type { GlobPatternConfig, Configuration } from "./types";
3
3
  export declare const loadConfig: ({ configPath, }: {
4
4
  configPath: string;
5
5
  }) => any;
@@ -15,6 +15,24 @@ export declare const translateKey: ({ inputLanguage, context, object, openai, ou
15
15
  export declare const loadLocalesFile: (loadPath: string | ((locale: string, namespace: string) => Promise<Record<string, string>>), locale: string, namespace: string) => Promise<Record<string, string>>;
16
16
  export declare const writeLocalesFile: (savePath: string | ((locale: string, namespace: string, data: Record<string, string>) => Promise<void>), locale: string, namespace: string, data: Record<string, string>) => Promise<void>;
17
17
  export declare const getPureKey: (key: string, namespace?: string, isDefault?: boolean) => string;
18
+ /**
19
+ * Extracts all glob patterns from the configuration, handling both string and object formats
20
+ */
21
+ export declare const extractGlobPatterns: (globPatterns: (string | GlobPatternConfig)[]) => string[];
22
+ /**
23
+ * Gets the namespaces associated with a specific file path based on glob pattern configuration
24
+ */
25
+ export declare const getNamespacesForFile: (filePath: string, globPatterns: (string | {
26
+ pattern: string;
27
+ namespaces: string[];
28
+ })[]) => string[];
29
+ /**
30
+ * Gets all glob patterns that should be used for a specific namespace
31
+ */
32
+ export declare const getGlobPatternsForNamespace: (namespace: string, globPatterns: (string | {
33
+ pattern: string;
34
+ namespaces: string[];
35
+ })[]) => string[];
18
36
  export declare const getMissingKeys: ({ globPatterns, namespaces, defaultNamespace, defaultLocale, loadPath, }: Configuration) => Promise<any[]>;
19
37
  export declare const getTextInput: (prompt: string) => Promise<string>;
20
38
  export declare const checkAllKeysExist: ({ namespaces, defaultLocale, loadPath, locales, context, openai, savePath, disableTranslation, model, }: Configuration) => Promise<void>;
@@ -24,3 +42,4 @@ export declare class TranslationError extends Error {
24
42
  cause?: Error;
25
43
  constructor(message: string, locale?: string, namespace?: string, cause?: Error);
26
44
  }
45
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAGhC,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE/D,eAAO,MAAM,UAAU,GAAI,i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,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,EAAE,KACnE,MAAM,EAeR,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,MAAM,EACjB,cAAc,CAAC,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,EAAE,KACnE,MAAM,EAcR,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,0EAMlC,aAAa,mBA6Cf,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,QAAQ,MAAM,oBAehD,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAU,yGAUrC,aAAa,kBAsDf,CAAA;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IAGhC,MAAM,CAAC,EAAE,MAAM;IACf,SAAS,CAAC,EAAE,MAAM;IAClB,KAAK,CAAC,EAAE,KAAK;gBAHpB,OAAO,EAAE,MAAM,EACR,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,KAAK;CAKvB"}
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TranslationError = exports.checkAllKeysExist = exports.getTextInput = exports.getMissingKeys = exports.getGlobPatternsForNamespace = exports.getNamespacesForFile = exports.extractGlobPatterns = exports.getPureKey = exports.writeLocalesFile = exports.loadLocalesFile = exports.translateKey = exports.loadConfig = void 0;
7
+ exports.removeDuplicatesFromArray = removeDuplicatesFromArray;
8
+ const fast_glob_1 = __importDefault(require("fast-glob"));
9
+ const i18next_scanner_1 = require("i18next-scanner");
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const prompts_1 = __importDefault(require("prompts"));
13
+ const languges_1 = require("./languges");
14
+ const loadConfig = ({ configPath = "i18n-magic.js", }) => {
15
+ const filePath = node_path_1.default.join(process.cwd(), configPath);
16
+ if (!node_fs_1.default.existsSync(filePath)) {
17
+ console.error("Config file does not exist:", filePath);
18
+ process.exit(1);
19
+ }
20
+ try {
21
+ const config = require(filePath);
22
+ // Validate config if needed
23
+ return config;
24
+ }
25
+ catch (error) {
26
+ console.error("Error while loading config:", error);
27
+ process.exit(1);
28
+ }
29
+ };
30
+ exports.loadConfig = loadConfig;
31
+ function removeDuplicatesFromArray(arr) {
32
+ return arr.filter((item, index) => arr.indexOf(item) === index);
33
+ }
34
+ const translateKey = async ({ inputLanguage, context, object, openai, outputLanguage, model, }) => {
35
+ // Split object into chunks of 100 keys
36
+ const entries = Object.entries(object);
37
+ const chunks = [];
38
+ for (let i = 0; i < entries.length; i += 100) {
39
+ chunks.push(entries.slice(i, i + 100));
40
+ }
41
+ let result = {};
42
+ const existingInput = languges_1.languages.find((l) => l.value === inputLanguage);
43
+ const existingOutput = languges_1.languages.find((l) => l.value === outputLanguage);
44
+ const input = existingInput?.label || inputLanguage;
45
+ const output = existingOutput?.label || outputLanguage;
46
+ // Translate each chunk
47
+ for (const chunk of chunks) {
48
+ const chunkObject = Object.fromEntries(chunk);
49
+ const completion = await openai.beta.chat.completions.parse({
50
+ model,
51
+ messages: [
52
+ {
53
+ content: `You are a bot that translates the values of a locales JSON. ${context
54
+ ? `The user provided some additional context or guidelines about what to fill in the blanks: \"${context}\". `
55
+ : ""}The user provides you a JSON with a field named "inputLanguage", which defines the language the values of the JSON are defined in. It also has a field named "outputLanguage", which defines the language you should translate the values to. The last field is named "data", which includes the object with the values to translate. The keys of the values should never be changed. You output only a JSON, which has the same keys as the input, but with translated values. I give you an example input: {"inputLanguage": "English", outputLanguage: "German", "keys": {"hello": "Hello", "world": "World"}}. The output should be {"hello": "Hallo", "world": "Welt"}.`,
56
+ role: "system",
57
+ },
58
+ {
59
+ content: JSON.stringify({
60
+ inputLanguage: input,
61
+ outputLanguage: output,
62
+ data: chunkObject,
63
+ }),
64
+ role: "user",
65
+ },
66
+ ],
67
+ response_format: {
68
+ type: "json_object",
69
+ },
70
+ });
71
+ const translatedChunk = JSON.parse(completion.choices[0].message.content);
72
+ // Merge translated chunk with result
73
+ result = { ...result, ...translatedChunk };
74
+ // Optional: Add a small delay between chunks to avoid rate limiting
75
+ await new Promise((resolve) => setTimeout(resolve, 100));
76
+ }
77
+ return result;
78
+ };
79
+ exports.translateKey = translateKey;
80
+ const loadLocalesFile = async (loadPath, locale, namespace) => {
81
+ if (typeof loadPath === "string") {
82
+ const resolvedPath = loadPath
83
+ .replace("{{lng}}", locale)
84
+ .replace("{{ns}}", namespace);
85
+ const content = node_fs_1.default.readFileSync(resolvedPath, "utf-8");
86
+ try {
87
+ const json = JSON.parse(content);
88
+ return json;
89
+ }
90
+ catch (error) {
91
+ throw new TranslationError(`Invalid JSON in locale file for ${locale}:${namespace}. Path: ${resolvedPath}`, locale, namespace, error instanceof Error ? error : undefined);
92
+ }
93
+ }
94
+ return loadPath(locale, namespace);
95
+ };
96
+ exports.loadLocalesFile = loadLocalesFile;
97
+ const writeLocalesFile = async (savePath, locale, namespace, data) => {
98
+ if (typeof savePath === "string") {
99
+ const resolvedSavePath = savePath
100
+ .replace("{{lng}}", locale)
101
+ .replace("{{ns}}", namespace);
102
+ node_fs_1.default.writeFileSync(resolvedSavePath, JSON.stringify(data, null, 2));
103
+ return;
104
+ }
105
+ await savePath(locale, namespace, data);
106
+ };
107
+ exports.writeLocalesFile = writeLocalesFile;
108
+ const getPureKey = (key, namespace, isDefault) => {
109
+ const splitted = key.split(":");
110
+ if (splitted.length === 1) {
111
+ if (isDefault) {
112
+ return key;
113
+ }
114
+ return null;
115
+ }
116
+ if (splitted[0] === namespace) {
117
+ return splitted[1];
118
+ }
119
+ return null;
120
+ };
121
+ exports.getPureKey = getPureKey;
122
+ /**
123
+ * Extracts all glob patterns from the configuration, handling both string and object formats
124
+ */
125
+ const extractGlobPatterns = (globPatterns) => {
126
+ return globPatterns.map((pattern) => typeof pattern === "string" ? pattern : pattern.pattern);
127
+ };
128
+ exports.extractGlobPatterns = extractGlobPatterns;
129
+ /**
130
+ * Gets the namespaces associated with a specific file path based on glob pattern configuration
131
+ */
132
+ const getNamespacesForFile = (filePath, globPatterns) => {
133
+ const matchingNamespaces = [];
134
+ for (const pattern of globPatterns) {
135
+ if (typeof pattern === "object") {
136
+ // Use minimatch or similar logic to check if file matches pattern
137
+ const globPattern = pattern.pattern;
138
+ // For now, using a simple includes check - in production you'd want proper glob matching
139
+ if (filePath.includes(globPattern.replace("**/*", "").replace("*", ""))) {
140
+ matchingNamespaces.push(...pattern.namespaces);
141
+ }
142
+ }
143
+ }
144
+ return [...new Set(matchingNamespaces)]; // Remove duplicates
145
+ };
146
+ exports.getNamespacesForFile = getNamespacesForFile;
147
+ /**
148
+ * Gets all glob patterns that should be used for a specific namespace
149
+ */
150
+ const getGlobPatternsForNamespace = (namespace, globPatterns) => {
151
+ const patterns = [];
152
+ for (const pattern of globPatterns) {
153
+ if (typeof pattern === "string") {
154
+ // String patterns apply to all namespaces
155
+ patterns.push(pattern);
156
+ }
157
+ else if (pattern.namespaces.includes(namespace)) {
158
+ // Object patterns only apply to specified namespaces
159
+ patterns.push(pattern.pattern);
160
+ }
161
+ }
162
+ return patterns;
163
+ };
164
+ exports.getGlobPatternsForNamespace = getGlobPatternsForNamespace;
165
+ const getMissingKeys = async ({ globPatterns, namespaces, defaultNamespace, defaultLocale, loadPath, }) => {
166
+ const parser = new i18next_scanner_1.Parser({
167
+ nsSeparator: false,
168
+ keySeparator: false,
169
+ });
170
+ const allPatterns = (0, exports.extractGlobPatterns)(globPatterns);
171
+ const files = await (0, fast_glob_1.default)([...allPatterns, "!**/node_modules/**"]);
172
+ const keys = [];
173
+ for (const file of files) {
174
+ const content = node_fs_1.default.readFileSync(file, "utf-8");
175
+ parser.parseFuncFromString(content, { list: ["t"] }, (key) => {
176
+ keys.push(key);
177
+ });
178
+ }
179
+ const uniqueKeys = removeDuplicatesFromArray(keys);
180
+ const newKeys = [];
181
+ for (const namespace of namespaces) {
182
+ const existingKeys = await (0, exports.loadLocalesFile)(loadPath, defaultLocale, namespace);
183
+ console.log(Object.keys(existingKeys).length, "existing keys");
184
+ for (const key of uniqueKeys) {
185
+ const pureKey = (0, exports.getPureKey)(key, namespace, namespace === defaultNamespace);
186
+ if (!pureKey) {
187
+ continue;
188
+ }
189
+ if (!existingKeys[pureKey]) {
190
+ newKeys.push({ key: pureKey, namespace });
191
+ }
192
+ }
193
+ }
194
+ return newKeys;
195
+ };
196
+ exports.getMissingKeys = getMissingKeys;
197
+ const getTextInput = async (prompt) => {
198
+ const input = await (0, prompts_1.default)({
199
+ name: "value",
200
+ type: "text",
201
+ message: prompt,
202
+ onState: (state) => {
203
+ if (state.aborted) {
204
+ process.nextTick(() => {
205
+ process.exit(0);
206
+ });
207
+ }
208
+ },
209
+ });
210
+ return input.value;
211
+ };
212
+ exports.getTextInput = getTextInput;
213
+ const checkAllKeysExist = async ({ namespaces, defaultLocale, loadPath, locales, context, openai, savePath, disableTranslation, model, }) => {
214
+ if (disableTranslation) {
215
+ return;
216
+ }
217
+ for (const namespace of namespaces) {
218
+ const defaultLocaleKeys = await (0, exports.loadLocalesFile)(loadPath, defaultLocale, namespace);
219
+ for (const locale of locales) {
220
+ if (locale === defaultLocale)
221
+ continue;
222
+ const localeKeys = await (0, exports.loadLocalesFile)(loadPath, locale, namespace);
223
+ const missingKeys = {};
224
+ // Check which keys from default locale are missing in current locale
225
+ for (const [key, value] of Object.entries(defaultLocaleKeys)) {
226
+ if (!localeKeys[key]) {
227
+ missingKeys[key] = value;
228
+ }
229
+ }
230
+ // If there are missing keys, translate them
231
+ if (Object.keys(missingKeys).length > 0) {
232
+ console.log(`Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`);
233
+ const translatedValues = await (0, exports.translateKey)({
234
+ inputLanguage: defaultLocale,
235
+ outputLanguage: locale,
236
+ context,
237
+ object: missingKeys,
238
+ openai,
239
+ model,
240
+ });
241
+ // Merge translated values with existing ones
242
+ const updatedLocaleKeys = {
243
+ ...localeKeys,
244
+ ...translatedValues,
245
+ };
246
+ // Save the updated translations
247
+ (0, exports.writeLocalesFile)(savePath, locale, namespace, updatedLocaleKeys);
248
+ console.log(`✓ Translated and saved missing keys for ${locale} (namespace: ${namespace})`);
249
+ }
250
+ }
251
+ }
252
+ };
253
+ exports.checkAllKeysExist = checkAllKeysExist;
254
+ class TranslationError extends Error {
255
+ constructor(message, locale, namespace, cause) {
256
+ super(message);
257
+ this.locale = locale;
258
+ this.namespace = namespace;
259
+ this.cause = cause;
260
+ this.name = "TranslationError";
261
+ }
262
+ }
263
+ exports.TranslationError = TranslationError;
264
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;;;;AA6BA,8DAEC;AA/BD,0DAA4B;AAC5B,qDAAwC;AACxC,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,QAAQ,CAAC,CAAA;QAChC,4BAA4B;QAC5B,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,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,CAAA;gBAED,MAAM,gBAAgB,GAAG,MAAM,IAAA,oBAAY,EAAC;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,IAAA,wBAAgB,EAAC,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;AAhEY,QAAA,iBAAiB,qBAgE7B;AAED,MAAa,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;AAVD,4CAUC"}
package/package.json CHANGED
@@ -1,46 +1,68 @@
1
1
  {
2
2
  "name": "@scoutello/i18n-magic",
3
- "version": "0.16.0",
3
+ "version": "0.19.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
- "description": "CLI to help you manage your locales JSON with translations, replacements, etc. with OpenAI or Gemini",
6
+ "description": "Intelligent CLI toolkit that automates internationalization workflows with AI-powered translations for JavaScript/TypeScript projects",
7
+ "keywords": [
8
+ "i18n",
9
+ "internationalization",
10
+ "translation",
11
+ "localization",
12
+ "cli",
13
+ "ai",
14
+ "openai",
15
+ "gemini",
16
+ "react-i18next",
17
+ "next-i18next",
18
+ "vue-i18n",
19
+ "automation",
20
+ "typescript",
21
+ "javascript"
22
+ ],
23
+ "homepage": "https://github.com/BjoernRave/i18n-magic#readme",
24
+ "bugs": {
25
+ "url": "https://github.com/BjoernRave/i18n-magic/issues"
26
+ },
7
27
  "repository": {
8
28
  "type": "git",
9
29
  "url": "https://github.com/BjoernRave/i18n-magic"
10
30
  },
11
- "author": "scoutello",
31
+ "author": {
32
+ "name": "scoutello",
33
+ "url": "https://github.com/BjoernRave"
34
+ },
12
35
  "main": "dist/index.js",
13
- "module": "dist/i18n-magic.esm.js",
14
36
  "typings": "dist/index.d.ts",
15
37
  "types": "dist/index.d.ts",
16
- "bin": "dist/index.js",
38
+ "bin": "dist/cli.js",
17
39
  "exports": {
18
40
  ".": {
19
41
  "require": "./dist/index.js",
20
- "import": "./dist/i18n-magic.esm.js",
21
42
  "types": "./dist/index.d.ts"
22
43
  }
23
44
  },
24
45
  "files": ["dist", "src"],
25
46
  "scripts": {
26
47
  "analyze": "size-limit --why",
27
- "build": "dts build && echo '#!/usr/bin/env node' | cat - dist/index.js > temp && mv temp dist/index.js",
28
- "lint": "dts lint",
29
- "prepare": "dts build && echo '#!/usr/bin/env node' | cat - dist/index.js > temp && mv temp dist/index.js",
48
+ "build": "tsc && echo '#!/usr/bin/env node' | cat - dist/cli.js > temp && mv temp dist/cli.js",
49
+ "lint": "biome check src/",
50
+ "prepare": "npm run build",
30
51
  "size": "size-limit",
31
- "start": "dts watch",
32
- "test": "dts test"
52
+ "start": "tsc --watch",
53
+ "test": "jest"
33
54
  },
34
55
  "jest": {
35
56
  "testEnvironment": "node"
36
57
  },
37
58
  "engines": {
38
- "node": ">=18"
59
+ "node": ">=16"
39
60
  },
40
61
  "peerDependencies": {
41
62
  "openai": "^4.94.0"
42
63
  },
43
64
  "dependencies": {
65
+ "@modelcontextprotocol/sdk": "^1.12.0",
44
66
  "chalk": "^5.4.1",
45
67
  "commander": "^13.1.0",
46
68
  "dotenv": "^16.5.0",
@@ -52,11 +74,13 @@
52
74
  "devDependencies": {
53
75
  "@biomejs/biome": "1.9.4",
54
76
  "@tsconfig/recommended": "^1.0.8",
77
+ "@types/jest": "^29.5.12",
55
78
  "@types/node": "^20.12.12",
56
79
  "@types/prompts": "^2.4.9",
57
- "dts-cli": "^2.0.5",
80
+ "jest": "^29.7.0",
58
81
  "openai": "^4.94.0",
59
82
  "tslib": "^2.8.1",
60
83
  "typescript": "^5.8.3"
61
- }
84
+ },
85
+ "packageManager": "pnpm@10.2.1+sha512.398035c7bd696d0ba0b10a688ed558285329d27ea994804a52bad9167d8e3a72bcb993f9699585d3ca25779ac64949ef422757a6c31102c12ab932e5cbe5cc92"
62
86
  }