-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use native Promise for global/i18n (#451)
- Loading branch information
1 parent
96a92fd
commit 08440c4
Showing
1 changed file
with
19 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |