2016-03-22 16:26:16 -04:00
|
|
|
/*
|
|
|
|
* spot checks the translation of the nav bar for a select set
|
|
|
|
* of languages that cover a number of types of translations.
|
|
|
|
*
|
|
|
|
* Languages checked:
|
|
|
|
* - Hebrew
|
|
|
|
* - Edible Scratch (fake language)
|
|
|
|
* - Mandarin
|
|
|
|
* - Japanese
|
|
|
|
* - Brasilian Portuguese
|
|
|
|
* - Polish
|
|
|
|
* - Norwegian
|
|
|
|
* - German
|
|
|
|
*/
|
2016-03-23 08:22:09 -04:00
|
|
|
var path = require('path');
|
2016-03-22 16:26:16 -04:00
|
|
|
var tap = require('tap');
|
2016-03-23 08:22:09 -04:00
|
|
|
|
|
|
|
var localeCompare = require('../../bin/lib/locale-compare');
|
2016-03-22 16:26:16 -04:00
|
|
|
var languagesToCheck = [
|
|
|
|
'he', 'zh-cn', 'ja', 'pt-br', 'pl', 'nb'
|
|
|
|
];
|
|
|
|
var idsToCheck = [
|
|
|
|
'general.about', 'general.create', 'general.help', 'general.joinScratch',
|
|
|
|
'general.signIn', 'general.discuss'
|
|
|
|
];
|
|
|
|
|
2016-03-23 08:22:09 -04:00
|
|
|
|
2016-05-19 06:56:45 -04:00
|
|
|
var ids = require(path.resolve(__dirname, '../../src/l10n.json'));
|
2016-05-17 15:56:06 -04:00
|
|
|
var viewLocales = {
|
|
|
|
general: {en: ids}
|
|
|
|
};
|
|
|
|
var idsWithICU = localeCompare.idToICUMap('general', ids);
|
|
|
|
var icuWithIds = localeCompare.icuToIdMap('general', ids);
|
2016-03-23 08:22:09 -04:00
|
|
|
var md5WithIds = localeCompare.getMD5Map(icuWithIds);
|
|
|
|
|
2016-03-22 16:26:16 -04:00
|
|
|
tap.test('spotCheckNavBar', function (t) {
|
|
|
|
for (var i in languagesToCheck) {
|
2016-03-23 08:22:09 -04:00
|
|
|
var translations = localeCompare.getTranslationsForLanguage(languagesToCheck[i], idsWithICU, md5WithIds);
|
2016-03-22 16:26:16 -04:00
|
|
|
for (var j in idsToCheck) {
|
|
|
|
t.notEqual(
|
2016-03-23 08:22:09 -04:00
|
|
|
translations['general'][languagesToCheck[i]][idsToCheck[j]],
|
|
|
|
viewLocales['general']['en'][idsToCheck[j]],
|
2016-03-22 16:26:16 -04:00
|
|
|
'check localization of ' + idsToCheck[j] + ' for ' + languagesToCheck[i]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
2016-03-23 08:22:09 -04:00
|
|
|
|
|
|
|
// Test splash items for fake language.
|
2016-03-22 16:26:16 -04:00
|
|
|
var fakeLanguageIdsToCheck = ['news.scratchNews', 'splash.featuredProjects', 'splash.featuredStudios'];
|
2016-03-23 08:22:09 -04:00
|
|
|
|
2016-05-19 06:56:45 -04:00
|
|
|
ids = require(path.resolve(__dirname, '../../src/views/splash/l10n.json'));
|
|
|
|
viewLocales = {
|
|
|
|
splash: {en: ids}
|
|
|
|
};
|
|
|
|
idsWithICU = localeCompare.idToICUMap('splash', ids);
|
|
|
|
icuWithIds = localeCompare.icuToIdMap('splash', ids);
|
2016-03-23 08:22:09 -04:00
|
|
|
md5WithIds = localeCompare.getMD5Map(icuWithIds);
|
|
|
|
|
2016-03-22 16:26:16 -04:00
|
|
|
tap.test('spotCheckNavBarFakeLanguage', function (t) {
|
2016-03-23 08:22:09 -04:00
|
|
|
var translations = localeCompare.getTranslationsForLanguage('yum', idsWithICU, md5WithIds);
|
2016-03-22 16:26:16 -04:00
|
|
|
for (var i in fakeLanguageIdsToCheck) {
|
|
|
|
t.notEqual(
|
2016-05-19 06:56:45 -04:00
|
|
|
translations['splash']['yum'][fakeLanguageIdsToCheck[i]],
|
2016-03-23 08:22:09 -04:00
|
|
|
viewLocales['splash']['en'][fakeLanguageIdsToCheck[i]],
|
2016-03-22 16:26:16 -04:00
|
|
|
'check localization of ' + fakeLanguageIdsToCheck[i] + ' for yum'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
t.end();
|
|
|
|
});
|