Skip to content

Commit 017c739

Browse files
committed
tools/check-messages-en: Check for mismatched message entries
1 parent 29376e7 commit 017c739

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
@@ -163,6 +163,19 @@ function getPossibleUiStrings(possibleUiStringFilePaths) {
163163
function main() {
164164
let didError = false;
165165

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

0 commit comments

Comments
 (0)