We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 046976a commit e7ee282Copy full SHA for e7ee282
src/lib/i18n.ts
@@ -1,16 +1,19 @@
1
import { writable, derived } from 'svelte/store';
2
import { langs } from './lang';
3
4
+const defaultLocale = 'en';
5
+
6
function determineLocale(locale: string): string {
7
if (langs[locale.toLowerCase()] != undefined) {
8
return locale.toLowerCase();
- } else {
9
+ } else if (langs[locale.toLowerCase().split('-')[0]] != undefined) {
10
return locale.toLowerCase().split('-')[0];
11
+ } else {
12
+ return defaultLocale;
13
}
14
15
16
export const locale = writable(determineLocale(navigator.language));
-const defaultLocale = 'en';
17
18
export const trans = derived(
19
locale,
0 commit comments