Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit 9fbe467

Browse files
houd1nikazupon
authored andcommitted
⚡ improvement(index): support retunable missing handler (#256) by @houd1ni
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.
1 parent dffc678 commit 9fbe467

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,11 @@ export default class VueI18n {
171171

172172
_warnDefault (locale: Locale, key: Path, result: ?any, vm: ?any, values: any): ?string {
173173
if (!isNull(result)) { return result }
174-
if (this._missing) {
175-
this._missing.apply(null, [locale, key, vm, values])
174+
if (this.missing) {
175+
const missingResult = this.missing.call(null, locale, key, vm)
176+
if (typeof missingResult === 'string') {
177+
return missingResult
178+
}
176179
} else {
177180
if (process.env.NODE_ENV !== 'production' && !this._silentTranslationWarn) {
178181
warn(

0 commit comments

Comments
 (0)