Removed shamefully-hoist and updated all packages to respect that
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
"@kit/shared": "workspace:^",
|
||||
"@kit/tailwind-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"i18next": "^23.10.1",
|
||||
"i18next": "^23.11.0",
|
||||
"i18next-browser-languagedetector": "7.2.0",
|
||||
"i18next-resources-to-backend": "^1.2.0",
|
||||
"react-i18next": "^14.1.0"
|
||||
|
||||
@@ -26,16 +26,12 @@ export function I18nProvider({
|
||||
|
||||
async function withI18nClient(lang: string, resolver: Resolver) {
|
||||
if (typeof window !== 'undefined') {
|
||||
client = await loadClientI18n(lang, resolver);
|
||||
const { initializeI18nClient } = await import('./i18n.client');
|
||||
|
||||
client = await initializeI18nClient(lang, resolver);
|
||||
} else {
|
||||
const { initializeServerI18n } = await import('./i18n.server');
|
||||
|
||||
client = await initializeServerI18n(lang, resolver);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadClientI18n(lang: string | undefined, resolver: Resolver) {
|
||||
const { initializeI18nClient } = await import('./i18n.client');
|
||||
|
||||
return initializeI18nClient(lang, resolver);
|
||||
}
|
||||
|
||||
@@ -5,19 +5,17 @@ import { initReactI18next } from 'react-i18next';
|
||||
|
||||
import { I18N_COOKIE_NAME, getI18nSettings } from './i18n.settings';
|
||||
|
||||
let promise: Promise<i18n>;
|
||||
|
||||
export function initializeI18nClient(
|
||||
lng: string | undefined,
|
||||
i18nResolver: (lang: string, namespace: string) => Promise<object>,
|
||||
): Promise<i18n> {
|
||||
const settings = getI18nSettings(lng);
|
||||
|
||||
if (promise !== undefined) {
|
||||
return promise;
|
||||
if (i18next.isInitialized) {
|
||||
return Promise.resolve(i18next);
|
||||
}
|
||||
|
||||
promise = new Promise<i18n>((resolve, reject) => {
|
||||
return new Promise<i18n>((resolve, reject) => {
|
||||
void i18next
|
||||
.use(initReactI18next)
|
||||
.use(
|
||||
@@ -49,6 +47,4 @@ export function initializeI18nClient(
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ export async function initializeServerI18n(
|
||||
i18nResolver: (language: string, namespace: string) => Promise<object>,
|
||||
) {
|
||||
const i18nInstance = createInstance();
|
||||
|
||||
if (i18nInstance.isInitialized) {
|
||||
return i18nInstance;
|
||||
}
|
||||
|
||||
const settings = getI18nSettings(lang);
|
||||
|
||||
await i18nInstance
|
||||
|
||||
@@ -19,7 +19,6 @@ export const defaultI18nNamespaces = [
|
||||
'teams',
|
||||
'billing',
|
||||
'marketing',
|
||||
'admin',
|
||||
];
|
||||
|
||||
export function getI18nSettings(
|
||||
|
||||
Reference in New Issue
Block a user