diff --git a/src/components/GlobalSidebar.tsx b/src/components/GlobalSidebar.tsx index 00c9e58..aac680a 100644 --- a/src/components/GlobalSidebar.tsx +++ b/src/components/GlobalSidebar.tsx @@ -101,18 +101,7 @@ export const GlobalSidebar: FC = ({ ), content: ( - -
- -
- - } - > + }> ), diff --git a/src/components/SettingsControls.tsx b/src/components/SettingsControls.tsx index a2a590f..69840f9 100644 --- a/src/components/SettingsControls.tsx +++ b/src/components/SettingsControls.tsx @@ -12,6 +12,7 @@ import { } from "@/components/ui/select"; import { useTheme } from "@/hooks/useTheme"; import { projectDetailQuery, projectListQuery } from "../lib/api/queries"; +import type { SupportedLocale } from "../lib/i18n/schema"; interface SettingsControlsProps { openingProjectId: string; @@ -87,16 +88,12 @@ export const SettingsControls: FC = ({ updateConfig(newConfig); }; - const handleLocaleChange = async (value: string) => { + const handleLocaleChange = async (value: SupportedLocale) => { const newConfig = { ...config, - locale: value as "ja" | "en", + locale: value, }; - updateConfig(newConfig, { - onSuccess: async () => { - window.location.reload(); - }, - }); + updateConfig(newConfig); }; const handleThemeChange = async (value: "light" | "dark" | "system") => { diff --git a/src/lib/i18n/LinguiProvider.tsx b/src/lib/i18n/LinguiProvider.tsx index 8455f42..6e669de 100644 --- a/src/lib/i18n/LinguiProvider.tsx +++ b/src/lib/i18n/LinguiProvider.tsx @@ -1,14 +1,19 @@ import { i18n } from "@lingui/core"; import { I18nProvider } from "@lingui/react"; -import type { FC, PropsWithChildren } from "react"; +import { type FC, type PropsWithChildren, useEffect } from "react"; +import { useConfig } from "../../app/hooks/useConfig"; import { i18nMessages } from "."; for (const { locale, messages } of i18nMessages) { i18n.load(locale, messages); } -i18n.activate("en"); - export const LinguiClientProvider: FC = ({ children }) => { + const { config } = useConfig(); + + useEffect(() => { + i18n.activate(config.locale); + }, [config.locale]); + return {children}; };