diff --git a/scripts/i18n/scan-hardcoded.ts b/scripts/i18n/scan-hardcoded.ts index b4139935..6aec3f89 100755 --- a/scripts/i18n/scan-hardcoded.ts +++ b/scripts/i18n/scan-hardcoded.ts @@ -94,6 +94,16 @@ function isHuman(value: string | undefined): value is string { return true; } +/** + * Commented-out code is not user-facing text. `Header.tsx` carries a disabled dev-console button inside + * a `{/* … *\/}` block, and counting it means the area can never reach zero without editing a comment. + * + * Deliberately only two shapes, both unambiguous: a block comment, and a line whose first non-space + * characters are `//`. Stripping every `//` would eat the tail of any string holding a URL. + */ +const stripComments = (source: string): string => + source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^[ \t]*\/\/.*$/gm, ''); + function* walk(dir: string): Generator { let entries: string[]; try { @@ -125,7 +135,7 @@ function scan(root: string): { files: number; hits: Hit[] } { files++; let source: string; try { - source = readFileSync(file, 'utf8'); + source = stripComments(readFileSync(file, 'utf8')); } catch { continue; }