Skip to content

Commit

Permalink
fix: initialize i18n only if its not already, extend otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgyulavari committed Sep 10, 2020
1 parent e39e5e6 commit e05b2f9
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/admin-bro.ts
Expand Up @@ -175,16 +175,19 @@ class AdminBro {
translations: combineTranslations(en.translations, this.options.locale?.translations),
language: this.options.locale?.language || en.language,
}

i18n.init({
lng: this.locale.language,
initImmediate: false, // loads translations immediately
resources: {
[this.locale.language]: {
translation: this.locale.translations,
if (i18n.isInitialized) {
i18n.addResourceBundle(this.locale.language, 'translation', this.locale.translations)
} else {
i18n.init({
lng: this.locale.language,
initImmediate: false, // loads translations immediately
resources: {
[this.locale.language]: {
translation: this.locale.translations,
},
},
},
})
})
}

// mixin translate functions to AdminBro instance so users will be able to
// call adminBro.translateMessage(...)
Expand Down

0 comments on commit e05b2f9

Please sign in to comment.