lingo-linter-tool 1.0.4 → 1.0.6
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/healer/index.js +18 -9
- package/package.json +1 -1
package/dist/healer/index.js
CHANGED
|
@@ -41,13 +41,18 @@ async function healIssues(issues, localesDir) {
|
|
|
41
41
|
if (!fs.existsSync(configPath)) {
|
|
42
42
|
console.log(chalk_1.default.yellow("⚠️ i18n.json not found. Auto-generating default config..."));
|
|
43
43
|
const defaultConfig = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
version: 1,
|
|
45
|
+
buckets: [
|
|
46
|
+
{
|
|
47
|
+
id: "frontend",
|
|
48
|
+
source: "en",
|
|
49
|
+
patterns: ["src/**/*.{ts,tsx,js,jsx}"],
|
|
50
|
+
output: "src/locales/{{lang}}.json",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
48
53
|
};
|
|
49
54
|
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
50
|
-
console.log(chalk_1.default.green("✅ Created i18n.json"));
|
|
55
|
+
console.log(chalk_1.default.green("✅ Created valid i18n.json with buckets"));
|
|
51
56
|
}
|
|
52
57
|
const enPath = path.join(localesDir, "en.json");
|
|
53
58
|
let enContent = {};
|
|
@@ -60,24 +65,28 @@ async function healIssues(issues, localesDir) {
|
|
|
60
65
|
missingKeys.forEach((issue) => {
|
|
61
66
|
if (issue.key && !enContent[issue.key]) {
|
|
62
67
|
const humanText = issue.key.split(".").pop() || issue.key;
|
|
63
|
-
|
|
68
|
+
const formattedText = humanText.charAt(0).toUpperCase() + humanText.slice(1);
|
|
69
|
+
enContent[issue.key] = formattedText;
|
|
64
70
|
hasChanges = true;
|
|
65
71
|
}
|
|
66
72
|
});
|
|
67
73
|
if (hasChanges) {
|
|
68
74
|
fs.writeFileSync(enPath, JSON.stringify(enContent, null, 2));
|
|
69
|
-
console.log(chalk_1.default.gray(
|
|
75
|
+
console.log(chalk_1.default.gray(` ➕ Injected ${missingKeys.length} missing keys into en.json`));
|
|
70
76
|
}
|
|
77
|
+
console.log(chalk_1.default.gray("\n📄 i18n.json contents:\n"));
|
|
78
|
+
console.log(fs.readFileSync(configPath, "utf-8"));
|
|
71
79
|
try {
|
|
72
80
|
console.log(chalk_1.default.magenta("🚀 Triggering Lingo.dev AI Translation..."));
|
|
73
|
-
(0, child_process_1.execSync)("npx lingo
|
|
81
|
+
(0, child_process_1.execSync)("npx lingo translate --force", {
|
|
74
82
|
stdio: "inherit",
|
|
75
83
|
cwd: projectRoot,
|
|
76
84
|
});
|
|
77
85
|
console.log(chalk_1.default.green("\n✅ Auto-Healing Complete!"));
|
|
78
86
|
}
|
|
79
87
|
catch (error) {
|
|
80
|
-
console.error(chalk_1.default.red("❌ Failed to run lingo.dev CLI."));
|
|
88
|
+
console.error(chalk_1.default.red("\n❌ Failed to run lingo.dev CLI."));
|
|
89
|
+
console.error(chalk_1.default.yellow(" Ensure you have an OpenAI API Key in your .env or GitHub Secrets."));
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
exports.healIssues = healIssues;
|