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

fix(translationtool): Improve regex for vue translation matching #663

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Sep 9, 2024

Signed-off-by: Joas Schilling <coding@schilljs.com>
@zorn-v
Copy link
Member

zorn-v commented Sep 9, 2024

It can be done via "ungreed ?" operator.
Like

/\Wt\s*\(\s*'?([\w.]+)'?,\s*'(.+?)'\s*/
                           here ^

But anyway, these regexp are ugly. And more of then it repeated 6 times.
It must to be refactored.

By the way third regexp is pointless. One slash in php double quotes just escape "everything" and did not make sense in case of "template quote".
I think there must be "backtick" (`) and not single quote (')

In the end - why not to do something like ['"\`]? I don't know.

@tintou
Copy link
Contributor

tintou commented Sep 10, 2024

I don't really know how to review this, it sounds like it requires a test set somehow, also there is this project that deals with string extractions that might be worth considering 🤷

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

That's a cool thing, unluckily most apps are not using Vue3 yet.

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

Added some testing as well

@nickvergessen nickvergessen merged commit b29a4c2 into master Sep 10, 2024
3 checks passed
@nickvergessen nickvergessen deleted the bugfix/noid/better-vue-matching branch September 10, 2024 13:20
@zorn-v
Copy link
Member

zorn-v commented Sep 10, 2024

For testing purpose provide

t('qwe"asd', "asd)qwe")
t(someVar, "qwe'asd" )
t(some.var, `It
"is" 
'some
template`)

Last one was a joke as incorrect "template quote" in regexp

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

Successfully merging this pull request may close these issues.

bug(l10n): Files are not parsed correctly leading to defect entries at Transifex
3 participants