mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
fa566ac140
Since it's using `require` to get the localisation strings, check if the error is `MODULE_NOT_FOUND` before moving on – because if it isn't, then there is an unknown error that should be thrown. Thanks @rschamp for the suggestion!
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
/*
|
|
* spot check that each language has values for the string id keys on Cards page
|
|
* that are contained in English (i.e. make sure strings will show up, not ids")
|
|
*/
|
|
var merge = require('lodash.merge');
|
|
var path = require('path');
|
|
var tap = require('tap');
|
|
|
|
var languages = require('../../languages.json');
|
|
var localeCompare = require('../../bin/lib/locale-compare');
|
|
|
|
tap.test('spotCheckCardStrings', function (t) {
|
|
var isoCodes = Object.keys(languages);
|
|
isoCodes.splice(isoCodes.indexOf('en'), 1);
|
|
|
|
var ids = require(path.resolve(__dirname, '../../src/views/cards/l10n.json'));
|
|
var viewLocales = {
|
|
cards: {en: ids}
|
|
};
|
|
var idsWithICU = localeCompare.idToICUMap('cards', ids);
|
|
var icuWithIds = localeCompare.icuToIdMap('cards', ids);
|
|
var md5WithIds = localeCompare.getMD5Map(icuWithIds);
|
|
var keysToCheck = Object.keys(merge(viewLocales['cards']['en'])).sort();
|
|
for (var i in isoCodes) {
|
|
var translations = localeCompare.getTranslationsForLanguage(isoCodes[i], idsWithICU, md5WithIds);
|
|
t.same(
|
|
Object.keys(translations['cards'][isoCodes[i]]).sort(),
|
|
keysToCheck,
|
|
'check Cards keys for language ' + isoCodes[i]
|
|
);
|
|
}
|
|
t.end();
|
|
});
|