mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 10:04:25 +00:00
i18n setup
This commit is contained in:
@@ -18,7 +18,7 @@ const lato = Lato({
|
|||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
});
|
});
|
||||||
|
|
||||||
// export const revalidate = 60; // revalidate every minute
|
export const revalidate = 60; // revalidate every minute
|
||||||
|
|
||||||
export function generateStaticParams() {
|
export function generateStaticParams() {
|
||||||
return i18nConfig.locales.map((locale) => ({ locale }));
|
return i18nConfig.locales.map((locale) => ({ locale }));
|
||||||
@@ -26,13 +26,12 @@ export function generateStaticParams() {
|
|||||||
|
|
||||||
export default async function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
params: { locale },
|
params: { locale, hl },
|
||||||
}: {
|
}: {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
params: { locale: string };
|
params: { locale: string; hl: string };
|
||||||
}) {
|
}) {
|
||||||
const i18nNamespaces = ["loginname"];
|
const i18nNamespaces = ["loginname"];
|
||||||
console.log("layout:", locale);
|
|
||||||
const { t, resources } = await initTranslations(locale, i18nNamespaces);
|
const { t, resources } = await initTranslations(locale, i18nNamespaces);
|
||||||
|
|
||||||
// later only shown with dev mode enabled
|
// later only shown with dev mode enabled
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { createInstance } from "i18next";
|
|
||||||
import { initReactI18next } from "react-i18next/initReactI18next";
|
|
||||||
import resourcesToBackend from "i18next-resources-to-backend";
|
|
||||||
import i18nConfig from "i18nConfig";
|
import i18nConfig from "i18nConfig";
|
||||||
|
import { createInstance } from "i18next";
|
||||||
|
import resourcesToBackend from "i18next-resources-to-backend";
|
||||||
|
import { initReactI18next } from "react-i18next/initReactI18next";
|
||||||
|
|
||||||
export default async function initTranslations(
|
export default async function initTranslations(
|
||||||
locale,
|
locale,
|
||||||
namespaces,
|
namespaces,
|
||||||
i18nInstance,
|
i18nInstance,
|
||||||
resources
|
resources,
|
||||||
) {
|
) {
|
||||||
i18nInstance = i18nInstance || createInstance();
|
i18nInstance = i18nInstance || createInstance();
|
||||||
|
|
||||||
@@ -15,9 +15,10 @@ export default async function initTranslations(
|
|||||||
|
|
||||||
if (!resources) {
|
if (!resources) {
|
||||||
i18nInstance.use(
|
i18nInstance.use(
|
||||||
resourcesToBackend((language, namespace) =>
|
resourcesToBackend(
|
||||||
import(`/locales/${language}/${namespace}.json`)
|
(language, namespace) =>
|
||||||
)
|
import(`/locales/${language}/${namespace}.json`),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user