Skip to content

Commit

Permalink
fix:修复国际化参数配置 (opentiny#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoyun8 authored Dec 7, 2023
1 parent 0cc2993 commit 0478258
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/canvas/src/components/render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const parseI18n = (i18n, scope, ctx) => {
return parseExpression(
{
type: 'JSExpression',
value: `this.i18n('${i18n.key}')`
value: `this.i18n('${i18n.key}', ${JSON.stringify(i18n.params)})`
},
scope,
{ i18n: i18nHost.global.t, ...ctx }
Expand Down
2 changes: 1 addition & 1 deletion packages/common/component/BindI18n.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
const params = []
const data = props?.data?.params || {}
curValue.replace(/\$\{(.+?)\}/g, (substr, key) => {
curValue.replace(/\{(.+?)\}/g, (substr, key) => {
key && params.push({ name: key, value: data[key] || '' })
})
paramsForm.value = params
Expand Down
7 changes: 6 additions & 1 deletion packages/vue-generator/src/generator/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ function handleBinding(props, attrsArr, description, state) {
}

if (propType === 'i18n') {
return attrsArr.push(`:${key}="t('${item.key}')"`)
const tArguments = [`'${item.key}'`]
const i18nParams = JSON.stringify(item.params)?.replace(/"/g, "'")

i18nParams && tArguments.push(i18nParams)

return attrsArr.push(`:${key}="t(${tArguments.join(',')})"`)
}

return attrsArr
Expand Down

0 comments on commit 0478258

Please sign in to comment.