From 287e619967596a2008848a04dd504c3488d38059 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Wed, 27 May 2026 09:35:00 +0100 Subject: [PATCH] Merge pull request #33663 from overleaf/td-en-json-sort-hook Sort staged locale files in the pre-commit hook GitOrigin-RevId: fb3a155be52495305372c5c5cc54c2f50e88c417 --- services/web/scripts/translations/sort-locale-file.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 services/web/scripts/translations/sort-locale-file.js diff --git a/services/web/scripts/translations/sort-locale-file.js b/services/web/scripts/translations/sort-locale-file.js new file mode 100644 index 0000000000..6fb50c0ddc --- /dev/null +++ b/services/web/scripts/translations/sort-locale-file.js @@ -0,0 +1,9 @@ +import fs from 'fs' + +const file = process.argv[2] +if (!file) { + console.error('Usage: node sort-locale-file.js ') + process.exit(1) +} +const obj = JSON.parse(fs.readFileSync(file, 'utf8')) +fs.writeFileSync(file, JSON.stringify(obj, Object.keys(obj).sort(), 2) + '\n')