From de90e4de54c37120c6278bcab8b65a8e656b1472 Mon Sep 17 00:00:00 2001 From: Athou Date: Mon, 28 Apr 2025 22:59:41 +0200 Subject: [PATCH] try to find a suitable language for the user before defaulting to english (#1767) --- commafeed-client/src/i18n.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commafeed-client/src/i18n.ts b/commafeed-client/src/i18n.ts index ff4d8e03..0e963fb3 100644 --- a/commafeed-client/src/i18n.ts +++ b/commafeed-client/src/i18n.ts @@ -57,8 +57,12 @@ function activateLocale(locale: string) { } export const useI18n = () => { - const locale = useAppSelector(state => state.user.settings?.language) + const locale = + useAppSelector(state => state.user.settings?.language) ?? + navigator.languages.map(l => l.split("-")[0]).find(l => locales.some(locale => locale.key === l)) ?? + "en" + useEffect(() => { - activateLocale(locale ?? "en") + activateLocale(locale) }, [locale]) }