grammar
This commit is contained in:
parent
da2bf44d55
commit
e8093f5dc5
1 changed files with 4 additions and 4 deletions
|
@ -7,7 +7,7 @@ const locales = require(path.join(__dirname, '../site/.vuepress/i18n/locales.jso
|
||||||
* @param {*} path The already visited path
|
* @param {*} path The already visited path
|
||||||
*/
|
*/
|
||||||
const getLeaves = (node, path = null) => {
|
const getLeaves = (node, path = null) => {
|
||||||
if (typeof node === 'string') return leavePaths.push(path);
|
if (typeof node === 'string') return leafPaths.push(path);
|
||||||
if (typeof node != 'object') throw new Error(typeof node);
|
if (typeof node != 'object') throw new Error(typeof node);
|
||||||
const currentPath = path ? `${path}.` : '';
|
const currentPath = path ? `${path}.` : '';
|
||||||
Object.keys(node).forEach((key) => getLeaves(node[key], `${currentPath}${key}`));
|
Object.keys(node).forEach((key) => getLeaves(node[key], `${currentPath}${key}`));
|
||||||
|
@ -40,15 +40,15 @@ const defaultTranslation = translations.find((t) => t.lang === locales['/'].lang
|
||||||
console.log(`Default translation set to ${defaultTranslation.lang}`);
|
console.log(`Default translation set to ${defaultTranslation.lang}`);
|
||||||
|
|
||||||
// Holds the paths to all leaf nodes of the default translation
|
// Holds the paths to all leaf nodes of the default translation
|
||||||
const leavePaths = [];
|
const leafPaths = [];
|
||||||
getLeaves(defaultTranslation.values);
|
getLeaves(defaultTranslation.values);
|
||||||
console.log('Detected translations: ', leavePaths);
|
console.log('Detected translations: ', leafPaths);
|
||||||
|
|
||||||
// Compare all translations to the default translation
|
// Compare all translations to the default translation
|
||||||
translations.forEach((t) => {
|
translations.forEach((t) => {
|
||||||
console.log(`Comparing ${t.lang} to ${defaultTranslation.lang}`);
|
console.log(`Comparing ${t.lang} to ${defaultTranslation.lang}`);
|
||||||
|
|
||||||
leavePaths.forEach((p) => {
|
leafPaths.forEach((p) => {
|
||||||
const value = getNestedProperty(t.values, p);
|
const value = getNestedProperty(t.values, p);
|
||||||
if (value == null || typeof value !== 'string') {
|
if (value == null || typeof value !== 'string') {
|
||||||
console.warn(`${t.lang} is missing a translation at '${p}'`);
|
console.warn(`${t.lang} is missing a translation at '${p}'`);
|
||||||
|
|
Loading…
Reference in a new issue