From 08440c4640f98e47081392fc1e728a9c398c278d Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Fri, 10 Jun 2022 16:38:51 +0200 Subject: [PATCH] Use native Promise for global/i18n (#451) --- frontend/src/global/i18n.ts | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/frontend/src/global/i18n.ts b/frontend/src/global/i18n.ts index 2ddedaf7..e1700f31 100644 --- a/frontend/src/global/i18n.ts +++ b/frontend/src/global/i18n.ts @@ -1,31 +1,29 @@ -import { Deferred } from 'jquery'; import * as i18next from 'i18next'; import * as languageDetector from 'i18next-browser-languagedetector'; import * as english from '../i18n/en/translation.json'; import * as french from '../i18n/fr/translation.json'; -const deferred = Deferred(); -const i18nPromise = deferred.promise(); - -i18next.use( - languageDetector -).init({ - fallbackLng: ['en', 'dev'], - resources: { - en: { - translation: english, - }, - fr: { - translation: french, +const i18nPromise = new Promise(function(resolve, reject) { + i18next.use( + languageDetector + ).init({ + fallbackLng: ['en', 'dev'], + resources: { + en: { + translation: english, + }, + fr: { + translation: french, + }, }, - }, -}, function(error, t) { - if (error) { - deferred.reject(error); - } else { - deferred.resolve(i18next); - } + }, function(error, t) { + if (error) { + reject(error); + } else { + resolve(i18next); + } + }); }); export { i18nPromise, i18next };