Skip to content

Commit

Permalink
Use native Promise for global/i18n (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jun 13, 2022
1 parent 96a92fd commit 08440c4
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions frontend/src/global/i18n.ts
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 08440c4

Please sign in to comment.