MCPcopy
hub / github.com/obsidianmd/obsidian-help / collectLocaleFiles

Function collectLocaleFiles

scripts/translate-locale.ts:470–496  ·  view source on GitHub ↗
(enFiles: Map<string, { relPath: string; content: string }>)

Source from the content-addressed store, hash-verified

468}
469
470function collectLocaleFiles(enFiles: Map<string, { relPath: string; content: string }>): FileInfo[] {
471 const results: FileInfo[] = [];
472 function walk(dir: string) {
473 for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
474 const full = path.join(dir, entry.name);
475 if (entry.isDirectory()) walk(full);
476 else if (entry.isFile() && entry.name.endsWith(".md")) {
477 const raw = fs.readFileSync(full, "utf8");
478 const parsed = matter(raw);
479 const permalink = parsed.data?.permalink as string | undefined;
480 if (!permalink) continue;
481 const enInfo = enFiles.get(permalink);
482 if (!enInfo) continue;
483 results.push({
484 absPath: full,
485 relPath: path.relative(localeDir, full),
486 enRelPath: enInfo.relPath,
487 permalink,
488 frontmatter: parsed.data as Record<string, unknown>,
489 content: parsed.content,
490 });
491 }
492 }
493 }
494 walk(localeDir);
495 return results;
496}
497
498function collectEnFiles(): Map<string, { relPath: string; content: string }> {
499 const map = new Map<string, { relPath: string; content: string }>();

Callers 1

mainFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected