Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/i18n.ts
7458 views
1
import i18n from 'i18next';
2
import { initReactI18next } from 'react-i18next';
3
import I18NextHttpBackend, { BackendOptions } from 'i18next-http-backend';
4
import I18NextMultiloadBackendAdapter from 'i18next-multiload-backend-adapter';
5
6
// If we're using HMR use a unique hash per page reload so that we're always
7
// doing cache busting. Otherwise just use the builder provided hash value in
8
// the URL to allow cache busting to occur whenever the front-end is rebuilt.
9
const hash = module.hot ? Date.now().toString(16) : process.env.WEBPACK_BUILD_HASH;
10
11
i18n.use(I18NextMultiloadBackendAdapter)
12
.use(initReactI18next)
13
.init({
14
debug: process.env.DEBUG === 'true',
15
lng: 'en',
16
fallbackLng: 'en',
17
keySeparator: '.',
18
backend: {
19
backend: I18NextHttpBackend,
20
backendOption: {
21
loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}',
22
queryStringParams: { hash },
23
allowMultiLoading: true,
24
} as BackendOptions,
25
} as Record<string, any>,
26
interpolation: {
27
// Per i18n-react documentation: this is not needed since React is already
28
// handling escapes for us.
29
escapeValue: false,
30
},
31
});
32
33
export default i18n;
34
35