Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add babel and/or babel plugin support #4

Open
OmgImAlexis opened this issue May 11, 2017 · 5 comments
Open

Add babel and/or babel plugin support #4

OmgImAlexis opened this issue May 11, 2017 · 5 comments

Comments

@OmgImAlexis
Copy link

I'm wanting to use this with vuejs which requires babel to convert the .vue file to .js.
Currently if I run this I just end up with errors.

➜  vue git:(feature/add-default-vue-route) ✗ yarn stonejs extract --functions="$t" "src/**/*.vue" locales/catalog.pot
yarn stonejs v0.23.4
$ "/Users/xo/code/Medusa/vue/node_modules/.bin/stonejs" extract  src/**/*.vue locales/catalog.pot
  * Extracting strings from 'src/components/app.vue'
WARN: SyntaxError: Unexpected token <
WARN: File skipped due to syntax errors
  * Extracting strings from 'src/components/home.vue'
WARN: SyntaxError: Unexpected token <
WARN: File skipped due to syntax errors
  * Extracting strings from 'src/components/loader.vue'
WARN: SyntaxError: Unexpected token <
WARN: File skipped due to syntax errors
  * Extracting strings from 'src/components/not-found.vue'
WARN: SyntaxError: Unexpected token <
WARN: File skipped due to syntax errors

0 string(s) extracted, 4 file(s) skipped.
OK: Translation template written: locales/catalog.pot
✨  Done in 0.91s.
@flozz
Copy link
Owner

flozz commented May 11, 2017

Hello,

I have to rewrite this tool, so I will think about this when I will do it.

Anyway, to make it work now, you can give the transpilled version of your js to stone tools to allow it to extract translatable strings. :)

@OmgImAlexis
Copy link
Author

Unless it reads source maps it won't give me the line number though. 😞

@OmgImAlexis
Copy link
Author

Doesn't work after compiling either.

$ stonejs extract --functions='$t' 'dist/build.js' locales/catalog.pot 
  * Extracting strings from 'dist/build.js'
WARN: SyntaxError: Unexpected token babel
WARN: File skipped due to syntax errors

0 string(s) extracted, 1 file(s) skipped.
OK: Translation template written: locales/catalog.pot
✨  Done in 0.59s.

@flozz
Copy link
Owner

flozz commented May 11, 2017

it is strange, it should work with the transpiled js... I will check if the parser is up to date by the end of the week.

@OmgImAlexis
Copy link
Author

Apparently I broke it somehow but it's "working" now. It really needs to be using source maps though as those lines don't match my source files.

➜  vue git:(feature/add-default-vue-route) yarn stonejs extract --functions='$t' 'dist/build.js' locales/catalog.pot 
yarn stonejs v0.23.4
$ "/Users/xo/code/Medusa/vue/node_modules/.bin/stonejs" extract dist/build.js locales/catalog.pot
  * Extracting strings from 'dist/build.js'

1 string(s) extracted.
OK: Translation template written: locales/catalog.pot
✨  Done in 1.59s.
➜  vue git:(feature/add-default-vue-route) cat locales/catalog.pot 
#: dist/build.js:1
#: dist/build.js:1
#: dist/build.js:1
#: dist/build.js:3
#: dist/build.js:4
#: dist/build.js:6
#: dist/build.js:6
#: dist/build.js:6
#: dist/build.js:6
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2017-05-11 20:55:08+0930\n"
"PO-Revision-Date: 2017-05-11 20:55:08+0930\n"
"Language: C\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"% 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants