Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export type PreCompileHandler = () => {
functions: MessageFunctions
}

export type CustomBlocks = string[] | PreCompileHandler
export type CustomBlocks = Array<string | LocaleMessages> | PreCompileHandler

/**
* Composer Options
Expand Down Expand Up @@ -222,7 +222,7 @@ function getLocaleMessages(
// merge locale messages of i18n custom block
if (isArray(__i18n)) {
__i18n.forEach(raw => {
ret = Object.assign(ret, JSON.parse(raw))
ret = Object.assign(ret, isString(raw) ? JSON.parse(raw) : raw)
})
return ret
}
Expand Down
29 changes: 29 additions & 0 deletions test/composer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,35 @@ describe('__i18n', () => {
}
})
})

test('locale messages object', () => {
const { messages } = createComposer({
__i18n: [
{ en: { hello: 'Hello,world!' } },
{
ja: {
hello: 'こんにちは、世界!',
nest: {
foo: {
bar: 'ばー'
}
}
}
}
]
})
expect(messages.value).toEqual({
en: { hello: 'Hello,world!' },
ja: {
hello: 'こんにちは、世界!',
nest: {
foo: {
bar: 'ばー'
}
}
}
})
})
})

describe('__transrateVNode', () => {
Expand Down