next-i18next.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const isDev = process.env.NODE_ENV === 'development';
  2. // biome-ignore lint/style/useNodejsImportProtocol: ignore
  3. const path = require('path');
  4. const { AllLang } = require('@growi/core');
  5. const { isServer } = require('@growi/core/dist/utils');
  6. const { defaultLang } = require('./i18next.config');
  7. /** @type {import('next-i18next').UserConfig} */
  8. module.exports = {
  9. ...require('./i18next.config').initOptions,
  10. i18n: {
  11. defaultLocale: defaultLang.toString(),
  12. locales: AllLang,
  13. },
  14. localePath: path.resolve('./public/static/locales'),
  15. serializeConfig: false,
  16. use: isDev
  17. ? isServer()
  18. ? []
  19. : [require('i18next-chained-backend').default]
  20. : [],
  21. backend: {
  22. backends: isServer()
  23. ? []
  24. : [
  25. require('i18next-localstorage-backend').default,
  26. require('i18next-http-backend').default,
  27. ],
  28. backendOptions: [
  29. // options for i18next-localstorage-backend
  30. { expirationTime: isDev ? 0 : 24 * 60 * 60 * 1000 }, // 1 day in production
  31. // options for i18next-http-backend
  32. { loadPath: '/static/locales/{{lng}}/{{ns}}.json' },
  33. ],
  34. },
  35. };