Skip to content

Commit

Permalink
Add Vue parsing to CLI & refactor extract function
Browse files Browse the repository at this point in the history
In order to parse for phrases the Vue SFC we needed to create a new
extract function. This means that cli will also be parsing all the
`*.vue` files that will find.

`vue-template-compiler` was used to do this so we can extract the
different types of content from the Vue template `script` and
`template`.

For the `template` part we use `compile` to get the AST and we traverse
with a custom function and for the `script` we just send to babel.

During this implementation it seemed that a lot of code could be
extracted from `extract.js` and so a new `parsers` folder was created
with `angularHTML`, `vue` and `babel` files with all the functionality
that can be reused accross parsers if needed.
  • Loading branch information
codegaze committed Jan 11, 2022
1 parent 51333f0 commit aa4ec0c
Show file tree
Hide file tree
Showing 12 changed files with 778 additions and 474 deletions.
4 changes: 2 additions & 2 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ USAGE
$ txjs-cli push [PATTERN]
ARGUMENTS
PATTERN [default: **/*.{js,jsx,ts,tsx}] file pattern to scan for strings
PATTERN [default: **/*.{js,jsx,ts,tsx,vue}] file pattern to scan for strings
OPTIONS
-v, --verbose verbose output
Expand All @@ -98,7 +98,7 @@ OPTIONS
--without-tags-only=without-tags-only push strings without specific tags
DESCRIPTION
Parse .js, .ts, .jsx, .tsx and .html files and detect phrases marked for
Parse .js, .ts, .jsx, .tsx, .html and .vue files and detect phrases marked for
translation by Transifex Native toolkit for Javascript and
upload them to Transifex for translation.
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"colors": "^1.4.0",
"glob": "^7.1.6",
"lodash": "^4.17.21",
"shelljs": "^0.8.4"
"shelljs": "^0.8.4",
"vue-template-compiler": "^2.6.14"
},
"devDependencies": {
"@oclif/dev-cli": "^1.26.0",
Expand Down
Loading

0 comments on commit aa4ec0c

Please sign in to comment.