Skip to content

Commit 94e337f

Browse files
committed
sidetrack custom i18n strategy attempt
1 parent ce1c9e0 commit 94e337f

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/hooks.client.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// import {
2+
// defineCustomClientStrategy,
3+
// isLocale,
4+
// } from '$lib/i18n/generated/runtime';
5+
// import type { ServerInit } from '@sveltejs/kit';
6+
7+
// export const init: ServerInit = () => {
8+
// defineCustomClientStrategy('custom-localStorage', {
9+
// getLocale() {
10+
// const [param] = window.location.pathname.split('/').filter(Boolean);
11+
// console.log(param);
12+
// if (param && isLocale(param)) {
13+
// return param;
14+
// }
15+
// const stored = localStorage.getItem('locale');
16+
// if (isLocale(stored)) {
17+
// return stored;
18+
// }
19+
// return undefined;
20+
// },
21+
// setLocale(locale) {
22+
// localStorage.setItem('locale', locale);
23+
// },
24+
// });
25+
// };

src/hooks.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@ import { deLocalizeUrl } from '$lib/i18n/generated/runtime';
22
import type { Reroute } from '@sveltejs/kit';
33

44
export const reroute: Reroute = (request) => {
5-
// const change = request.url.searchParams.get('locale');
6-
// if (change && isLocale(change) && change !== getLocale()) {
7-
// cookie.set('locale', change);
8-
// }
95
return deLocalizeUrl(request.url).pathname;
106
};

vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export default defineConfig({
1111
paraglide({
1212
project: './project.inlang',
1313
outdir: './src/lib/i18n/generated',
14-
strategy: ['url', 'cookie', 'preferredLanguage', 'baseLocale'],
15-
cookieName: 'locale',
14+
strategy: ['url'],
1615
}),
1716
markdown(),
1817
tailwindcss(),

0 commit comments

Comments
 (0)