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

Fetching a message without compilation #1884

Open
3 tasks done
thany opened this issue Jul 5, 2024 · 0 comments
Open
3 tasks done

Fetching a message without compilation #1884

thany opened this issue Jul 5, 2024 · 0 comments
Labels
Status: Proposal Request for comments

Comments

@thany
Copy link

thany commented Jul 5, 2024

Clear and concise description of the problem

We need regexes in our translation files, for localised validation of things. Regexes are already annoying to read, and having to put extra encoding in them makes them even less readable.

Suggested solution

A way to fetch a translation message, without attempting to "compile" it. It should ignore all special characters in it, and just return the string exactly as-is, without processing or compilation. This could be a switch in the TranslationOptions object that is given in the t function, since compilation appears to occur just-in-time, e.g. when a message is fetched.

Alternative

Like I said, it would require annoying encoding in a string that is already hard to read:

\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{8,14}$|0[89]0[069]d{4,7}$|07[078]d{6}$

Would need to become, well, I dunno what exactly. A even uglier monster 🙂
I'm not convinced that changing all regexes is a viable alternative, but it is technically an alternative.

I guess for now we should rather hardcode regexes into the application, but having a workaround should not demotivate finding a solution.

Additional context

Might be helpful to know that this had worked fine in version 8. We skipped 9, and when straight to 10 while upgrading to Vue 3.

Validations

@thany thany added the Status: Proposal Request for comments label Jul 5, 2024
@thany thany changed the title Fetching a messages without compilation Fetching a message without compilation Jul 8, 2024
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

1 participant