简体   繁体   English

如何将参数传递给翻译

[英]How to pass parameters to translations

I'm using vuejs 3 with TS.我正在使用带有 TS 的 vuejs 3。

I created the translation files in TS like this:我在 TS 中创建了这样的翻译文件:

index.ts:索引.ts:

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

In order then to use it in this way:为了然后以这种方式使用它:

{{ $t('example') }}

Now I would like to pass a parameter to the translation, like, for example:现在我想将一个参数传递给翻译,例如:

index.ts:索引.ts:

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

How can I do this?我怎样才能做到这一点?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM