next-i18next.config.ts 1004 B

12345678910111213141516171819202122232425262728
  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 defaultLang = Lang.en_US;
  8. export const i18n = {
  9. defaultLocale: defaultLang,
  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. };