From 57433becaa357ed08b66b3b35292d724bce9706d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 22 Mar 2026 20:00:48 +0100 Subject: [PATCH] Fix language selector regex to match zh-Hant, zh-Hans, nb-NO, etc. The URL matching regex only accepted two-letter codes or two-letter plus two uppercase (e.g., pt-BR), missing codes like zh-Hant with longer suffixes. Use [a-zA-Z]+ after the hyphen to match all codes. --- scripts/patch-mdbook-theme.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/patch-mdbook-theme.sh b/scripts/patch-mdbook-theme.sh index 75e76c1dd..609c6b9e4 100755 --- a/scripts/patch-mdbook-theme.sh +++ b/scripts/patch-mdbook-theme.sh @@ -89,8 +89,8 @@ cat >> "$HEAD_HBS" << 'ENDSCRIPT' document.addEventListener('DOMContentLoaded', function() { var path = window.location.pathname; // Match both deployed (/coreutils/docs[-lang]/utils/X.html) and local (book[-lang]/utils/X.html) - var match = path.match(/\/(?:coreutils\/)?docs(?:-([a-z]{2}(?:-[A-Z]{2})?))?\/utils\/(\w+)\.html/) - || path.match(/\/book(?:-([a-z]{2}(?:-[A-Z]{2})?))?\/utils\/(\w+)\.html/); + var match = path.match(/\/(?:coreutils\/)?docs(?:-([a-zA-Z]{2}(?:-[a-zA-Z]+)?))?\/utils\/(\w+)\.html/) + || path.match(/\/book(?:-([a-zA-Z]{2}(?:-[a-zA-Z]+)?))?\/utils\/(\w+)\.html/); if (!match) return; var currentLang = match[1] || 'en';