微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将参数传递给翻译

如何解决如何将参数传递给翻译

我将 vuejs 3 与 TS 一起使用。

我在 TS 中创建了这样的翻译文件

index.ts:

export default {
 'example': 'example',}

为了然后以这种方式使用它:

{{ $t('example') }}

现在我想向翻译传递一个参数,例如:

index.ts:

export default {
 'hi_man': 'Hi {name}',//where the name is the parameter
}

我该怎么做?

解决方法

也许您应该考虑阅读文档:https://kazupon.github.io/vue-i18n/guide/formatting.html#named-formatting

<p>{{ $t('hi_man',{ name: 'Monkey' }) }}</p>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。