-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathnext-i18next.config.js
43 lines (38 loc) · 1.03 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
const path = require('path');
/**
* Intl takes the BCP 47 language code as
* constructor argument, so you (might)
* need to convert the locale to BCP 47
*/
const localeToBCP47 = {
en: 'en-US',
no: 'nb-NO'
};
// For more information on internationalized routing,
// check out the Next.js docs:
// https://nextjs.org/docs/advanced-features/i18n-routing
module.exports = {
i18n: {
// Match these locales with app.config.json
defaultLocale: 'en',
locales: ['en'],
localePath: path.resolve('./public/static/locales')
},
serializeConfig: false,
interpolation: {
escapeValue: false, // react already safe from xss
format(value, format, locale, { currency }) {
const localeBCP47 = localeToBCP47[locale];
if (format === 'currency') {
if (typeof value === 'undefined' || !currency) {
return 'N/A';
}
return new Intl.NumberFormat(localeBCP47 || locale, {
style: 'currency',
currency
}).format(value);
}
return value;
}
}
};