#734·vue-i18n

Allow use of modifiers on arguments

Author: BenAlbinCreated Nov 1, 2019Updated Oct 11, 2024
LabelsStatus: ProposalType: Feature

For example:

Desired text 1: "Creating user failed."

Desired text 2: "User successfully created."

Imagine there are multiple 'things' that could be created, and I don't want to write out translations for every one of them.

My current method:

translations:

"messages": {
  "createSuccess": "{thing} successfully created.",
  "createFailed": "Creating {thing} failed."
},
"things": {
  "user": {
    "lower": "user",
    "proper": "User"
  }
}

usage:

$t("messages.createSuccess", { thing:  $t("things.user.proper") })
$t("messages.createFailed", { thing: $t("things.user.lower") })

Desired translations:

...
"messages": {
  "createSuccess": ".proper:{thing} successfully created."
  "createFailed": "Creating .lower:{thing} failed."
}
"things": {
  "user": "user"
}
...

Using a custom modifier obviously for proper case.

I don't know what syntax would make sense.

This could be handled within templates, but it should really be the responsibility of the translations.

This seems like it could also be solved if we could link to arguments. For example:

"@.modifier:{thing}"