i18nizer 0.1.2 → 0.1.3

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.
@@ -63,14 +63,13 @@ export default class Extract extends Command {
63
63
  locales,
64
64
  texts: texts.map((t) => t.text),
65
65
  });
66
- // Pasamos el provider a la función
67
66
  const raw = await generateTranslations(prompt, provider);
68
67
  if (!raw)
69
68
  throw new Error("AI did not return any data");
70
69
  const json = parseAiJson(raw);
71
70
  writeLocaleFiles(componentName, json, locales);
72
71
  spinner.succeed(`✅ Translations generated with ${provider}`);
73
- const namespace = componentName.toLowerCase();
72
+ const namespace = componentName;
74
73
  const aiGeneratedKeys = Object.keys(json[namespace] || {});
75
74
  const mapped = texts.map((e, i) => ({
76
75
  key: aiGeneratedKeys[i],
@@ -4,7 +4,7 @@ import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
6
  import OpenAI from "openai";
7
- const CONFIG_FILE = path.join(os.homedir(), ".18nizer", "api-keys.json");
7
+ const CONFIG_FILE = path.join(os.homedir(), ".i18nizer", "api-keys.json");
8
8
  function loadApiKeys() {
9
9
  if (!fs.existsSync(CONFIG_FILE)) {
10
10
  console.warn(`⚠️ API keys file not found: ${CONFIG_FILE}`);
@@ -1,30 +1,29 @@
1
- export function buildPrompt({ componentName, locales, texts, }) {
1
+ export function buildPrompt({ componentName, locales, texts }) {
2
2
  return `
3
- You are an i18n automation tool.
3
+ You are an i18n automation tool for React components.
4
4
 
5
5
  TASK:
6
6
  Generate translation keys and translations for a React component.
7
7
 
8
8
  RULES:
9
- - Keys must be camelCase
9
+ - Keys must be camelCase and always in English
10
10
  - Namespace must be "${componentName}"
11
- - Languages: ${locales.join(", ")}
11
+ - Include translations for all requested languages: ${locales.join(", ")}
12
12
  - Do NOT invent or modify meaning
13
- - Do NOT add explanations
14
- - Do NOT add markdown
13
+ - Do NOT include explanations or comments
14
+ - Do NOT add markdown or extra text
15
15
  - Output ONLY valid JSON
16
16
 
17
17
  FORMAT EXACTLY:
18
18
  {
19
19
  "${componentName}": {
20
- "keyName": {
21
- "${locales[0]}": "...",
22
- "${locales[1]}": "..."
20
+ "keyNameInEnglish": {
21
+ ${locales.map((l) => `"${l}": "..."`).join(",\n ")}
23
22
  }
24
23
  }
25
24
  }
26
25
 
27
- TEXTS:
26
+ TEXTS TO TRANSLATE:
28
27
  ${texts.map((t) => `"${t}"`).join("\n")}
29
28
  `.trim();
30
29
  }
@@ -161,5 +161,5 @@
161
161
  ]
162
162
  }
163
163
  },
164
- "version": "0.1.2"
164
+ "version": "0.1.3"
165
165
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18nizer",
3
3
  "description": "CLI to extract texts from JSX/TSX and generate i18n JSON with AI translations",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "author": "Yoannis Sanchez Soto",
6
6
  "bin": "./bin/run.js",
7
7
  "bugs": "https://github.com/tools/i18nizer/issues",