Skip to content

Commit 02072ba

Browse files
Make translation extraction deterministic by sorting keys (#4056)
1 parent 5ec57eb commit 02072ba

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ui/scripts/sort-translations.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ if (!file) {
66
process.exit(1);
77
}
88

9-
const json = JSON.parse(fs.readFileSync(file, 'utf8'));
9+
if (!fs.existsSync(file)) {
10+
console.error(`File not found: ${file}`);
11+
process.exit(1);
12+
}
13+
14+
let json;
15+
try {
16+
json = JSON.parse(fs.readFileSync(file, 'utf8'));
17+
} catch (err) {
18+
console.error(
19+
`Error: File "${file}" does not contain valid JSON: ${err.message}`,
20+
);
21+
process.exit(1);
22+
}
1023

1124
const sorted = Object.keys(json)
1225
.sort((a, b) => a.localeCompare(b))

0 commit comments

Comments
 (0)