Spittal / vue-i18n-extract

Manage vue-i18n localization with static analysis
https://pixari.github.io/vue-i18n-extract/#what-is-it
MIT License
313 stars 86 forks source link

Provide documentation on how to use as ES6 module #217

Open jplaverdure opened 8 months ago

jplaverdure commented 8 months ago

Hello,

I'm a bit of a newbie to the JS ecosystem and understand there are 2 module loading schemes (commonJS and ES6) It would be nice to have a bit more documentation on how to use this tool in the context of an ES6 project.

It seems everything I attempt results in:

[vue-i18n-extract] SyntaxError: Cannot use import statement outside a module
    at /u/jpl/Documents/binfo/qarome/node_modules/vue-i18n-extract/dist/vue-i18n-extract.umd.js:166:53
    at Array.map (<anonymous>)
    at readLanguageFiles (/u/jpl/Documents/binfo/qarome/node_modules/vue-i18n-extract/dist/vue-i18n-extract.umd.js:153:26)
    at Object.createI18NReport (/u/jpl/Documents/binfo/qarome/node_modules/vue-i18n-extract/dist/vue-i18n-extract.umd.js:291:29)
    at Object.<anonymous> (/u/jpl/Documents/binfo/qarome/test_extract.js:3:31)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

I see the presence of a vue-i18n-extract.modern.mjs file in the dist folder but how do I make use of it ? Surely I'm not the only one trying to figure out how to make this work..

All help is welcome !

jplaverdure commented 8 months ago

Forgot to mention, but I'm trying to use this on a Quasar project.. Maybe that explains the issues I'm running into ?

mreduar commented 6 months ago

@jplaverdure do you resolve this issue?

jplaverdure commented 6 months ago

I unfortunately resolved it by using the vue-gettext plugin which worked perfectly in my case.

mreduar commented 6 months ago

I solved it with this comment.