Closed Heziode closed 11 months ago
Hi, the filter should not be necessary - that's why there is the "translations/*.po" argument.
I can't see right away why .../Library/pnpm/global/5/node_modules/vuei18n-po/cli.js would match "translations/*.po".
When invoking vuei18n-po --messagesDir=lang "translations/*.po"
, what is your current directory and where are the translations/*.po located?
I can't see right away why .../Library/pnpm/global/5/node_modules/vuei18n-po/cli.js would match "translations/*.po".
In fact it does not mach the pattern, but it seems to be passed as arguments or something like that using node via PNPM.
what is your current directory and where are the translations/*.po located?
The current directory is my project dir, and *.po files are all located in translations
, like translations/en.po
, etc.
it's possible that pnpm passes the arguments slightly differently. in my case, in cli.js:3, process.argv is
[
".../bin/node",
".../vuei18n-po/cli.js",
"--messagesDir=lang",
"translations/*.po",
]
the parsed argv
{
_: [
'/usr/local/bin/node',
'/Users/pavelstudeny/src/avast/vuei18n-po/cli.js',
'translations/*.po'
],
messagesDir: 'lang'
}
and then, at cli.js:65, the processed argv would look like
{ messagesDir: 'lang', po: [ 'translations/*.po' ] }
How is it for you?
Looks like you have been able to resolve this on your side, @Heziode ?
Sorry for the delay @pavelstudeny.
I modified the begining of cli.js
:
#!/usr/bin/env node
let argv = require('minimist')(process.argv);
const chokidar = require('chokidar');
console.log("argv: ", argv);
// rest of the code
And here is my result:
argv: {
_: [
'/Users/heziode/Library/pnpm/nodejs/12.22.12/bin/node',
'/Users/heziode/Library/pnpm/global/5/node_modules/vuei18n-po/cli.js',
'translations/ar.po',
'translations/cs.po',
'translations/da.po',
'translations/de.po',
'translations/el.po',
'translations/en.po',
'translations/es.po',
'translations/fi.po',
'translations/fr.po',
'translations/hu.po',
'translations/it.po',
'translations/nl.po',
'translations/no.po',
'translations/pl.po',
'translations/pt-BR.po',
'translations/pt.po',
'translations/ro.po',
'translations/ru.po',
'translations/sk.po',
'translations/sv.po',
'translations/th.po',
'translations/tr.po'
],
messagesDir: 'lang'
}
And line 65 of cli.js I got this:
argv: {
messagesDir: 'lang',
po: [
'/Users/heziode/Library/pnpm/nodejs/12.22.12/bin/node',
'/Users/heziode/Library/pnpm/global/5/node_modules/vuei18n-po/cli.js',
'translations/ar.po',
'translations/cs.po',
'translations/da.po',
'translations/de.po',
'translations/el.po',
'translations/en.po',
'translations/es.po',
'translations/fi.po',
'translations/fr.po',
'translations/hu.po',
'translations/it.po',
'translations/nl.po',
'translations/no.po',
'translations/pl.po',
'translations/pt-BR.po',
'translations/pt.po',
'translations/ro.po',
'translations/ru.po',
'translations/sk.po',
'translations/sv.po',
'translations/th.po',
'translations/tr.po'
]
}
So, to sumup, this result is obtained with the following environment:
My current workaround, it to add a filter for .po
files (as describe in the first message).
But maybe it is more relevant to add this filter in cli.js
inside argv._
processing (line 5-17).
With something like:
if (argv._) {
console.log("__filename: ", __filename);
let myself = argv._.indexOf(__filename);
if (myself == -1) {
myself = argv._.findIndex(a => a.indexOf('.bin/vuei18n-po') != -1);
}
if (myself != -1 && myself + 1 < argv._.length) {
argv.po = argv._.slice(myself + 1);
}
else if (myself == -1 && argv._.length > 0) {
argv.po = argv._.slice();
}
+ argv.po = argv.po.filter(fname => fname.endsWith(".po"));
}
Since this is specific to pnpm and there is an easy workaround, I'm closing this issue. If there were more reports or the workaround was causing undesired behavior, I will reopen and address this.
I got the following error using this command:
As we can see, the first file parsed is
/Users/heziode/Library/pnpm/global/5/node_modules/vuei18n-po/cli.js
, and I don't know why…I think the following line should add a filter for PO files:
https://github.com/avast/vuei18n-po/blob/3dc265e5a8448290f52216396bf3544521616ffa/index.js#L117