fix(i18n,client): translatable cta url (#41384)

This commit is contained in:
Nicholas Carrigan (he/him)
2021-03-12 16:14:54 -08:00
committed by GitHub
parent c198d508be
commit f1c8a9825b
14 changed files with 113 additions and 40 deletions

View File

@@ -5,6 +5,7 @@ const trendingSchema = require('./locales/english/trending.json');
const motivationSchema = require('./locales/english/motivation.json');
const introSchema = require('./locales/english/intro.json');
const metaTagsSchema = require('./locales/english/meta-tags.json');
const linksSchema = require('./locales/english/links.json');
/**
* Flattens a nested object structure into a single
@@ -106,6 +107,7 @@ const trendingSchemaKeys = Object.keys(flattenAnObject(trendingSchema));
const motivationSchemaKeys = Object.keys(flattenAnObject(motivationSchema));
const introSchemaKeys = Object.keys(flattenAnObject(introSchema));
const metaTagsSchemaKeys = Object.keys(flattenAnObject(metaTagsSchema));
const linksSchemaKeys = Object.keys(flattenAnObject(linksSchema));
/**
* Function that checks the translations.json file
@@ -219,8 +221,8 @@ const introSchemaValidation = languages => {
const filePath = path.join(__dirname, `/locales/${language}/intro.json`);
const fileJson = require(filePath);
const fileKeys = Object.keys(flattenAnObject(fileJson));
findMissingKeys(fileKeys, introSchemaKeys, `${language}/intro.json`);
findExtraneousKeys(fileKeys, introSchemaKeys, `${language}/intro.json`);
findMissingKeys(fileKeys, linksSchemaKeys, `${language}/intro.json`);
findExtraneousKeys(fileKeys, linksSchemaKeys, `${language}/intro.json`);
const emptyKeys = noEmptyObjectValues(fileJson);
if (emptyKeys.length) {
console.warn(
@@ -257,6 +259,23 @@ const metaTagsSchemaValidation = languages => {
});
};
const linksSchemaValidation = languages => {
languages.forEach(language => {
const filePath = path.join(__dirname, `/locales/${language}/links.json`);
const fileJson = require(filePath);
const fileKeys = Object.keys(flattenAnObject(fileJson));
findMissingKeys(fileKeys, introSchemaKeys, `${language}/links.json`);
findExtraneousKeys(fileKeys, introSchemaKeys, `${language}/links.json`);
const emptyKeys = noEmptyObjectValues(fileJson);
if (emptyKeys.length) {
console.warn(
`${language}/links.json has these empty keys: ${emptyKeys.join(', ')}`
);
}
console.info(`${language} links.json validation complete`);
});
};
const translatedLangs = availableLangs.client.filter(x => x !== 'english');
translationSchemaValidation(translatedLangs);
@@ -264,3 +283,4 @@ trendingSchemaValidation(translatedLangs);
motivationSchemaValidation(translatedLangs);
introSchemaValidation(translatedLangs);
metaTagsSchemaValidation(translatedLangs);
linksSchemaValidation(translatedLangs);