Synchronous init? #636

Closed
megapctr opened this Issue Mar 31, 2016 · 3 comments

Projects

None yet

2 participants

@megapctr

Hi, is there a proper way to initialize i18next synchronously?

I import my translations from a json file (via webpack), so they're available instantly. Therefore I'd expect i18n.t to be ready to use as soon as i18n.init is called. Instead, I have to wait for callback to be called.

By browsing through the source code, I came up with this:

i18n.init({
    resources: translations,
    lng: language,
    ...
})
i18n.changeLanguage(language)

It's more of a hack than a solution -- is there a proper way to do this?

@jamuhl
Member
jamuhl commented Mar 31, 2016

hm...i see...will call changeLanguage immediatly when passing in resources...will keep you uptodate.

@megapctr
megapctr commented Apr 4, 2016

Works, thanks :)

@megapctr megapctr closed this Apr 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment