vue-i18n-extract icon indicating copy to clipboard operation
vue-i18n-extract copied to clipboard

Linked messages are incorrectly reported as unused

Open JoostKersjes opened this issue 3 years ago • 0 comments

Linked messages can be used to combine existing messages into one larger message.

From what I can tell, vue-i18n-extract only checks the vueFiles to determine if a message is used or not, while the languageFiles also can use their own messages with this feature.

Steps to reproduce

  1. Create minimal Vue repo
  2. Set up vue-i18n
  3. Add following files:

src/locales/en-GB.json

{
  "message": {
    "the_world": "the world",
    "dio": "DIO:",
    "linked": "@:message.dio @:message.the_world !!!!"
  }
}

src/App.vue

<template>
  <p>{{ $t("message.linked") }}</p>
</template>
  1. Run npx vue-i18n-extract report --vueFiles './src/App.vue' --languageFiles './src/locales/*.?json'
  2. "message.the_world" and "message.dio" are reported as unused

What you expected would happen

Messages used to create linked messages to not be reported as unused.

My suggestion: Treat any message linked referenced with the @: syntax as used. If the message making the reference is deleted (because that message is maybe unused), the linked message will no longer be referenced, and should once again be reported as unused.

What actually happens

Messages used to create linked messages are reported as unused.

If you run npx vue-i18n-extract report --remove in this project, the App will break.

JoostKersjes avatar Sep 09 '22 10:09 JoostKersjes