-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
next-i18next.config.js
64 lines (62 loc) · 1.63 KB
/
next-i18next.config.js
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
57
58
59
60
61
62
63
64
/* eslint-disable turbo/no-undeclared-env-vars */
/* eslint-disable @typescript-eslint/no-var-requires */
// @ts-check
/* eslint-disable import/no-unused-modules */
const path = require('path')
const isBrowser = typeof window !== 'undefined'
const plugins = () => {
/** @type {any[]} */
const pluginsToUse = []
if (process.env.NODE_ENV === 'development') {
if (isBrowser) {
import('i18next-hmr/plugin').then(({ HMRPlugin }) =>
pluginsToUse.push(new HMRPlugin({ webpack: { client: true } }))
)
} else {
import('i18next-hmr/plugin').then(({ HMRPlugin }) =>
pluginsToUse.push(new HMRPlugin({ webpack: { server: true } }))
)
}
}
return pluginsToUse
}
/**
* @template {import('next-i18next').UserConfig} T
* @type {import('next-i18next').UserConfig}
* @param {T} config
* @constraint {{import('next-i18next').UserConfig}}
*/
const config = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
defaultNS: 'common',
localePath: path.resolve('./public/locales'),
reloadOnPrerender: process.env.NODE_ENV !== 'production',
debug: false, //process.env.NODE_ENV !== 'production',
nonExplicitSupportedLngs: true,
cleanCode: true,
react: { useSuspense: false },
joinArrays: '',
serializeConfig: false,
use: plugins(),
interpolation: {
skipOnVariables: false,
alwaysFormat: true,
format: (value, format, lng, edit) => {
switch (format) {
case 'lowercase': {
if (typeof value === 'string') return value.toLocaleLowerCase()
break
}
case 'uppercase': {
if (typeof value === 'string') return value.toLocaleUpperCase()
break
}
}
return value
},
},
}
module.exports = config