next-i18next.config.ts 1001 B

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