vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Modifiers for interpolated values

Open lnvglr opened this issue 5 months ago • 0 comments

Clear and concise description of the problem

Lets say you want to translate "Passenger" as well as "Remove passenger". And let's say passengers are not the only thing you want to remove (i.e. images, links etc.).

Currently, what you have to do (it seems), is to add a source key for every scenario:

{
  "passenger": "Passenger",
  "image": "Image",
  "link": "Link",
  "remove.passenger": "Remove @.lower:passenger",
  "remove.image": "Remove @.lower:image",
  "remove.link": "Remove @.lower:link"
}

And you would use it like so: $t("remove.passenger"). But that seems awfully redundant!

Suggested solution

What if, instead, you could lowercase interpolated strings.

{
  "remove": "Remove @.lower:{value}",
  "passenger": "Passenger",
  "image": "Image",
  "link": "Link",
}

And you would use it like so $t("remove", { value: $t("passenger") } )

Alternative

No response

Additional context

This would open up endless possibilities, especially for custom modifiers

Validations

lnvglr avatar Mar 01 '24 10:03 lnvglr