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

Not reporting Missing key when using CRLF end of line sequence #218

Open
kyh196201 opened this issue Aug 1, 2024 · 0 comments
Open

Not reporting Missing key when using CRLF end of line sequence #218

kyh196201 opened this issue Aug 1, 2024 · 0 comments

Comments

@kyh196201
Copy link

kyh196201 commented Aug 1, 2024

Hello! I'm using vue-i18n-extract in my project.
First of all, thank you for creating such an awesome project!
I discovered that vue-i18n-extract cannot detect or collect missing keys when using CRLF end-of-line sequences.

Upon examining the source code, I found that the componentRegExp inside the extractComponentMatches function only detects the LF end-of-line sequence.

const componentRegExp = /(?:(?:<|h\()(?:i18n|Translation))(?:.|\n)*?(?:\s(?:(?:key)?)path(?:=|: )("|'))((?:[^\\]|\\.)*?)\1/gi;

I tried the following regex, which successfully detects the CRLF end-of-line sequence.

const componentRegex = /(?:(?:<|h\()(?:i18n|Translation))(?:.|\r?\n|\r)*?(?:[^:]path(?:=|: )("|'))((?:[^\\]|\\.)*?)\1/gi;

Expected behavior

The regex should detect missing keys in the i18n-t component, even when CRLF end-of-line sequences are used.

<i18n-t
  tag="p"
  keypath="The grass is always greener on the other side of the fence from {username}"
  class="message"
>
  <template #username> {{ username }} </template>
</i18n-t>

Actual behavior

The current regex does not detect or collect missing keys when the i18n-t component uses CRLF end-of-line sequences.


Steps to reproduce

  1. Set singleAttributePerLine to true in your .prettierrc file.
  2. Change the end-of-line sequence to CRLF.
  3. Create an i18n-t component with multiple props and attributes.
  4. Run the vue-i18n-extract report.

You can try with this setup with the following sandbox

npm run vue-i18n-extract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant