Skip to content

Support extracting tags from Svelte files#94

Merged
AlexMost merged 4 commits intottag-org:masterfrom
MrOrz:svelte-support
Mar 24, 2020
Merged

Support extracting tags from Svelte files#94
AlexMost merged 4 commits intottag-org:masterfrom
MrOrz:svelte-support

Conversation

@MrOrz
Copy link
Copy Markdown
Contributor

@MrOrz MrOrz commented Mar 23, 2020

Inspired by Vue integration, I added tag extraction support for svelte files in this PR, which is the component file used in Svelte.

In order to support extraction of t in template, I included svelte as dependency in order to leverage it's exposed built-in parser. However, it seems that the type definition in svelte lacks some dependency, which will trigger Typescript errors. I am new to Typescript and not very sure how we should handle this.

Also, estree-walker is included to walk through the AST -- which can be replaced by any other ESTree traversal tool.

Please let me know if there is any concern regarding this PR. Thanks!

@MrOrz
Copy link
Copy Markdown
Contributor Author

MrOrz commented Mar 24, 2020

One caveat:

Actually strings with variables like <h1>{tHello ${translated} !}</h1> cannot be translated. When babel-loader (with ttag-plugin) takes over, svelte-loader would mangle the variables.

螢幕快照 2020-03-24 下午1 08 38

@AlexMost
Copy link
Copy Markdown
Member

AlexMost commented Mar 24, 2020

Thanks, that looks awesome! Unfortunately, still, I have no experience with Svelte, it would be great if you could provide some example or doc how we can use ttag and svelte! Anyway, thanks for the great job, will try to fix ts errors and release ASAP.

@AlexMost AlexMost merged commit 5960dd4 into ttag-org:master Mar 24, 2020
eavae pushed a commit to eavae/ttag-cli that referenced this pull request Mar 25, 2020
* Add @types/walk to make unit test happy

* Svelte file support

* Add svelte AST interfaces to make tsc happy

* Remove redundant test.only
@MrOrz MrOrz deleted the svelte-support branch April 5, 2020 19:08
@ljani ljani mentioned this pull request Dec 27, 2022
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

Successfully merging this pull request may close these issues.

2 participants