-
Notifications
You must be signed in to change notification settings - Fork 0
/
next-i18next.config.mjs
56 lines (49 loc) · 1.67 KB
/
next-i18next.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-check
/**
* @type {import('next-i18next').UserConfig}
*/
import path from 'path';
import fs from "node:fs/promises";
import { createRequire } from "node:module";
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename);
import HttpBackend from 'i18next-http-backend/cjs'
import ChainedBackend from 'i18next-chained-backend'
import LocalStorageBackend from 'i18next-localstorage-backend'
import { fileURLToPath } from 'url';
const isBrowser = typeof window !== 'undefined'
const isDev = process.env.NODE_ENV === 'development'
const options = {
// https://www.i18next.com/overview/configuration-options#logging
backend: {
backendOptions: [
{ expirationTime: isDev ? 60 * 1000 : 60 * 60 * 1000 },
{},
], // 1 hour
backends: isBrowser ? [LocalStorageBackend, HttpBackend] : [],
},
// https://www.i18next.com/overview/configuration-options#logging
debug: isDev,
i18n: {
defaultLocale: 'en',
locales: ['en', 'tr'],
},
/** To avoid issues when deploying to some paas (vercel...) */
localePath:
typeof window === 'undefined'
? path.resolve(__dirname, 'public', 'locales')
: '/public/locales',
reloadOnPrerender: process.env.NODE_ENV === 'development',
ns: ['common'],
partialBundledLanguages: isBrowser,
use: isBrowser ? [ChainedBackend] : [],
/**
* @link https://github.com/i18next/next-i18next#6-advanced-configuration
*/
// saveMissing: false,
// strictMode: true,
// serializeConfig: false,
// react: { useSuspense: false }
}
export default options;
export { options }