allow changing language from settings.yaml

pull/163/head^2
Ben Phelps 2 years ago
parent 15a8c4f0d7
commit db18519c16

@ -2,6 +2,8 @@
import useSWR from "swr"; import useSWR from "swr";
import Head from "next/head"; import Head from "next/head";
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import { useTranslation } from "react-i18next";
import { useEffect } from "react";
import ServicesGroup from "components/services/group"; import ServicesGroup from "components/services/group";
import BookmarksGroup from "components/bookmarks/group"; import BookmarksGroup from "components/bookmarks/group";
@ -30,7 +32,10 @@ export async function getStaticProps() {
}, },
}; };
} }
export default function Home({ settings }) { export default function Home({ settings }) {
const { i18n } = useTranslation();
const { data: services } = useSWR("/api/services"); const { data: services } = useSWR("/api/services");
const { data: bookmarks } = useSWR("/api/bookmarks"); const { data: bookmarks } = useSWR("/api/bookmarks");
const { data: widgets } = useSWR("/api/widgets"); const { data: widgets } = useSWR("/api/widgets");
@ -41,6 +46,12 @@ export default function Home({ settings }) {
wrappedStyle.backgroundSize = "cover"; wrappedStyle.backgroundSize = "cover";
} }
useEffect(() => {
if (settings.language) {
i18n.changeLanguage(settings.language);
}
}, [i18n, settings.language]);
return ( return (
<ColorProvider> <ColorProvider>
<ThemeProvider> <ThemeProvider>

Loading…
Cancel
Save