next-i18next.config.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. const path = require('path');
  2. const { AllLang, Lang } = require('@growi/core');
  3. const { isServer } = require('@growi/core/dist/utils');
  4. const I18nextChainedBackend = require('i18next-chained-backend').default;
  5. const I18NextHttpBackend = require('i18next-http-backend');
  6. const I18NextLocalStorageBackend = require('i18next-localstorage-backend').default;
  7. const isDev = process.env.NODE_ENV === 'development';
  8. module.exports = {
  9. defaultLang: Lang.en_US,
  10. i18n: {
  11. defaultLocale: Lang.en_US,
  12. locales: AllLang,
  13. },
  14. defaultNS: 'translation',
  15. localePath: path.resolve('./public/static/locales'),
  16. serializeConfig: false,
  17. use: isServer() ? [] : [I18nextChainedBackend],
  18. backend: {
  19. backends: isServer() ? [] : [I18NextLocalStorageBackend, I18NextHttpBackend],
  20. backendOptions: [
  21. // options for i18next-localstorage-backend
  22. { expirationTime: isDev ? 0 : 24 * 60 * 60 * 1000 }, // 1 day in production
  23. // options for i18next-http-backend
  24. { loadPath: '/static/locales/{{lng}}/{{ns}}.json' },
  25. ],
  26. },
  27. };