diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index d31a1f1..b94e5d6 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -1,16 +1,19 @@ import { writable, derived } from 'svelte/store'; import { langs } from './lang'; +const defaultLocale = 'en'; + function determineLocale(locale: string): string { if (langs[locale.toLowerCase()] != undefined) { return locale.toLowerCase(); - } else { + } else if (langs[locale.toLowerCase().split('-')[0]] != undefined) { return locale.toLowerCase().split('-')[0]; + } else { + return defaultLocale; } } export const locale = writable(determineLocale(navigator.language)); -const defaultLocale = 'en'; export const trans = derived( locale,