vue i18n中的复数化
·
问题:vue i18n中的复数化
嗨,我正在尝试基于https://kazupon.github.io/vue-i18n/guide/pluralization.html进行复数
imageCount== 1
? $t("message.imageMessage", 1, { imageCount})
: $t("message.imageMessage", imageCount, {
imageCount
})
imageMessage: '{imageCount} image downloaded | {imageCount} images downloaded'
问题:目前它正在显示不应该发生的消息,我实施的方式有什么问题吗?

Codesandbox:https://codesandbox.io/s/lingering-haze-z9jzt?fileu003d/src/components/HelloWorld.vue
解答
来自文档...
您的模板需要使用
$tc()而不是$t()。
您还可以通过在翻译字符串中使用{n}或{count}来改进/缩短代码...
en: {
message: {
imageMessage: "{n} image downloaded | {n} images downloaded"
}
}
并在您的模板中
$tc("message.imageMessage", imageCount)
更多推荐

所有评论(0)