diff --git a/package.json b/package.json index ad692794a..73102ac0a 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "fork-awesome": "1.2.0", "highlight.js": "11.3.1", "http-server": "14.0.0", - "i18next": "21.4.2", + "i18next": "21.5.2", "i18next-browser-languagedetector": "6.1.2", "i18next-resources-to-backend": "1.0.0", "js-yaml": "4.1.0", diff --git a/src/components/application-loader/initializers/i18n/i18n.ts b/src/components/application-loader/initializers/i18n/i18n.ts index f16dc0a7b..019452125 100644 --- a/src/components/application-loader/initializers/i18n/i18n.ts +++ b/src/components/application-loader/initializers/i18n/i18n.ts @@ -5,15 +5,14 @@ */ import type { ResourceKey } from 'i18next' -import i18n 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 => { - await i18n - .use( + await i18nUse( resourcesToBackend((language, namespace, callback) => { import(`../../../../../locales/${language}.json`) .then((resources: ResourceKey) => { diff --git a/src/components/editor-page/editor-pane/upload-handler.ts b/src/components/editor-page/editor-pane/upload-handler.ts index a9f90da5d..7a63eaa0e 100644 --- a/src/components/editor-page/editor-pane/upload-handler.ts +++ b/src/components/editor-page/editor-pane/upload-handler.ts @@ -5,7 +5,7 @@ */ import type { Editor } from 'codemirror' -import i18n from 'i18next' +import { t } from 'i18next' import { uploadFile } from '../../../api/media' import { store } from '../../../redux' import { supportedMimeTypes } from '../../common/upload-image-mimetypes' @@ -22,7 +22,7 @@ export const handleUpload = (file: File, editor: Editor): void => { return } const cursor = editor.getCursor() - const uploadPlaceholder = `![${i18n.t('editor.upload.uploadFile', { fileName: file.name })}]()` + const uploadPlaceholder = `![${t('editor.upload.uploadFile', { fileName: file.name })}]()` const noteId = store.getState().noteDetails.id const insertCode = (replacement: string) => { editor.replaceRange(replacement, cursor, { line: cursor.line, ch: cursor.ch + uploadPlaceholder.length }, '+input') diff --git a/src/redux/ui-notifications/methods.ts b/src/redux/ui-notifications/methods.ts index 9f3dd95c1..f9ce61bb7 100644 --- a/src/redux/ui-notifications/methods.ts +++ b/src/redux/ui-notifications/methods.ts @@ -5,7 +5,7 @@ */ import type { TOptions } from 'i18next' -import i18n from 'i18next' +import { t } from 'i18next' import { store } from '../index' import type { DismissUiNotificationAction, DispatchOptions } from './types' import { UiNotificationActionType } from './types' @@ -75,7 +75,7 @@ export const dismissUiNotification = (notificationId: number): void => { export const showErrorNotification = (messageI18nKey: string, messageI18nOptions?: TOptions | string) => (error: Error): void => { - log.error(i18n.t(messageI18nKey, messageI18nOptions), error) + log.error(t(messageI18nKey, messageI18nOptions), error) void dispatchUiNotification('common.errorOccurred', messageI18nKey, { contentI18nOptions: messageI18nOptions, icon: 'exclamation-triangle' diff --git a/yarn.lock b/yarn.lock index b7e0d4866..d2861cd36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8056,10 +8056,10 @@ i18next-resources-to-backend@1.0.0: dependencies: "@babel/runtime" "7.14.0" -i18next@21.4.2: - version "21.4.2" - resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.4.2.tgz#10d10e07c9d1d589d71ac031f8ae755a37fcd0fc" - integrity sha512-vVWsmTnZNdYHPLt01MvT5YNM2lxec2R6r5T72J89eaazp8XQnGSqA66O+a918qqmjHZGB6HHRSs02xp753he9g== +i18next@21.5.2: + version "21.5.2" + resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.5.2.tgz#ababe6fb0a769360035ebf06a36751e0b810cdfa" + integrity sha512-Iuztr2+7CPCh5SYQV0utw2HXMx1za18xfznrw/PmgX+98oIpm84bhIM7VUPODjLycwIZ299oP7sEVQ9oCgmzfg== dependencies: "@babel/runtime" "^7.12.0"