-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathnext-i18next.config.js
74 lines (68 loc) · 2.95 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
65
66
67
68
69
70
71
72
73
74
// POSSIBILITY 1: locize live download usage on client side only
const LocizeBackend = require('i18next-locize-backend/cjs')
const ChainedBackend= require('i18next-chained-backend').default
const LocalStorageBackend = require('i18next-localstorage-backend').default
// If you've configured caching for your locize version, you may not need the i18next-localstorage-backend and i18next-chained-backend plugin.
// https://docs.locize.com/more/caching
const isBrowser = typeof window !== 'undefined'
const isDev = process.env.NODE_ENV === 'development'
module.exports = {
debug: isDev,
i18n: {
defaultLocale: 'en',
locales: ['en', 'de'],
},
backend: {
backendOptions: [{
expirationTime: 60 * 60 * 1000 // 1 hour
}, {
projectId: 'd3b405cf-2532-46ae-adb8-99e88d876733',
// apiKey: 'myApiKey', // to not add the api-key in production
version: 'latest'
}],
backends: isBrowser ? [LocalStorageBackend, LocizeBackend] : [],
},
partialBundledLanguages: isBrowser && true,
serializeConfig: false,
use: isBrowser ?
(isDev ? [ChainedBackend, /*require('locize').locizeEditorPlugin({ show: true }), require('locize-lastused')*/] : [ChainedBackend]) :
(isDev ? [/*require('locize').locizeEditorPlugin({ show: true })*/] : []),
// locizeLastUsed: {
// projectId: 'd3b405cf-2532-46ae-adb8-99e88d876733',
// apiKey: 'myApiKey', // to not add the api-key in production
// version: 'latest',
// debounceSubmit: 10000
// },
saveMissing: isDev && isBrowser // do not set saveMissing to true for production and also not when using the chained backend
}
// POSSIBILITY 2: config for locize live download usage
// module.exports = {
// i18n: {
// defaultLocale: 'en',
// locales: ['en', 'de'],
// },
// // this will download the translations from locize directly, in client (browser) and server (node.js)
// // DO NOT USE THIS if having a serverless environment => this will generate too much download requests
// // => https://github.com/locize/i18next-locize-backend#important-advice-for-serverless-environments---aws-lambda-google-cloud-functions-azure-functions-etc
// backend: {
// projectId: 'd3b405cf-2532-46ae-adb8-99e88d876733',
// // apiKey: 'myApiKey', // to not add the api-key in production, used for saveMissing feature
// referenceLng: 'en'
// },
// use: [
// require('i18next-locize-backend/cjs')
// ],
// ns: ['common', 'footer', 'second-page'], // the namespaces needs to be listed here, to make sure they got preloaded
// serializeConfig: false, // because of the custom use i18next plugin
// // debug: true,
// // saveMissing: true, // do not saveMissing to true for production
// }
// POSSIBILITY 3: bundle translations with app
// for a serverless environment bundle the translations first. See downloadLocales script in package.json
// and configre this file like this:
// module.exports = {
// i18n: {
// defaultLocale: 'en',
// locales: ['en', 'de'],
// }
// }