Improved i18n tests to include commits with missing i18n.js entries (#21175)

no ref

We've had several PRs for new locales that forgot to update i18n.js,
which causes them not to get regenerated by yarn translate. This PR
checks for that error, and also the reverse one where they update i18n
but we're missing folders. (Never expected to error, because 'yarn test'
is defined to include 'yarn translate', which generates the folders.)
This commit is contained in:
Cathy Sarisky 2024-10-01 16:04:21 -04:00 committed by GitHub
parent 6e599ef541
commit b9547cc120
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,4 +69,25 @@ describe('i18n', function () {
});
});
});
describe('directories and locales in i18n.js will match', function () {
it('should have a key for each directory in the locales directory', async function () {
const locales = await fs.readdir(path.join(__dirname, '../locales'));
const supportedLocales = i18n.SUPPORTED_LOCALES;
for (const locale of locales) {
if (locale !== 'context.json') {
assert(supportedLocales.includes(locale), `The locale ${locale} is not in the list of supported locales`);
}
}
});
it('should have a directory for each key in lib/i18n.js', async function () {
const supportedLocales = i18n.SUPPORTED_LOCALES;
for (const locale of supportedLocales) {
const localeDir = path.join(__dirname, `../locales/${locale}`);
const stats = await fs.stat(localeDir);
assert(stats.isDirectory(), `The locale ${locale} does not have a directory`);
}
});
});
});