diff --git a/src/modules/config/JSONLocale.loader.ts b/src/modules/config/JSONLocale.loader.ts index 485e539d..e2c0b433 100644 --- a/src/modules/config/JSONLocale.loader.ts +++ b/src/modules/config/JSONLocale.loader.ts @@ -4,22 +4,25 @@ import path from "node:path"; export class JSONLocaleLoader { public constructor(private readonly path: string) {} + private ignoredFoldersAndFiles = [".git", "crowdin.yml"]; + public async loadTranslations() { const locales: Record> = {}; - const folders = fs.readdirSync(this.path); + const folders = fs.readdirSync(this.path).filter((f) => !this.ignoredFoldersAndFiles.includes(f)); for (const langFolder of folders) { const langPath = path.join(this.path, langFolder); - const namespaces = fs.readdirSync(langPath); + const namespaces = fs.readdirSync(langPath).filter((f) => !this.ignoredFoldersAndFiles.includes(f)); const langData = {}; for (const namespace of namespaces) { const namespacePath = path.join(langPath, namespace); - const files = fs.readdirSync(namespacePath); + const files = fs.readdirSync(namespacePath).filter((f) => !this.ignoredFoldersAndFiles.includes(f)); const namespaceData = {}; - for (const file of files) { const filePath = path.join(namespacePath, file); + if (path.extname(file) !== ".json") continue; + const jsonContent = fs.readFileSync(filePath, "utf-8"); const jsonData = JSON.parse(jsonContent); namespaceData[file.replace(".json", "")] = jsonData;