Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing translations dashboard #2981

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions site/gatsby-site/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const createBlogPages = require('./page-creators/createBlogPages');

const createDocPages = require('./page-creators/createDocPages');

const createMissingTranslationsPage = require('./page-creators/createMissingTranslationsPage');

const algoliasearch = require('algoliasearch');

const Translator = require('./src/utils/Translator');
Expand Down Expand Up @@ -75,6 +77,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
});

for (const pageCreator of [
createMissingTranslationsPage,
createBlogPages,
createCitationPages,
createWordCountsPages,
Expand Down
45 changes: 45 additions & 0 deletions site/gatsby-site/page-creators/createMissingTranslationsPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require('path');

const fs = require('fs');

const util = require('util');

const readFile = util.promisify(fs.readFile);

const readdir = util.promisify(fs.readdir);

const createMissingTranslationsPage = async (graphql, createPage) => {

let allLocales = [];

const locales = await readdir('./i18n/locales/');

allLocales = locales;

const translationEntries = [];

for (const locale of locales) {
const files = await readdir('./i18n/locales/' + locale);

for (const file of files) {
const json = await readFile(`./i18n/locales/${locale}/${file}`, 'utf8');

const data = JSON.parse(json);

for (const key of Object.keys(data)) {

const translation = data[key];

translationEntries.push({ locale, file, key, translation });
}
}
}

createPage({
path: '/meta/i18n',
component: path.resolve('./src/templates/missingTranslations.js'),
context: { allLocales, translationEntries },
});
};

module.exports = createMissingTranslationsPage;
Loading
Loading