summaryrefslogtreecommitdiff
path: root/src/components/SwitchLanguageLink.astro
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-14 21:12:55 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-14 21:14:19 +0100
commita9f63d838b37e5819e8b52cde5f8d0472aee63aa (patch)
treec189365fa6d980a4a1e9d9f1cd97723a203fc809 /src/components/SwitchLanguageLink.astro
parent442adaa1e8d778e367c83bcb335ff308cbcbfc72 (diff)
SwitchLanguageLink works for news items
Diffstat (limited to 'src/components/SwitchLanguageLink.astro')
-rw-r--r--src/components/SwitchLanguageLink.astro5
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);
---