Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Sync missing translation keys in app/locales/*.json files to a Google Sheet #481

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
ported over script usage
  • Loading branch information
michaelmcmillan committed Mar 29, 2020
commit 004d5e059ba6da56dda36ea47b371bf44bb8c9d6
13 changes: 11 additions & 2 deletions ops/lost-in-translation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const { spawnSync } = require('child_process');

/**
* This script finds all the english translation keys across
* all commits (including branches and pull requests) for each
* locale.json in app/locales. Afterwards it looks at each locale
* separately to see if it's missing any one the english keys.
* Usage: node ops/lost-in-translation.js
* Important: You need to run it from the root directory.
*/

/**
* Calls git cli with arguments and returns stdout.
*/
Expand Down Expand Up @@ -49,7 +58,7 @@ function retrieveJSONForFileAtCommitHash(filePath, commitHash) {
allLocales = new Set(['no', 'se']);
allEnglishTranslationKeys = new Set([]);
for (const locale of allLocales) {
const filePath = `../app/locales/${locale}.json`;
const filePath = `app/locales/${locale}.json`;
for (const commitHash of findCommitHashesForFile(filePath)) {
const translation = retrieveJSONForFileAtCommitHash(filePath, commitHash);
for (const translationKey of Object.keys(translation)) {
Expand All @@ -71,7 +80,7 @@ for (const locale of allLocales) {
*/
const translationKeysByLocale = {};
for (const locale of allLocales) {
const filePath = `../app/locales/${locale}.json`;
const filePath = `app/locales/${locale}.json`;
for (const commitHash of findCommitHashesForFile(filePath)) {
const translation = retrieveJSONForFileAtCommitHash(filePath, commitHash);
if (translationKeysByLocale[locale] === undefined) {
Expand Down