feat: solidjs integration#2510
Conversation
|
@Huliiiiii is attempting to deploy a commit to the Crowdin Team on Vercel. A member of the Team first needs to authorize it. |
|
@Huliiiiii please add description for the PR, with details:
That will make reviewing and merging the PR easier and faster. Thanks! |
| ["@lingui/react", "@lingui/solid"].some((moduleName) => | ||
| path | ||
| .get("openingElement") | ||
| .get("name") | ||
| .referencesImport(moduleName, "Trans"), | ||
| ) |
There was a problem hiding this comment.
Todo for myself: check if we can drop it entirely or make configurable. Don't want to have list of packages hardcoded
There was a problem hiding this comment.
@Huliiiiii i think we can use macro.runtimeConfigModule.Trans option here and avoid hardcode, could you make it change and at a simple test testing that this property is respected? Thanks!
| components: { | ||
| 0: (props) => <a href="/docs" {...props} />, | ||
| }, |
There was a problem hiding this comment.
could you elaborate a bit onwhy this needed for Solid?
I wonder could we avoid branching and generate for both react and solid the same way? From the first glance it seems react would also work with no issues with this syntax
There was a problem hiding this comment.
React uses VDOM, but Solid eagerly creates real DOM nodes. So preserve laziness manually is needed. Otherwise, for a component like this, there’s no correct way to insert children at the right position (using the approach in #2101).
const Comp = (props) => <div><div>before</div>{props.children}<div>after</div></div>
Maybe there’s a better solution, but I can’t think of one at the moment.
43c18b7 to
4d5b385
Compare
|
I’ve updated the description. |
Could you elaborate on this? What this mean for a user? Could you write few examples what would work - what is not with possible workaround |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
I've added some examples to the description. Would that be enough? |
What happened with the following message? <Trans>Hello <strong>user</strong> from planet <strong>Earth</strong>Current macro will dedupe {
0: <strong>
}
UPD: I reread your description one more time, and it seems i didn't get it correctly. Correct me if'm wrong - this issue you described
You already solved with |
Deduplication should works correctly if the current tests already cover that. The core difference is that solid can only use references, but react uses clones/copies. |
|
Tests failed because |
|
@Huliiiiii thank you for the contribution! Improving Lingui's compatibility with SolidJS and the broader ecosystem (Astro, Vue, Svelte) is a major focus for the community at the moment. With v6 nearly finalized, our plan is to ship the current milestone first and then introduce dedicated SolidJS support in a subsequent release. In addition to the feature itself, it would be great to have a dedicated example project featuring the integration, a documentation page (similarly to the existing React Apps Internationalization) and a blog post (optionally). Please let us know your thoughts! |
|
@Huliiiiii we reached v6 milestone. We still interersted in this integration. Could you update the branch to the latest main? (please note, the main branch is renamed from what was Thanks! |
|
@Huliiiiii i'm going to jump in and help with this PR, so please don't rebase/force push. Thanks! |
| ["@lingui/react", "@lingui/solid"].some((moduleName) => | ||
| path | ||
| .get("openingElement") | ||
| .get("name") | ||
| .referencesImport(moduleName, "Trans"), | ||
| ) |
There was a problem hiding this comment.
@Huliiiiii i think we can use macro.runtimeConfigModule.Trans option here and avoid hardcode, could you make it change and at a simple test testing that this property is respected? Thanks!
|
@Huliiiiii could you please not force push in this branch. We don't care about the history in the feature bunches since they would be squahed and merged any way. I'm going to push to your branch to help with CI issues. |
# Conflicts: # yarn.lock
|
Sorry, I accidentally force-pushed again. |
|
I’m unable to reproduce the timeout issue locally. Maybe it’s an issue with the action runner? |
Description
@lingui/solidbased on the@lingui/reactdesignjsxRuntimeoption in@lingui/confbabel-plugin-lingui-macroDifferences from React
Components are compiled into:
instead of:
Reusing the same node multiple times in a translation string (for example, "<0/> <0/>") is not supported.
For example, this source code:
produces a message like:
Read the <0>docs</0>.A translation such as this is not supported:
Read the <0>docs</0> or the <0>guide</0>.It will render as
Read the or the <a href="/docs">guide</a>.This is because HTML elements cannot be cloned trivially. In this implementation, the same element is reused by reference instead of copies.
The same limitation also applies when a JSX element stored in a variable is referenced multiple times.
For example:
The output will be similar to:
or <a href="/docs">docs</a>Using a component instead avoids this problem:
Types of changes
Closes #2425
Checklist