Skip to content

Commit

Permalink
Merge pull request #596 from adamgyulavari/adam-fix-i18n-init
Browse files Browse the repository at this point in the history
fix: initialize i18n only if its not already, extend otherwise

closes #592
  • Loading branch information
wojtek-krysiak authored Sep 23, 2020
2 parents dc19588 + e05b2f9 commit 77d8da1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/admin-bro.ts
Original file line number Diff line number Diff line change
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 77d8da1

Please sign in to comment.