mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
refactor: move mockI18n
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
3962cafa5d
commit
86276b0753
35 changed files with 36 additions and 36 deletions
26
frontend/src/test-utils/mock-i18n.ts
Normal file
26
frontend/src/test-utils/mock-i18n.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { TFunction } from 'i18next'
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
|
||||
/**
|
||||
* Initializes i18n with minimal settings and without any data, so it just returns the used key as translation.
|
||||
*
|
||||
* @return A promise that resolves if i18n has been initialized
|
||||
*/
|
||||
export const mockI18n = (): Promise<TFunction> => {
|
||||
return i18n.use(initReactI18next).init({
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
ns: ['translationsNS'],
|
||||
defaultNS: 'translationsNS',
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
},
|
||||
resources: { en: { translationsNS: {} } }
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue