mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 18:55:19 -04:00
![renovate[bot]](/assets/img/avatar_default.png)
* Update dependency i18next to v21.5.2 Signed-off-by: Renovate Bot <bot@renovateapp.com> * Fix i18n imports Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
37 lines
1 KiB
TypeScript
37 lines
1 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import type { ResourceKey } from 'i18next'
|
|
import i18n, { use as i18nUse } from 'i18next'
|
|
import LanguageDetector from 'i18next-browser-languagedetector'
|
|
import resourcesToBackend from 'i18next-resources-to-backend'
|
|
import { Settings } from 'luxon'
|
|
import { initReactI18next } from 'react-i18next'
|
|
|
|
export const setUpI18n = async (): Promise<void> => {
|
|
await i18nUse(
|
|
resourcesToBackend((language, namespace, callback) => {
|
|
import(`../../../../../locales/${language}.json`)
|
|
.then((resources: ResourceKey) => {
|
|
callback(null, resources)
|
|
})
|
|
.catch((error: Error) => {
|
|
callback(error, null)
|
|
})
|
|
})
|
|
)
|
|
.use(LanguageDetector)
|
|
.use(initReactI18next)
|
|
.init({
|
|
fallbackLng: 'en',
|
|
debug: process.env.NODE_ENV !== 'production',
|
|
interpolation: {
|
|
escapeValue: false
|
|
}
|
|
})
|
|
|
|
Settings.defaultLocale = i18n.language
|
|
}
|