Skip to content

Commit

Permalink
⚡ improvement(index): support retunable missing handler (#256) by @ho…
Browse files Browse the repository at this point in the history
…ud1ni

Missing() can produce some dynamic results, using it's own fallback algorythm and make something like 'header.nav.toHome' -> 'To Home' transformation e.g. It's would be interesting to make it async, but it seems that it's a little bit deeper change.
  • Loading branch information
houd1ni authored and kazupon committed Mar 13, 2018
1 parent dffc678 commit 9fbe467
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ export default class VueI18n {

_warnDefault (locale: Locale, key: Path, result: ?any, vm: ?any, values: any): ?string {
if (!isNull(result)) { return result }
if (this._missing) {
this._missing.apply(null, [locale, key, vm, values])
if (this.missing) {
const missingResult = this.missing.call(null, locale, key, vm)
if (typeof missingResult === 'string') {
return missingResult
}
} else {
if (process.env.NODE_ENV !== 'production' && !this._silentTranslationWarn) {
warn(
Expand Down

0 comments on commit 9fbe467

Please sign in to comment.