translate-kit 0.2.0 → 0.3.1
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 +532 -114
- package/dist/cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var configSchema = z.object({
|
|
|
13
13
|
translation: z.object({
|
|
14
14
|
batchSize: z.number().int().positive().default(50),
|
|
15
15
|
context: z.string().optional(),
|
|
16
|
-
glossary: z.record(z.string()).optional(),
|
|
16
|
+
glossary: z.record(z.string(), z.string()).optional(),
|
|
17
17
|
tone: z.string().optional(),
|
|
18
18
|
retries: z.number().int().min(0).default(2),
|
|
19
19
|
concurrency: z.number().int().positive().default(3),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { loadConfig } from \"c12\";\nimport { z } from \"zod\";\nimport type { TranslateKitConfig } from \"./types.js\";\n\nconst configSchema = z\n .object({\n model: z.custom<TranslateKitConfig[\"model\"]>(\n (val) => val != null && typeof val === \"object\",\n { message: \"model must be an AI SDK LanguageModel instance\" },\n ),\n mode: z.enum([\"keys\", \"inline\"]).default(\"keys\"),\n sourceLocale: z.string().min(1),\n targetLocales: z.array(z.string().min(1)).min(1),\n messagesDir: z.string().min(1),\n translation: z\n .object({\n batchSize: z.number().int().positive().default(50),\n context: z.string().optional(),\n glossary: z.record(z.string()).optional(),\n tone: z.string().optional(),\n retries: z.number().int().min(0).default(2),\n concurrency: z.number().int().positive().default(3),\n validatePlaceholders: z.boolean().default(true).optional(),\n })\n .optional(),\n scan: z\n .object({\n include: z.array(z.string()),\n exclude: z.array(z.string()).optional(),\n translatableProps: z\n .array(z.string())\n .default([\"placeholder\", \"title\", \"alt\", \"aria-label\"]),\n i18nImport: z.string().default(\"next-intl\"),\n })\n .optional(),\n inline: z\n .object({\n componentPath: z.string().min(1),\n })\n .optional(),\n })\n .refine((data) => data.mode !== \"inline\" || data.inline != null, {\n message: \"inline options are required when mode is 'inline'\",\n path: [\"inline\"],\n });\n\nexport function defineConfig(config: TranslateKitConfig) {\n return config as TranslateKitConfig;\n}\n\nexport async function loadTranslateKitConfig(): Promise<TranslateKitConfig> {\n const { config } = await loadConfig({\n name: \"translate-kit\",\n });\n\n if (!config || Object.keys(config).length === 0) {\n throw new Error(\n \"No config found. Create a translate-kit.config.ts file or run `translate-kit init`.\",\n );\n }\n\n const result = configSchema.safeParse(config);\n if (!result.success) {\n const errors = result.error.issues\n .map((i) => ` - ${i.path.join(\".\")}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(`Invalid config:\\n${errors}`);\n }\n\n return result.data as TranslateKitConfig;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAGlB,IAAM,eAAe,EAClB,OAAO;AAAA,EACN,OAAO,EAAE;AAAA,IACP,CAAC,QAAQ,OAAO,QAAQ,OAAO,QAAQ;AAAA,IACvC,EAAE,SAAS,iDAAiD;AAAA,EAC9D;AAAA,EACA,MAAM,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,EAAE,QAAQ,MAAM;AAAA,EAC/C,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC9B,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAAA,EAC/C,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,aAAa,EACV,OAAO;AAAA,IACN,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE;AAAA,IACjD,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { loadConfig } from \"c12\";\nimport { z } from \"zod\";\nimport type { TranslateKitConfig } from \"./types.js\";\n\nconst configSchema = z\n .object({\n model: z.custom<TranslateKitConfig[\"model\"]>(\n (val) => val != null && typeof val === \"object\",\n { message: \"model must be an AI SDK LanguageModel instance\" },\n ),\n mode: z.enum([\"keys\", \"inline\"]).default(\"keys\"),\n sourceLocale: z.string().min(1),\n targetLocales: z.array(z.string().min(1)).min(1),\n messagesDir: z.string().min(1),\n translation: z\n .object({\n batchSize: z.number().int().positive().default(50),\n context: z.string().optional(),\n glossary: z.record(z.string(), z.string()).optional(),\n tone: z.string().optional(),\n retries: z.number().int().min(0).default(2),\n concurrency: z.number().int().positive().default(3),\n validatePlaceholders: z.boolean().default(true).optional(),\n })\n .optional(),\n scan: z\n .object({\n include: z.array(z.string()),\n exclude: z.array(z.string()).optional(),\n translatableProps: z\n .array(z.string())\n .default([\"placeholder\", \"title\", \"alt\", \"aria-label\"]),\n i18nImport: z.string().default(\"next-intl\"),\n })\n .optional(),\n inline: z\n .object({\n componentPath: z.string().min(1),\n })\n .optional(),\n })\n .refine((data) => data.mode !== \"inline\" || data.inline != null, {\n message: \"inline options are required when mode is 'inline'\",\n path: [\"inline\"],\n });\n\nexport function defineConfig(config: TranslateKitConfig) {\n return config as TranslateKitConfig;\n}\n\nexport async function loadTranslateKitConfig(): Promise<TranslateKitConfig> {\n const { config } = await loadConfig({\n name: \"translate-kit\",\n });\n\n if (!config || Object.keys(config).length === 0) {\n throw new Error(\n \"No config found. Create a translate-kit.config.ts file or run `translate-kit init`.\",\n );\n }\n\n const result = configSchema.safeParse(config);\n if (!result.success) {\n const errors = result.error.issues\n .map((i) => ` - ${i.path.join(\".\")}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(`Invalid config:\\n${errors}`);\n }\n\n return result.data as TranslateKitConfig;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAGlB,IAAM,eAAe,EAClB,OAAO;AAAA,EACN,OAAO,EAAE;AAAA,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E,OAAO,EAAE,IAAI,CAAC;AAAA,EACjC,CAAC,EACA,SAAS;AACd,CAAC,EACA,OAAO,CAAC,SAAS,KAAK,SAAS,YAAY,KAAK,UAAU,MAAM;AAAA,EAC/D,SAAS;AAAA,EACT,MAAM,CAAC,QAAQ;AACjB,CAAC;AAEI,SAAS,aAAa,QAA4B;AACvD,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "translate-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "AI-powered translation SDK for build time. Compatible with next-intl.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,27 +46,27 @@
|
|
|
46
46
|
"prepublishOnly": "bun run build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@babel/generator": "^7.
|
|
50
|
-
"@babel/parser": "^7.
|
|
51
|
-
"@babel/traverse": "^7.
|
|
52
|
-
"@babel/types": "^7.
|
|
53
|
-
"@clack/prompts": "^0.
|
|
54
|
-
"c12": "^
|
|
55
|
-
"citty": "^0.
|
|
49
|
+
"@babel/generator": "^7.29.1",
|
|
50
|
+
"@babel/parser": "^7.29.0",
|
|
51
|
+
"@babel/traverse": "^7.29.0",
|
|
52
|
+
"@babel/types": "^7.29.0",
|
|
53
|
+
"@clack/prompts": "^1.0.0",
|
|
54
|
+
"c12": "^4.0.0-beta.2",
|
|
55
|
+
"citty": "^0.2.0",
|
|
56
56
|
"dotenv": "^17.2.4",
|
|
57
|
-
"p-limit": "^
|
|
58
|
-
"picocolors": "^1.1.
|
|
57
|
+
"p-limit": "^7.3.0",
|
|
58
|
+
"picocolors": "^1.1.1",
|
|
59
59
|
"tinyglobby": "^0.2.15",
|
|
60
60
|
"tokenlens": "^1.3.1",
|
|
61
|
-
"zod": "^3.
|
|
61
|
+
"zod": "^4.3.6"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@types/babel__generator": "^7.
|
|
65
|
-
"@types/babel__traverse": "^7.
|
|
66
|
-
"@types/node": "^
|
|
67
|
-
"tsup": "^8.
|
|
68
|
-
"typescript": "^5.
|
|
69
|
-
"vitest": "^
|
|
64
|
+
"@types/babel__generator": "^7.27.0",
|
|
65
|
+
"@types/babel__traverse": "^7.28.0",
|
|
66
|
+
"@types/node": "^25.2.3",
|
|
67
|
+
"tsup": "^8.5.1",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"vitest": "^4.0.18"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"ai": ">=4.0.0"
|