diff options
author | Christoph Cullmann <cullmann@kde.org> | 2024-04-28 17:33:09 +0200 |
---|---|---|
committer | Christoph Cullmann <cullmann@kde.org> | 2024-04-28 17:33:09 +0200 |
commit | e77051ccc4b47951bfa4fde2be436b1bb2fb113b (patch) | |
tree | f0b75ee3521da9c8cd39dac4359212348f70e4e8 /themes/blowfish/findMissingTranslations.js | |
parent | 4b355837824ac2422d371acef790f0f4249255c7 (diff) |
use https://github.com/nunocoracao/blowfish.git
Diffstat (limited to 'themes/blowfish/findMissingTranslations.js')
-rw-r--r-- | themes/blowfish/findMissingTranslations.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/themes/blowfish/findMissingTranslations.js b/themes/blowfish/findMissingTranslations.js new file mode 100644 index 0000000..67eebce --- /dev/null +++ b/themes/blowfish/findMissingTranslations.js @@ -0,0 +1,75 @@ +const fs = require('fs'); + +const configDir = "./exampleSite/config/_default"; +const contentDir = "./exampleSite/content"; +const defaultLang = "en"; + +var targetLangs = [] + +function readConfigs() { + const files = fs.readdirSync(configDir); + files.forEach(file => { + //console.log(file) + if(file.indexOf("languages.") > -1) { + var lang = file.split(".")[1]; + //console.log(lang) + if(lang != defaultLang) { + targetLangs.push(lang); + } + } + }); +} + +async function processFile(filePath, file) { + if (filePath.indexOf("index.md") > -1) { + + //console.log("processing", filePath) + + for(var i in targetLangs) { + const targetLang = targetLangs[i]; + var targetFilePath = filePath.replace(".md", "." + targetLang + ".md"); + //var targetFileName = file.replace(".md", "." + targetLang + ".md"); + + if(fs.existsSync(targetFilePath)) { + //console.log("file already exists", targetFilePath); + + const data = fs.readFileSync(filePath, 'utf8'); + const data2 = fs.readFileSync(targetFilePath, 'utf8'); + if(data != data2) { + //console.log("file contents are different", targetFilePath); + }else{ + //console.log("file contents are the same", targetFilePath); + console.log(targetFilePath); + //process.exit(1); + } + + }else{ + //console.log("file does not exist", targetFilePath); + } + } + + } else + return +} + +async function processFolder(folderPath) { + const files = fs.readdirSync(folderPath); + + for (var i in files) { + const file = files[i]; + const filePath = `${folderPath}/${file}`; + const isDir = fs.lstatSync(filePath).isDirectory(); + if (isDir) { + await processFolder(filePath); + } else { + await processFile(filePath, file); + } + } +} + +async function createLinks() { + processFolder(contentDir); +} + +readConfigs(); +createLinks();
\ No newline at end of file |