mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-09-03 22:45:21 +00:00
fix: ru.json duplicate AUDIO_BACK, add dupe detection to locale tests
This commit is contained in:
@@ -189,7 +189,6 @@
|
|||||||
"AUDIO_OPEN_SETTINGS": "Открыть",
|
"AUDIO_OPEN_SETTINGS": "Открыть",
|
||||||
"NEW_FEATURE_AUDIO": "Новое: Обработка звука — попробуйте компрессор!",
|
"NEW_FEATURE_AUDIO": "Новое: Обработка звука — попробуйте компрессор!",
|
||||||
"AUDIO_BACK": "← Назад",
|
"AUDIO_BACK": "← Назад",
|
||||||
"AUDIO_BACK": "← Назад",
|
|
||||||
"AUDIO_PAGE_TITLE": "Настройки звука",
|
"AUDIO_PAGE_TITLE": "Настройки звука",
|
||||||
"AUDIO_MASTER_TOGGLE": "Обработка звука",
|
"AUDIO_MASTER_TOGGLE": "Обработка звука",
|
||||||
"AUDIO_COMPRESSOR": "Компрессор",
|
"AUDIO_COMPRESSOR": "Компрессор",
|
||||||
|
|||||||
+20
-1
@@ -55,7 +55,26 @@ console.log(`Auditing i18n locales using ${enKeys.length} baseline keys from en.
|
|||||||
for (const file of localeFiles) {
|
for (const file of localeFiles) {
|
||||||
const filePath = path.join(localesDir, file);
|
const filePath = path.join(localesDir, file);
|
||||||
try {
|
try {
|
||||||
const dict = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
const raw = fs.readFileSync(filePath, 'utf8');
|
||||||
|
|
||||||
|
// Check for duplicate keys in raw JSON before parsing
|
||||||
|
const keyRe = /"(\w+)"\s*:/g;
|
||||||
|
const seenKeys = {};
|
||||||
|
let dupes = [];
|
||||||
|
let m;
|
||||||
|
while ((m = keyRe.exec(raw)) !== null) {
|
||||||
|
if (seenKeys[m[1]]) {
|
||||||
|
dupes.push(m[1]);
|
||||||
|
}
|
||||||
|
seenKeys[m[1]] = true;
|
||||||
|
}
|
||||||
|
if (dupes.length > 0) {
|
||||||
|
hasError = true;
|
||||||
|
console.error(`❌ ${file} has duplicate keys: ${[...new Set(dupes)].join(', ')}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dict = JSON.parse(raw);
|
||||||
const keys = Object.keys(dict);
|
const keys = Object.keys(dict);
|
||||||
|
|
||||||
const missingKeys = enKeys.filter(k => !keys.includes(k));
|
const missingKeys = enKeys.filter(k => !keys.includes(k));
|
||||||
|
|||||||
@@ -27,7 +27,26 @@ console.log(`Auditing website i18n locales using ${enKeys.length} baseline keys
|
|||||||
for (const file of localeFiles) {
|
for (const file of localeFiles) {
|
||||||
const filePath = path.join(localesDir, file);
|
const filePath = path.join(localesDir, file);
|
||||||
try {
|
try {
|
||||||
const dict = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
const raw = fs.readFileSync(filePath, 'utf8');
|
||||||
|
|
||||||
|
// Check for duplicate keys in raw JSON before parsing
|
||||||
|
const keyRe = /"(\w+)"\s*:/g;
|
||||||
|
const seenKeys = {};
|
||||||
|
let dupes = [];
|
||||||
|
let m;
|
||||||
|
while ((m = keyRe.exec(raw)) !== null) {
|
||||||
|
if (seenKeys[m[1]]) {
|
||||||
|
dupes.push(m[1]);
|
||||||
|
}
|
||||||
|
seenKeys[m[1]] = true;
|
||||||
|
}
|
||||||
|
if (dupes.length > 0) {
|
||||||
|
hasError = true;
|
||||||
|
console.error(`❌ ${file} has duplicate keys: ${[...new Set(dupes)].join(', ')}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dict = JSON.parse(raw);
|
||||||
const keys = Object.keys(dict).sort();
|
const keys = Object.keys(dict).sort();
|
||||||
|
|
||||||
const missingKeys = enKeys.filter(k => !keys.includes(k));
|
const missingKeys = enKeys.filter(k => !keys.includes(k));
|
||||||
|
|||||||
Reference in New Issue
Block a user