This update separates the creation of i18n settings into its own function (@kit/i18n) and enhances the handling of language and namespace loading in i18n.client. It tracks loaded languages and namespaces, and prevents rendering if none are loaded or after a maximum number of iterations. The usage of Suspense has also been modified in root-providers to employ a null fallback.
34 lines
572 B
TypeScript
34 lines
572 B
TypeScript
/**
|
|
* Get i18n settings for i18next.
|
|
* @param languages
|
|
* @param language
|
|
* @param namespaces
|
|
*/
|
|
export function createI18nSettings({
|
|
languages,
|
|
language,
|
|
namespaces,
|
|
}: {
|
|
languages: string[];
|
|
language: string;
|
|
namespaces?: string | string[];
|
|
}) {
|
|
const lng = language;
|
|
const ns = namespaces;
|
|
|
|
return {
|
|
supportedLngs: languages,
|
|
fallbackLng: languages[0],
|
|
detection: undefined,
|
|
lng,
|
|
load: 'languageOnly',
|
|
preload: false,
|
|
lowerCaseLng: true,
|
|
fallbackNS: ns,
|
|
ns,
|
|
react: {
|
|
useSuspense: true,
|
|
},
|
|
};
|
|
}
|