File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,16 @@ import { de, enUS } from "date-fns/locale";
2
2
import { ui , defaultLang } from "./ui" ;
3
3
4
4
export function getLangFromUrl ( url : URL ) {
5
- const [ , lang ] = url . pathname . split ( "/" ) ;
6
- if ( lang in ui ) return lang as keyof typeof ui ;
5
+ const candidates = url . pathname . split ( "/" ) . filter ( ( a ) => a . length === 2 ) ;
6
+
7
+ if ( candidates . includes ( "de" ) ) {
8
+ return "de" ;
9
+ }
10
+
11
+ if ( candidates . includes ( "en" ) ) {
12
+ return "en" ;
13
+ }
14
+
7
15
return defaultLang ;
8
16
}
9
17
Original file line number Diff line number Diff line change 1
1
---
2
- import { getLangFromUrl , useTranslations } from " ../i18n/utils" ;
2
+ import { getLangFromUrl } from " ../i18n/utils" ;
3
3
import Head from " ../components/Head.astro" ;
4
4
import " @/styles/globals.css" ;
5
5
import Footer from " ../components/Footer.astro" ;
@@ -8,7 +8,6 @@ import Navigation from "../components/Navigation.astro";
8
8
const { title } = Astro .props ;
9
9
10
10
const lang = getLangFromUrl (Astro .url );
11
- const t = useTranslations (lang );
12
11
---
13
12
14
13
<script is:inline >
You can’t perform that action at this time.
0 commit comments