From c10dae3e6e047f5ca8f263cf88b2d55dff709e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sun, 23 Aug 2026 04:47:05 +0000 Subject: [PATCH] scanner: text inside code, kbd, pre and samp is code, not prose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ApiKeys.tsx documents the header to send as Authorization: Bearer …. That is an identifier crossing a boundary on the doc's never-translate list, and translating it would break the thing it documents. Those four elements exist to mark content as code, so the scanner now honours them. Verified the delta across both remaining areas is exactly that one string. --- scripts/i18n/scan-hardcoded.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/i18n/scan-hardcoded.ts b/scripts/i18n/scan-hardcoded.ts index 6aec3f89..1420f063 100755 --- a/scripts/i18n/scan-hardcoded.ts +++ b/scripts/i18n/scan-hardcoded.ts @@ -104,6 +104,15 @@ function isHuman(value: string | undefined): value is string { const stripComments = (source: string): string => source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^[ \t]*\/\/.*$/gm, ''); +/** + * ``, ``, `
` and `` mark content as code rather than prose — that is what the
+ * elements are for. `Authorization: Bearer …` is an HTTP header, which the doc's
+ * never-translate list covers as an identifier crossing a boundary, and translating it would break the
+ * thing it documents.
+ */
+const stripCodeElements = (source: string): string =>
+  source.replace(/<(code|kbd|pre|samp)\b[^>]*>[\s\S]*?<\/\1>/g, '<$1/>');
+
 function* walk(dir: string): Generator {
   let entries: string[];
   try {
@@ -135,7 +144,7 @@ function scan(root: string): { files: number; hits: Hit[] } {
     files++;
     let source: string;
     try {
-      source = stripComments(readFileSync(file, 'utf8'));
+      source = stripCodeElements(stripComments(readFileSync(file, 'utf8')));
     } catch {
       continue;
     }