简体   繁体   中英

How to pass parameters to translations

I'm using vuejs 3 with TS.

I created the translation files in TS like this:

index.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:

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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