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

Commit

Permalink
fix(src/index.js): improve formatFallbackMessages code (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
masongzhi committed Feb 25, 2020
1 parent 2d659d4 commit 685c15e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
13 changes: 6 additions & 7 deletions dist/vue-i18n.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-i18n v8.15.3
* (c) 2020 kazuya kawaguchi
* (c) 2019 kazuya kawaguchi
* Released under the MIT License.
*/
'use strict';
Expand Down Expand Up @@ -1306,7 +1306,7 @@ VueI18n.prototype._getMessages = function _getMessages () { return this._vm.mess
VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };

VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {
VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values) {
if (!isNull(result)) { return result }
if (this._missing) {
var missingRet = this._missing.apply(null, [locale, key, vm, values]);
Expand All @@ -1324,7 +1324,7 @@ VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm,

if (this._formatFallbackMessages) {
var parsedArgs = parseArgs.apply(void 0, values);
return this._render(key, interpolateMode, parsedArgs.params, key)
return this._render(key, 'string', parsedArgs.params, key)
} else {
return key
}
Expand Down Expand Up @@ -1457,8 +1457,7 @@ VueI18n.prototype._link = function _link (
}
translated = this._warnDefault(
locale, linkPlaceholder, translated, host,
Array.isArray(values) ? values : [values],
interpolateMode
Array.isArray(values) ? values : [values]
);

if (this._modifiers.hasOwnProperty(formatterName)) {
Expand Down Expand Up @@ -1535,7 +1534,7 @@ VueI18n.prototype._t = function _t (key, _locale, messages, host) {
if (!this._root) { throw Error('unexpected error') }
return (ref = this._root).$t.apply(ref, [ key ].concat( values ))
} else {
return this._warnDefault(locale, key, ret, host, values, 'string')
return this._warnDefault(locale, key, ret, host, values)
}
};

Expand All @@ -1557,7 +1556,7 @@ VueI18n.prototype._i = function _i (key, locale, messages, host, values) {
if (!this._root) { throw Error('unexpected error') }
return this._root.$i18n.i(key, locale, values)
} else {
return this._warnDefault(locale, key, ret, host, [values], 'raw')
return this._warnDefault(locale, key, ret, host, [values])
}
};

Expand Down
11 changes: 5 additions & 6 deletions dist/vue-i18n.esm.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ class VueI18n {
_getDateTimeFormats () { return this._vm.dateTimeFormats }
_getNumberFormats () { return this._vm.numberFormats }

_warnDefault (locale, key, result, vm, values, interpolateMode) {
_warnDefault (locale, key, result, vm, values) {
if (!isNull(result)) { return result }
if (this._missing) {
const missingRet = this._missing.apply(null, [locale, key, vm, values]);
Expand All @@ -1301,7 +1301,7 @@ class VueI18n {

if (this._formatFallbackMessages) {
const parsedArgs = parseArgs(...values);
return this._render(key, interpolateMode, parsedArgs.params, key)
return this._render(key, 'string', parsedArgs.params, key)
} else {
return key
}
Expand Down Expand Up @@ -1433,8 +1433,7 @@ class VueI18n {
}
translated = this._warnDefault(
locale, linkPlaceholder, translated, host,
Array.isArray(values) ? values : [values],
interpolateMode
Array.isArray(values) ? values : [values]
);

if (this._modifiers.hasOwnProperty(formatterName)) {
Expand Down Expand Up @@ -1507,7 +1506,7 @@ class VueI18n {
if (!this._root) { throw Error('unexpected error') }
return this._root.$t(key, ...values)
} else {
return this._warnDefault(locale, key, ret, host, values, 'string')
return this._warnDefault(locale, key, ret, host, values)
}
}

Expand All @@ -1525,7 +1524,7 @@ class VueI18n {
if (!this._root) { throw Error('unexpected error') }
return this._root.$i18n.i(key, locale, values)
} else {
return this._warnDefault(locale, key, ret, host, [values], 'raw')
return this._warnDefault(locale, key, ret, host, [values])
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/vue-i18n.esm.browser.min.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions dist/vue-i18n.esm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-i18n v8.15.3
* (c) 2020 kazuya kawaguchi
* (c) 2019 kazuya kawaguchi
* Released under the MIT License.
*/
/* */
Expand Down Expand Up @@ -1304,7 +1304,7 @@ VueI18n.prototype._getMessages = function _getMessages () { return this._vm.mess
VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };

VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {
VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values) {
if (!isNull(result)) { return result }
if (this._missing) {
var missingRet = this._missing.apply(null, [locale, key, vm, values]);
Expand All @@ -1322,7 +1322,7 @@ VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm,

if (this._formatFallbackMessages) {
var parsedArgs = parseArgs.apply(void 0, values);
return this._render(key, interpolateMode, parsedArgs.params, key)
return this._render(key, 'string', parsedArgs.params, key)
} else {
return key
}
Expand Down Expand Up @@ -1455,8 +1455,7 @@ VueI18n.prototype._link = function _link (
}
translated = this._warnDefault(
locale, linkPlaceholder, translated, host,
Array.isArray(values) ? values : [values],
interpolateMode
Array.isArray(values) ? values : [values]
);

if (this._modifiers.hasOwnProperty(formatterName)) {
Expand Down Expand Up @@ -1533,7 +1532,7 @@ VueI18n.prototype._t = function _t (key, _locale, messages, host) {
if (!this._root) { throw Error('unexpected error') }
return (ref = this._root).$t.apply(ref, [ key ].concat( values ))
} else {
return this._warnDefault(locale, key, ret, host, values, 'string')
return this._warnDefault(locale, key, ret, host, values)
}
};

Expand All @@ -1555,7 +1554,7 @@ VueI18n.prototype._i = function _i (key, locale, messages, host, values) {
if (!this._root) { throw Error('unexpected error') }
return this._root.$i18n.i(key, locale, values)
} else {
return this._warnDefault(locale, key, ret, host, [values], 'raw')
return this._warnDefault(locale, key, ret, host, [values])
}
};

Expand Down
13 changes: 6 additions & 7 deletions dist/vue-i18n.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* vue-i18n v8.15.3
* (c) 2020 kazuya kawaguchi
* (c) 2019 kazuya kawaguchi
* Released under the MIT License.
*/
(function (global, factory) {
Expand Down Expand Up @@ -1310,7 +1310,7 @@
VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };

VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {
VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values) {
if (!isNull(result)) { return result }
if (this._missing) {
var missingRet = this._missing.apply(null, [locale, key, vm, values]);
Expand All @@ -1328,7 +1328,7 @@

if (this._formatFallbackMessages) {
var parsedArgs = parseArgs.apply(void 0, values);
return this._render(key, interpolateMode, parsedArgs.params, key)
return this._render(key, 'string', parsedArgs.params, key)
} else {
return key
}
Expand Down Expand Up @@ -1461,8 +1461,7 @@
}
translated = this._warnDefault(
locale, linkPlaceholder, translated, host,
Array.isArray(values) ? values : [values],
interpolateMode
Array.isArray(values) ? values : [values]
);

if (this._modifiers.hasOwnProperty(formatterName)) {
Expand Down Expand Up @@ -1539,7 +1538,7 @@
if (!this._root) { throw Error('unexpected error') }
return (ref = this._root).$t.apply(ref, [ key ].concat( values ))
} else {
return this._warnDefault(locale, key, ret, host, values, 'string')
return this._warnDefault(locale, key, ret, host, values)
}
};

Expand All @@ -1561,7 +1560,7 @@
if (!this._root) { throw Error('unexpected error') }
return this._root.$i18n.i(key, locale, values)
} else {
return this._warnDefault(locale, key, ret, host, [values], 'raw')
return this._warnDefault(locale, key, ret, host, [values])
}
};

Expand Down
4 changes: 2 additions & 2 deletions dist/vue-i18n.min.js

Large diffs are not rendered by default.

0 comments on commit 685c15e

Please sign in to comment.