diff --git a/src/components/common/FollowAllButton.tsx b/src/components/common/FollowAllButton.tsx index 1eac7ea2..1eee793d 100644 --- a/src/components/common/FollowAllButton.tsx +++ b/src/components/common/FollowAllButton.tsx @@ -1,12 +1,12 @@ "use client" -import { useTranslation } from "next-i18next" import { useState } from "react" import { useAccountState } from "@crossbell/connect-kit" import { useRefCallback } from "@crossbell/util-hooks" import { Button } from "~/components/ui/Button" +import { useTranslation } from "~/lib/i18n/client" import { getSubscriptionsFromList } from "~/models/site.model" import { useSubscribeToSites } from "~/queries/site" diff --git a/src/components/home/Showcase.tsx b/src/components/home/Showcase.tsx index ec51763c..4d96ddcf 100644 --- a/src/components/home/Showcase.tsx +++ b/src/components/home/Showcase.tsx @@ -7,11 +7,13 @@ import { FollowAllButton } from "~/components/common/FollowAllButton" import { Image } from "~/components/ui/Image" import { UniLink } from "~/components/ui/UniLink" import { getSiteLink } from "~/lib/helpers" +import { useTranslation } from "~/lib/i18n/client" import { useGetShowcase } from "~/queries/home" export function ShowCase() { const showcaseSites = useGetShowcase() const [showcaseMore, setShowcaseMore] = useState(false) + const { t } = useTranslation("index") return ( <> @@ -35,8 +37,7 @@ export function ShowCase() { }`} onClick={() => setShowcaseMore(true)} > - {/* {t("Show more")} */} - Show more + {t("Show more")} {showcaseSites.data?.map((site) => (
  • diff --git a/src/lib/i18n/client.ts b/src/lib/i18n/client.ts index 46ff0779..1cf919b9 100644 --- a/src/lib/i18n/client.ts +++ b/src/lib/i18n/client.ts @@ -3,12 +3,13 @@ import i18next from "i18next" import LanguageDetector from "i18next-browser-languagedetector" import resourcesToBackend from "i18next-resources-to-backend" +import { useEffect, useState } from "react" import { initReactI18next, useTranslation as useTranslationOrg, } from "react-i18next" -import { getOptions } from "./settings" +import { fallbackLng, getOptions } from "./settings" i18next .use(initReactI18next) @@ -28,5 +29,16 @@ i18next }) export function useTranslation(ns: string) { - return useTranslationOrg(ns) + const [value, setValue] = useState({ + t: i18next.getFixedT(fallbackLng, ns), + }) + + const { t } = useTranslationOrg(ns) + useEffect(() => { + setValue({ + t, + }) + }, [t]) + + return value }