Skip to content

Commit

Permalink
💥 breaking(formatter): change method name
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed May 2, 2017
1 parent 19babec commit 6eed51c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
let tokens: Array<Token> = this._caches[message]
if (!tokens) {
tokens = parse(message)
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/unit/format_custom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand All @@ -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()
}
}
Expand Down

0 comments on commit 6eed51c

Please sign in to comment.