next-i18next.config.ts 964 B

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