diff --git a/README.md b/README.md index 47a9f07..4028318 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ with: ## Example Integration Workflow This workflow can be used to validate that all language files are alphabetized. Any language file being out of order will cause the workflow to throw an error. +The workflow will also throw an error if any keys exists in a language file and do not exist in the base file. ```yaml name: Verify all i18n files are alphabetized diff --git a/copy_keys.js b/copy_keys.js index e768a91..f964098 100644 --- a/copy_keys.js +++ b/copy_keys.js @@ -39,6 +39,13 @@ function updateJSONFiles(baseFileName, directory) { if (filename.endsWith('.json') && filename !== baseFileName) { let otherData = loadJSONFile(filePath); + // Check if there are keys in another langague that are not in the base English file + for (const key in otherData) { + if (!(key in sortedBaseData)) { + throw new Error(`Key '${key}' found in '${filename}' but not in '${baseFileName}' file`); + } + } + // Copy missing fields from the base data for (const key in sortedBaseData) { if (!(key in otherData)) { diff --git a/dist/index.js b/dist/index.js index be41c87..3d68b97 100644 --- a/dist/index.js +++ b/dist/index.js @@ -26632,6 +26632,13 @@ function updateJSONFiles(baseFileName, directory) { if (filename.endsWith('.json') && filename !== baseFileName) { let otherData = loadJSONFile(filePath); + // Check if there are keys in another langague that are not in the base English file + for (const key in otherData) { + if (!(key in sortedBaseData)) { + throw new Error(`Key '${key}' found in '${filename}' but not in '${baseFileName}' file`); + } + } + // Copy missing fields from the base data for (const key in sortedBaseData) { if (!(key in otherData)) {