diff options
Diffstat (limited to 'src/components/SwitchLanguageLink.astro')
| -rw-r--r-- | src/components/SwitchLanguageLink.astro | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/components/SwitchLanguageLink.astro b/src/components/SwitchLanguageLink.astro index 62de1ba..c8733bc 100644 --- a/src/components/SwitchLanguageLink.astro +++ b/src/components/SwitchLanguageLink.astro @@ -10,7 +10,10 @@ const currentLocale = getLocaleFromPath(Astro.url.pathname); const otherLocale: Locale = currentLocale === 'sco' ? 'en-GB' : 'sco'; const currentPath = Astro.url.pathname; const currentLocaleInPath = new RegExp(`(?<=^/)(${currentLocale}/)?`); -const otherLocalePath = currentPath.replace(currentLocaleInPath, `${otherLocale}/`); +const newsCurrentLocaleInPath = new RegExp(`(?<=/news/)(${currentLocale.toLocaleLowerCase()})`); +const otherLocalePath = currentPath + .replace(currentLocaleInPath, `${otherLocale}/`) + .replace(newsCurrentLocaleInPath, `${otherLocale.toLocaleLowerCase()}`); const t = translate(currentLocale); --- |
