This commit is contained in:
Finley Ge
2025-03-18 12:53:42 +08:00
committed by GitHub
parent 5563c3a0e7
commit 37f4dd3f27
29 changed files with 29 additions and 35 deletions

View File

@@ -1,15 +0,0 @@
import { I18nNsType } from '../../types/i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
export const serviceSideProps = async (content: any, ns: I18nNsType = []) => {
const lang = content.req?.cookies?.NEXT_LOCALE || content.locale;
const extraLng = content.req?.cookies?.NEXT_LOCALE ? undefined : content.locales;
// Device size
const deviceSize = content.req?.cookies?.NEXT_DEVICE_SIZE || null;
return {
...(await serverSideTranslations(lang, ['common', ...ns], null, extraLng)),
deviceSize
};
};

View File

@@ -44,7 +44,7 @@ export const useI18nLng = () => {
await i18n?.changeLanguage?.(lang);
if (!i18n.hasResourceBundle(lang, 'common') && prevLang !== lang) {
if (!i18n?.hasResourceBundle?.(lang, 'common') && prevLang !== lang) {
window?.location?.reload?.();
}
};