mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 04:24:43 -04:00
Replace i18next-http-backend with i18next-resources-to-backend (#1466)
* Replace i18next-http-backend with i18next-resources-to-backend Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
dee494386a
commit
7fb7c55877
33 changed files with 30 additions and 24 deletions
|
@ -6,22 +6,28 @@
|
|||
|
||||
import i18n from 'i18next'
|
||||
import LanguageDetector from 'i18next-browser-languagedetector'
|
||||
import Backend from 'i18next-http-backend'
|
||||
import resourcesToBackend from 'i18next-resources-to-backend'
|
||||
import { Settings } from 'luxon'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
|
||||
export const setUpI18n = async (frontendAssetsUrl: string): Promise<void> => {
|
||||
export const setUpI18n = async (): Promise<void> => {
|
||||
await i18n
|
||||
.use(Backend)
|
||||
.use(
|
||||
resourcesToBackend((language, namespace, callback) => {
|
||||
import(`../../../../../locales/${language}.json`)
|
||||
.then((resources) => {
|
||||
callback(null, resources)
|
||||
})
|
||||
.catch((error) => {
|
||||
callback(error, null)
|
||||
})
|
||||
})
|
||||
)
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
fallbackLng: 'en',
|
||||
debug: process.env.NODE_ENV !== 'production',
|
||||
backend: {
|
||||
loadPath: `${frontendAssetsUrl}locales/{{lng}}.json`
|
||||
},
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { setUpI18n } from './i18n'
|
||||
import { setUpI18n } from './i18n/i18n'
|
||||
import { refreshHistoryState } from '../../../redux/history/methods'
|
||||
import { fetchAndSetBanner } from './fetch-and-set-banner'
|
||||
import { setApiUrl } from '../../../redux/api-url/methods'
|
||||
|
@ -36,7 +36,7 @@ export const createSetUpTaskList = (
|
|||
return [
|
||||
{
|
||||
name: 'Load Translations',
|
||||
task: setUpI18n(frontendAssetsUrl)
|
||||
task: setUpI18n()
|
||||
},
|
||||
{
|
||||
name: 'Load config',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue