【问题标题】:How to pass parameters to translations如何将参数传递给翻译
【发布时间】:2021-09-14 04:02:10
【问题描述】:

我正在使用带有 TS 的 vuejs 3。

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

index.ts:

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

为了以这种方式使用它:

{{ $t('example') }}

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

index.ts:

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

我该怎么做?

【问题讨论】:

    标签: typescript vue.js internationalization vuejs3 vue-i18n


    【解决方案1】:

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

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

    【讨论】:

    • 是的,实际上我读过它,我注意到我在代码中犯了一个错误。我只是拼错了。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    • 2020-02-05
    • 2011-05-07
    • 2020-10-09
    • 2012-12-21
    • 2012-01-07
    相关资源
    最近更新 更多