diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-14 21:12:55 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-14 21:14:19 +0100 |
| commit | a9f63d838b37e5819e8b52cde5f8d0472aee63aa (patch) | |
| tree | c189365fa6d980a4a1e9d9f1cd97723a203fc809 /src | |
| parent | 442adaa1e8d778e367c83bcb335ff308cbcbfc72 (diff) | |
SwitchLanguageLink works for news items
Diffstat (limited to 'src')
| -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); --- |
