forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi18n.ts
More file actions
34 lines (31 loc) · 1.27 KB
/
i18n.ts
File metadata and controls
34 lines (31 loc) · 1.27 KB
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
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import I18NextHttpBackend, { BackendOptions } from 'i18next-http-backend';
import I18NextMultiloadBackendAdapter from 'i18next-multiload-backend-adapter';
// If we're using HMR use a unique hash per page reload so that we're always
// doing cache busting. Otherwise just use the builder provided hash value in
// the URL to allow cache busting to occur whenever the front-end is rebuilt.
const hash = module.hot ? Date.now().toString(16) : process.env.WEBPACK_BUILD_HASH;
i18n
.use(I18NextMultiloadBackendAdapter)
.use(initReactI18next)
.init({
debug: process.env.DEBUG === 'true',
lng: 'en',
fallbackLng: 'en',
keySeparator: '.',
backend: {
backend: I18NextHttpBackend,
backendOption: {
loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}',
queryStringParams: { hash },
allowMultiLoading: true,
} as BackendOptions,
} as Record<string, any>,
interpolation: {
// Per i18n-react documentation: this is not needed since React is already
// handling escapes for us.
escapeValue: false,
},
});
export default i18n;