Skip to content

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

Open
@kyh196201

Description

@kyh196201

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions