intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.12k stars 325 forks source link

Linked message and pluralization #939

Open zanzara opened 2 years ago

zanzara commented 2 years ago

Clear and concise description of the problem

In some languages (as german i.e.) there exists the Genitive case in mostly appending a 's' char at the end. So I tried to solve it with pluralization:

auth: {
  labels: {
     password: "Passwort | Passworts",
...     
    password: {
        change: {
          error: "Fehler beim Ändern des @:auth.labels.password{'s'}"

but my problem is, to have it choiceabel in the linked message itself!?! Of course , I can put a traling {'s'} but I wish to have a solution as this i.e. @:auth.labels.password{[2]} @:auth.labels.password|2

Suggested solution

To have the ability to add the proper index into the linked message @:auth.labels.password{[index]} or @:auth.labels.password|index

Alternative

No response

Additional context

I hope, this topic wasn't discussed somwhere yet. I couldn't find anything regarding such an approach. Using: "vue": "^3.0.0", "vue-i18n": "^9.0.0",

Validations

andrey-hohlov commented 1 year ago

This works for me:

{
  "validation": {
    "plurals": {
      "symbol": "no symbol | {n} symbol | {n} symbols"
    },
    "string": {
      "min": "Min length @:validation.plurals.symbol"
    }
  }
}
t('validation.string.min', 3); // Min length 3 symbols
t('validation.string.min', 1); // Min length 1 symbol