Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolations without provided value should remain in the translation result #1638

Open
3 tasks done
rubenduiveman opened this issue Nov 22, 2023 · 1 comment
Open
3 tasks done
Labels
Status: Proposal Request for comments

Comments

@rubenduiveman
Copy link

Clear and concise description of the problem

We're upgrading to v9.x. When translating a string, we want to perform some extra logic on the result, using special tags {tag} to be replaced in the translated result. In V8, the translated value still contained those values, but in V9 it doesn't anymore.

Input: { val: "I am a special {tag} string" }, calling t("val").
V8 result: I am a special {tag} string
V9 result: I am a special string

Suggested solution

Let's add an option to createI18n to toggle between those behaviors globally if it's not there.

Alternative

No response

Additional context

No response

Validations

@rubenduiveman rubenduiveman added the Status: Proposal Request for comments label Nov 22, 2023
@JvanderHeide
Copy link

JvanderHeide commented Apr 5, 2024

Currently missing exactly this behaviour.

E.g.: with the following translation key:

en:
  form.validations.xxx: '{label} should be at least {min} characters'

In combination with Zod for validation:

message: i18n.t("form.validations.xxx", {
  min: issue.minimum
})

The actual outcome is: should be at least 1 characters,
Whereas I expect to find {label} should be at least 1 characters, for re-use later on like so:

{{ t(errorMessage, {label, name, inputValue}, {resolvedMessage: true}) }

My current work around is to manually map the missing keys back to their respective placeholders:

message: i18n.t("form.validations.xxx", {
  min: issue.minimum,
  label: '{label}',
  name: '{name}',
  inputValue: '{inputValue}'
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

2 participants