Skip to content

Commit 6cf3742

Browse files
committed
tools/check-messages-en: Check for mismatched message entries
1 parent a0c97c9 commit 6cf3742

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/check-messages-en

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ function getPossibleUiStrings(possibleUiStringFilePaths) {
165165
}
166166

167167
function main() {
168+
// We use a convention where a message's ID matches its value; a mismatch
169+
// is probably accidental.
170+
const mismatchedMessageEntries = Object.entries(messages_en).filter(
171+
([messageId, message]) => messageId !== message,
172+
);
173+
if (mismatchedMessageEntries.length > 0) {
174+
console.error(
175+
'Each message in static/translations/messages_en.json should match its ID, but some do not:',
176+
);
177+
console.error(mismatchedMessageEntries);
178+
process.exit(1);
179+
}
180+
168181
// Mobile's style is to use curly quotes. They look nicer, but also: since
169182
// v3, react-intl uses the single straight quote as an escape character:
170183
// https://formatjs.io/docs/intl-messageformat/#features

0 commit comments

Comments
 (0)