Skip to content

Commit

Permalink
fix: Wait for lazy loading promises (#163)
Browse files Browse the repository at this point in the history
* Prevent "WARN Cannot stringify a function"

* Make result const
  • Loading branch information
Alex--C authored and paulgv committed Jan 14, 2019
1 parent 21d4305 commit 8b42631
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/templates/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export async function loadLanguageAsync (i18n, locale) {
try {
const module = await import(/* webpackChunkName: "lang-[request]" */ '~/<%= options.langDir %>' + file)
const messages = module.default ? module.default : module
i18n.setLocaleMessage(locale, typeof messages === 'function' ? await Promise.resolve(messages()) : messages)
const result = typeof messages === 'function' ? await Promise.resolve(messages()) : messages
i18n.setLocaleMessage(locale, result)
i18n.loadedLanguages.push(locale)
return messages
return result
} catch (error) {
console.error(error)
}
Expand Down

0 comments on commit 8b42631

Please sign in to comment.