Skip to content

Commit f47d54a

Browse files
author
alxndrsn
committed
Fix plural errors
1 parent 72d660d commit f47d54a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bin/util/transifex.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,19 @@ class PluralForms {
7777
if (forms.length > 2)
7878
logThenThrow(message, 'a pluralized message must have exactly two forms');
7979

80-
for (const form of forms) {
80+
for (let i=0; i<forms.length; ++i) {
81+
const form = forms[i];
82+
8183
if (form.includes('|')) logThenThrow(message, 'unexpected |');
8284

8385
const badWhitespace = form.match(/^\s+|\s+$|\s\s+/);
8486
if (badWhitespace) {
8587
const badLength = badWhitespace[0].length;
86-
console.error(`unexpected white space in translation string '${key}':`); // eslint-disable-line no-console
87-
console.error(` [${message}]`); // eslint-disable-line no-console
88-
console.error(` [${''.padStart(badLength, '^').padStart(badWhitespace.index + badLength, ' ').padEnd(message.length, ' ')}]`); // eslint-disable-line no-console
89-
throw new Error(`unexpected whitespace in message '${key}' at index ${badWhitespace.index} ("${message}")`);
88+
const badPath = forms.length === 1 ? key : `${key}[${i}]`;
89+
console.error(`unexpected white space in translation string '${badPath}':`); // eslint-disable-line no-console
90+
console.error(` [${form}]`); // eslint-disable-line no-console
91+
console.error(` [${''.padStart(badLength, '^').padStart(badWhitespace.index + badLength, ' ').padEnd(form.length, ' ')}]`); // eslint-disable-line no-console
92+
throw new Error(`unexpected whitespace in message '${badPath}' at index ${badWhitespace.index} ("${message}")`);
9093
}
9194
}
9295

0 commit comments

Comments
 (0)