Open notiv-nt opened 5 years ago
I've been flattening my parameters.
function flattenObjectParameters (obj, prefix = '') {
return Object.keys(obj).reduce((params, key) => {
const pre = prefix.length ? prefix + '.' : ''
if (typeof obj[key] === 'object') {
Object.assign(params, flattenObjectParameters(obj[key], pre + key))
} else {
params[pre + key] = obj[key]
}
return params
}, {})
then
const params = {
id: 3,
data: {
name: 'John',
}
}
this.$t('hello', flattenObjectParameters(params))
I prefer your solution.
any new news?
vue@2.6.8, vue-i18n@8.11.2
Reproduction Link
http://jsfiddle.net/psqw6gv9/
What is Expected?
should work
What is actually happening?
data.name
not workingSolution ?
https://github.com/kazupon/vue-i18n/blob/d28e3b25d9bd9eac51fc3714a4a2940772d85c3d/src/format.js#L96-L98