Skip to content

Commit

Permalink
fix(i18n): ignore .git folder and crowdin.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
NedcloarBR committed May 28, 2024
1 parent 1ea5326 commit e30a8ab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/modules/config/JSONLocale.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Record<string, string>> = {};
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;
Expand Down

0 comments on commit e30a8ab

Please sign in to comment.