-
Notifications
You must be signed in to change notification settings - Fork 387
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
feat: add full support of Vue.js #1925
base: next
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
ed0de3e
to
a0b37e8
Compare
a0b37e8
to
dcb5245
Compare
add Vue.js support with components, plugins, extractor and compiler
dcb5245
to
078e564
Compare
Cool, thanks. I actually don't know what steps should we take to proceed it further.
Could you also describe what exactly left to do? Upd: I think it worth it to copy the readme from your original repo into this PR description |
We should probably hide I also thought a lot about how to organize the documentation. At least we need to create a new page in the API Reference section. In addition, it would be good to have a separate page in the Tutorials section describing the full path of using the new package in a Vue application. I don't think we need a separate installation article, just include this step in the tutorial (maybe the Installation section will disappear in the future). I see the Tutorials section as a dedicated place to describe Lingui usage with various frameworks (React, Vue, Next.js, React Native, Svelte, etc.) and think about moving the React common patterns and Explicit vs Generated IDs articles to the Guides section. |
I would advice to deprecate |
My fifty cents: We can publish it as beta for a while with a description what exactly the drawbacks. The most important things to be done:
I'm thinking about how we can reuse existing macro code for vue version. |
@JSteunou how can we proceed with this PR? |
Sorry guys, not available ATM, but I will take a moment on this next week. Priority on docs, then snapshots. I think it is better to publish early, feature freeze, and add support for Plural and all other goodies later. |
@JSteunou how do you use plurals in Vue right now? It seems the only way is manually wright ICU expressions and pass arguments. Also "Compile time transpiling for vt" is not only about dedoubling messages in the bundle, but also about feature parity. The |
Nope, the actual way is to use
I try to make
|
i think integrating deeply core
I believe the vue compiler expose analyzed binding which is passed from setup script to the template, so you can use them to fin instances of |
As to be tested, but SFC compiler is so much not documented, it is a pain to find what it does and what can be done safely. :( If it is possible to go this way, |
some function were extracted to macroJsAst. The all tests was concerned.
i've pushed lingui vue-plugin which is registering all bits together in one plugin. I don't have time for proper testing of it. @JSteunou if you can pick up it from here would be awesome. |
f595647
to
f0b1689
Compare
@thekip I'm trying to merge
weird because |
8ef8047
to
f0b1689
Compare
@JSteunou I will help with conflicts here. Could you take it over and finish this feature? I would be available in discord for a help. |
add Vue.js support with components, plugins, extractor and compiler
Description
Title is kinda catchy because in reality there is still a lot to do, but this PR brings at least a full Vue.js experience that just works
Types of changes
Fixes # (issue)
Checklist
To this checklist I will add
For more context this is the README of my original repo https://github.com/JSteunou/vue-lingui
Why?
#1730
How to use lingui in vue SFC?
in the setup part
You can use any of the current @lingui/macro helper it will just work as long as you follow the vite configuration instruction below.
Of course vanilla JS with @lingui/core also works fine
in the template part
You will have to use either
<Trans>
orvt
from lingui-vue. Both mimic the actuel lingui macros<Trans>
andt
but with limited functionnalities. (see What still need to be done?)How to configure your vuejs / vite project?
lingui config
This is mostly as the doc says except you have to use this new extractor.
vite config
This is what a really basic config will look like:
transformer
will do some magic inside your template sectionslingui
plugin is nothing more than the vite plugin / loader for catalogsbabelMacros
plugin will make lingui macros work with viteHow it works?
See #1730 (comment)
Or to wrap things up with some detailed examples
In extraction phase
<Trans>
will be find in the SFC AST by the vue extractor for lingui and will be transformed to a thing that the lingui default extractor already knows and will handle.vt
will be find in the SFC AST the same way and also transformed.In build & runtime phase
Again
<Trans>
will be find in the SFC AST but this time by the vite / vue transformer and will be transformed to a more complexe form that just works and allows to use variables and inner tags / components without worring about this complex syntax.vt
will not be transformed and will be used as is in runtime. This is possible only thanks to the recent feature that lingui introduced in 4.60 about ids hence the strong requirement.What still need to be done?
but will be done later... (any contributions are welcome)
<Trans>
vt
vt
in component child interpolationvt
in Trans inner tag attributes