intlify / vue-cli-plugin-i18n

:globe_with_meridians: Vue CLI plugin to add vue-i18n to your Vue Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'vue)'' is not recognized as an internal or external command

m4ss1m0g opened this issue · comments

System

  • vuecli 4.1.2
  • yarn 1.21.1
  • OS Windows 10

Steps to reproduce

  1. vue create -d -n repro

  2. cd repro

  3. vue add i18n

  4. Setup with

    • locale: en,
    • fallback: en,
    • localization directory: locales,
    • enable locale on single file component: yes
  5. yarn run i18n:report

Expected behavior

Scan files and report missing / unused localization

Actual Behavior

$ vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'
'vue)'' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Having the same problem. An Attempt to replace the single quotes with escaped double quotes did also not work

Having the same problem. An Attempt to replace the single quotes with escaped double quotes did also not work

Yes, that is the trick:
"vue-cli-service i18n:report --src \"./src/**/*.?(js|vue)\" --locales \"./src/locales/**/*.json\""

Having the same problem. An Attempt to replace the single quotes with escaped double quotes did also not work

Yes, that is the trick:
"vue-cli-service i18n:report --src \"./src/**/*.?(js|vue)\" --locales \"./src/locales/**/*.json\""

Only works for me when running from the console (cmd, Powershell, GIT Bash) but not when running from Vue UI web interface. There I get the following error:

$ vue-cli-service i18n:report --src ./src/**/*.?(js|vue)" --locales "./src/locales/**/*.json 'vue)" --locales ".' is not recognized as an internal or external command, operable program or batch file.

But the command in the "command bar" looks fine. See below:
image

Only works for me when running from the console (cmd, Powershell, GIT Bash) but not when running from Vue UI web interface.

I have written a small .js wrapping the command.

i18n.js

/* eslint-disable @typescript-eslint/no-var-requires */
const { exec } = require("child_process");
const cmd =
    'npx vue-cli-service i18n:report --src "./src/**/*.?(vue)" --locales "./src/locales/**/*.json"';
exec(cmd, (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`${stdout}`);
});

And on package.json

"scripts": {
     
    "i18n:report": "node i18n.js"
  },

I solved this issue on Windows 10 as follows:

  1. Replace the single quotes by escaped double quotes.
  2. Replace *.?(js|vue) by *.{js,vue} (i.e. curly-braces without leading question-mark).
# package.json
-    "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'"
+    "i18n:report": "vue-cli-service i18n:report --src \"./src/**/*.{js,vue}\" --locales \"./src/locales/**/*.json\""

PS: It looks like (1) is sufficient, see this comment in #49.