1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 18:42:31 +01:00
Pterodactyl-Panel/resources/scripts/i18n.ts

34 lines
1.2 KiB
TypeScript
Raw Normal View History

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.
2022-11-25 21:25:03 +01:00
const hash = Date.now().toString(16);
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;