summaryrefslogtreecommitdiff
path: root/src/components/SwitchLanguageLink.astro
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-13 20:41:29 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-13 20:41:29 +0100
commit7781c69153e3956ca14684fe9a287fbbb8a01082 (patch)
tree6bf18977ee93608aead54dc2322c0d42c2284f78 /src/components/SwitchLanguageLink.astro
parent71eac2d383c9918645e99b6b845fb8f4faecf346 (diff)
Determines current locale with lib function
Diffstat (limited to 'src/components/SwitchLanguageLink.astro')
-rw-r--r--src/components/SwitchLanguageLink.astro7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/components/SwitchLanguageLink.astro b/src/components/SwitchLanguageLink.astro
index 96dd538..62de1ba 100644
--- a/src/components/SwitchLanguageLink.astro
+++ b/src/components/SwitchLanguageLink.astro
@@ -3,13 +3,10 @@ import tPage from '$i18n/translations/components/languageLinks';
import tSite from '$i18n/translations/site';
import translate from '$i18n/translate';
import type Locale from '$types/Locale';
-
-interface Props {
- currentLocale: Locale;
-}
+import getLocaleFromPath from '$lib/getLocaleFromPath';
// This logic assumes that there are exactly two locales.
-const { currentLocale } = Astro.props;
+const currentLocale = getLocaleFromPath(Astro.url.pathname);
const otherLocale: Locale = currentLocale === 'sco' ? 'en-GB' : 'sco';
const currentPath = Astro.url.pathname;
const currentLocaleInPath = new RegExp(`(?<=^/)(${currentLocale}/)?`);