-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3792da4
commit b0c5863
Showing
14 changed files
with
178 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
|
||
// const __dirname = path.dirname(new URL(import.meta.url).pathname) | ||
const ProjectSourceRoot = path.resolve(__dirname, '..') | ||
|
||
const directoryPath = path.join(ProjectSourceRoot, './src/locales') | ||
const englishJsonFilename = 'en-US.json' // Set the English JSON filename | ||
|
||
// Function to load JSON files and check for untranslated strings | ||
function findUntranslatedStrings(dirPath) { | ||
const files = fs.readdirSync(dirPath) | ||
const englishFilePath = path.join(dirPath, englishJsonFilename) | ||
const englishData = fs.readJsonSync(englishFilePath) | ||
const untranslated = {} | ||
|
||
files.forEach((file) => { | ||
if (path.extname(file) === '.json' && file !== englishJsonFilename) { | ||
const filePath = path.join(dirPath, file) | ||
const data = fs.readJsonSync(filePath) | ||
const languageCode = path.basename(file, '.json') | ||
|
||
// Check each key in the JSON file | ||
Object.entries(data).forEach(([key, value]) => { | ||
if (value === '') { | ||
if (!untranslated[key]) { | ||
untranslated[key] = { | ||
untranslated: [], | ||
englishSource: | ||
englishData[key] || | ||
'No English source available', | ||
} | ||
} | ||
untranslated[key].untranslated.push(languageCode) | ||
} | ||
}) | ||
} | ||
}) | ||
|
||
return untranslated | ||
} | ||
|
||
// Execute the function and log the results | ||
const untranslated = findUntranslatedStrings(directoryPath) | ||
console.log(JSON.stringify(untranslated, null, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.