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

Prevent vue-i18n special characters causing error #11287

Merged
merged 2 commits into from
Jan 26, 2022
Merged

Conversation

azrikahar
Copy link
Contributor

Fixes #11056

Context

Ref #11056 (comment). There are several special characters in vue-i18n that will cause error when users add them in field/collection translations.

For example, if a user types title@here as the field translation, the @ will be interpreted as linked message. But since the format is malformed (it should be @:key where key is an existing translation key), it errors out.

The offending line is here inside parseField function:

name = i18n.global.t(`fields.${field.collection}.${field.field}`);

This will only throw console errors during dev, but it ends up throwing an error in production environment and prevent any logged in user in that particular locale from doing anything.

WGujPJ7WSZ

Solution

Apply the recommended literal interpolations on all the special characters when they are parsed.

Result

Wt4BNiSOKE

@rijkvanzanten rijkvanzanten merged commit 7c7158a into main Jan 26, 2022
@rijkvanzanten rijkvanzanten deleted the issue/11056 branch January 26, 2022 12:59
@rijkvanzanten rijkvanzanten added this to the v9-next milestone Jan 26, 2022
@rijkvanzanten rijkvanzanten self-assigned this Jan 26, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The char @ in the translation of a field name produces an Unknown error
2 participants