Yuki Takei 3 лет назад
Родитель
Сommit
abec92cd98
2 измененных файлов с 5 добавлено и 6 удалено
  1. 3 3
      packages/app/src/next-i18next.config.ts
  2. 2 3
      packages/app/src/services/i18next-hmr.ts

+ 3 - 3
packages/app/src/next-i18next.config.ts

@@ -1,10 +1,10 @@
 import path from 'path';
 import path from 'path';
 
 
+import { isServer } from '@growi/core';
 import I18nextChainedBackend from 'i18next-chained-backend';
 import I18nextChainedBackend from 'i18next-chained-backend';
 import I18NextHttpBackend from 'i18next-http-backend';
 import I18NextHttpBackend from 'i18next-http-backend';
 import I18NextLocalStorageBackend from 'i18next-localstorage-backend';
 import I18NextLocalStorageBackend from 'i18next-localstorage-backend';
 
 
-const isServer = typeof window === 'undefined';
 const isDev = process.env.NODE_ENV === 'development';
 const isDev = process.env.NODE_ENV === 'development';
 
 
 export const i18n = {
 export const i18n = {
@@ -15,9 +15,9 @@ export const defaultNS = 'translation';
 export const localePath = path.resolve('./public/static/locales');
 export const localePath = path.resolve('./public/static/locales');
 
 
 export const serializeConfig = false;
 export const serializeConfig = false;
-export const use = isServer ? [] : [I18nextChainedBackend];
+export const use = isServer() ? [] : [I18nextChainedBackend];
 export const backend = {
 export const backend = {
-  backends: isServer ? [] : [I18NextLocalStorageBackend, I18NextHttpBackend],
+  backends: isServer() ? [] : [I18NextLocalStorageBackend, I18NextHttpBackend],
   backendOptions: [
   backendOptions: [
     // options for i18next-localstorage-backend
     // options for i18next-localstorage-backend
     { expirationTime: isDev ? 0 : 24 * 60 * 60 * 1000 }, // 1 day in production
     { expirationTime: isDev ? 0 : 24 * 60 * 60 * 1000 }, // 1 day in production

+ 2 - 3
packages/app/src/services/i18next-hmr.ts

@@ -1,9 +1,8 @@
 import { useEffect } from 'react';
 import { useEffect } from 'react';
 
 
+import { isServer } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
 
 
-const isServer = typeof window === 'undefined';
-
 export const useI18nextHMR = (isDev: boolean): void => {
 export const useI18nextHMR = (isDev: boolean): void => {
   const { i18n } = useTranslation();
   const { i18n } = useTranslation();
 
 
@@ -19,7 +18,7 @@ export const useI18nextHMR = (isDev: boolean): void => {
     return;
     return;
   }
   }
 
 
-  if (isServer) {
+  if ((isServer())) {
     import('i18next-hmr/server').then(({ applyServerHMR }) => {
     import('i18next-hmr/server').then(({ applyServerHMR }) => {
       applyServerHMR(i18n);
       applyServerHMR(i18n);
     });
     });