diff --git a/src/format.js b/src/format.js index 9c461731b..79b92fb4b 100644 --- a/src/format.js +++ b/src/format.js @@ -13,7 +13,7 @@ export default class BaseFormatter { get options (): FormatterOptions { return this._options } - format (message: string, values: any): any { + interpolate (message: string, values: any): Array { let tokens: Array = this._caches[message] if (!tokens) { tokens = parse(message) diff --git a/src/index.js b/src/index.js index 0fd28470d..f0af88b07 100644 --- a/src/index.js +++ b/src/index.js @@ -220,7 +220,7 @@ export default class VueI18n { } _render (message: string, interpolateMode: string, values: any): any { - const ret = this._formatter.format(message, values) + const ret = this._formatter.interpolate(message, values) // if interpolateMode is **not** 'string' ('row'), // return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter return interpolateMode === 'string' ? ret.join('') : ret diff --git a/test/unit/format_custom.test.js b/test/unit/format_custom.test.js index b1bc42a3f..949f2d26c 100644 --- a/test/unit/format_custom.test.js +++ b/test/unit/format_custom.test.js @@ -4,8 +4,8 @@ describe('custom formatter', () => { describe('via i18n instance API calling', () => { it('should allows for specifying a custom formatter', done => { class CustomFormatter { - format (message, ...args) { - assert.deepEqual({ name: 'joe' }, args[0]) + interpolate (message, values) { + assert.deepEqual({ name: 'joe' }, values) done() } } @@ -22,8 +22,8 @@ describe('custom formatter', () => { describe('via vue instance calling', () => { it('should allows for specifying a custom formatter', done => { const formatter = { - format: (message, ...args) => { - assert.deepEqual([1, 2, 3], args[0]) + interpolate: (message, values) => { + assert.deepEqual([1, 2, 3], values) done() } }