next-i18next.config.js 1003 B

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