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

Commit 6eed51c

Browse files
committed
💥 breaking(formatter): change method name
1 parent 19babec commit 6eed51c

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class BaseFormatter {
1313

1414
get options (): FormatterOptions { return this._options }
1515

16-
format (message: string, values: any): any {
16+
interpolate (message: string, values: any): Array<any> {
1717
let tokens: Array<Token> = this._caches[message]
1818
if (!tokens) {
1919
tokens = parse(message)

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export default class VueI18n {
220220
}
221221

222222
_render (message: string, interpolateMode: string, values: any): any {
223-
const ret = this._formatter.format(message, values)
223+
const ret = this._formatter.interpolate(message, values)
224224
// if interpolateMode is **not** 'string' ('row'),
225225
// return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter
226226
return interpolateMode === 'string' ? ret.join('') : ret

test/unit/format_custom.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ describe('custom formatter', () => {
44
describe('via i18n instance API calling', () => {
55
it('should allows for specifying a custom formatter', done => {
66
class CustomFormatter {
7-
format (message, ...args) {
8-
assert.deepEqual({ name: 'joe' }, args[0])
7+
interpolate (message, values) {
8+
assert.deepEqual({ name: 'joe' }, values)
99
done()
1010
}
1111
}
@@ -22,8 +22,8 @@ describe('custom formatter', () => {
2222
describe('via vue instance calling', () => {
2323
it('should allows for specifying a custom formatter', done => {
2424
const formatter = {
25-
format: (message, ...args) => {
26-
assert.deepEqual([1, 2, 3], args[0])
25+
interpolate: (message, values) => {
26+
assert.deepEqual([1, 2, 3], values)
2727
done()
2828
}
2929
}

0 commit comments

Comments
 (0)