2

嗨,我正在尝试根据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?file=/src/components/HelloWorld.vue

4

1 回答 1

5

文档...

您的模板将需要使用$tc()而不是$t().


您还可以通过使用{n}{count}在您的翻译字符串中改进/缩短您的代码......

en: {
  message: {
    imageMessage: "{n} image downloaded | {n} images downloaded"
  }
}

并在您的模板中

$tc("message.imageMessage", imageCount)
于 2020-04-30T06:00:01.957 回答