MCPcopy Create free account
hub / github.com/5e-bits/5e-database / getEnglishSourcePath

Function getEnglishSourcePath

scripts/translationUtils.ts:36–45  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

34 * e.g., 'src/2014/de/5e-SRD-Spells.json' -> 'src/2014/en/5e-SRD-Spells.json'
35 */
36export function getEnglishSourcePath(filepath: string): string | null {
37 const parts = filepath.split('/');
38 const yearIdx = parts.findIndex((p) => YEAR_DIR_PATTERN.test(p));
39 if (yearIdx < 0) return null;
40 const localeSegment = parts[yearIdx + 1];
41 if (!localeSegment || !LOCALE_PATTERN.test(localeSegment)) return null;
42 const result = [...parts];
43 result[yearIdx + 1] = 'en';
44 return result.join('/');
45}
46
47/**
48 * Validates a single translation entry against the English source map and

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected