-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'quark-bot-discord:main' into main
- Loading branch information
Showing
60 changed files
with
954 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
function readJson(filePath) { | ||
const rawData = fs.readFileSync(filePath, 'utf8'); | ||
return JSON.parse(rawData); | ||
} | ||
|
||
function getAllJsonFiles(directory) { | ||
let jsonFiles = []; | ||
const files = fs.readdirSync(directory); | ||
|
||
files.forEach(file => { | ||
const fullPath = path.join(directory, file); | ||
if (fs.statSync(fullPath).isDirectory()) { | ||
jsonFiles = jsonFiles.concat(getAllJsonFiles(fullPath)); | ||
} else if (file.endsWith('.json')) { | ||
jsonFiles.push(fullPath); | ||
} | ||
}); | ||
|
||
return jsonFiles; | ||
} | ||
|
||
function compareJsonFiles(enUsDir, otherLangDir) { | ||
const enUsFiles = getAllJsonFiles(enUsDir); | ||
const otherLangFiles = getAllJsonFiles(otherLangDir); | ||
|
||
const enUsFilesRelative = enUsFiles.map(file => path.relative(enUsDir, file)); | ||
const otherLangFilesRelative = otherLangFiles.map(file => path.relative(otherLangDir, file)); | ||
|
||
const missingFiles = enUsFilesRelative.filter(file => !otherLangFilesRelative.includes(file)); | ||
|
||
const missingKeys = {}; | ||
|
||
enUsFilesRelative.forEach(file => { | ||
if (otherLangFilesRelative.includes(file)) { | ||
const enUsJson = readJson(path.join(enUsDir, file)); | ||
const otherLangJson = readJson(path.join(otherLangDir, file)); | ||
|
||
const missingKeysInFile = Object.keys(enUsJson).filter(key => !otherLangJson.hasOwnProperty(key)); | ||
if (missingKeysInFile.length > 0) { | ||
missingKeys[file] = missingKeysInFile; | ||
} | ||
} | ||
}); | ||
|
||
return { missingFiles, missingKeys }; | ||
} | ||
|
||
function compareAllLanguages(baseDir) { | ||
const enUsDir = path.join(baseDir, 'en_us'); | ||
const languages = fs.readdirSync(baseDir).filter(dir => fs.statSync(path.join(baseDir, dir)).isDirectory() && dir !== 'en_us'); | ||
|
||
const report = {}; | ||
|
||
languages.forEach(lang => { | ||
const langDir = path.join(baseDir, lang); | ||
const { missingFiles, missingKeys } = compareJsonFiles(enUsDir, langDir); | ||
report[lang] = { missingFiles, missingKeys }; | ||
}); | ||
|
||
return report; | ||
} | ||
|
||
const baseDirectory = './bot/'; | ||
const comparisonReport = compareAllLanguages(baseDirectory); | ||
|
||
for (const [lang, report] of Object.entries(comparisonReport)) { | ||
console.log(`Language: ${lang}`); | ||
console.log(` Missing files: ${report.missingFiles.length > 0 ? report.missingFiles.join(', ') : 'None'}`); | ||
console.log(` Missing keys: ${Object.keys(report.missingKeys).length > 0 ? JSON.stringify(report.missingKeys, null, 2) : 'None'}`); | ||
console.log(); | ||
} |
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,13 @@ | ||
name: Language comparison | ||
|
||
on: [workflow_dispatch] | ||
|
||
jobs: | ||
compare-languages: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Compare language files | ||
run: node .github/scripts/compare-languages.js |
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,4 @@ | ||
{ | ||
"1": "Admin", | ||
"2": "Basic" | ||
} |
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,3 @@ | ||
{ | ||
"none": "none" | ||
} |
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,3 @@ | ||
{ | ||
"none": "none" | ||
} |
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,12 @@ | ||
{ | ||
"ignoreTargets": "Ignore Target Users", | ||
"ignoreExecutors": "Ignore Target Executors", | ||
"specificMessageContent": "Ignore Specific Message Content", | ||
"ignoreChannels": "Ignore Channels", | ||
"ignoreBotExecutors": "Ignore Bot Executors", | ||
"ignoreBotTargets": "Ignore Bot Targets", | ||
"ignoreExecutorRoles": "Ignore Executor Roles", | ||
"ignoreTargetRoles": "Ignore Target Roles", | ||
"ignoreCategories": "Ignore Categories", | ||
"activeIgnore": "Active Ignore" | ||
} |
Oops, something went wrong.