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

Come up with a way to do Component Interpolation #72

Open
LorisSigrist opened this issue Apr 11, 2024 — with Linear · 0 comments
Open

Come up with a way to do Component Interpolation #72

LorisSigrist opened this issue Apr 11, 2024 — with Linear · 0 comments
Assignees

Comments

Copy link
Member

LorisSigrist commented Apr 11, 2024

Context

It's currently unclear how component interpolation could be implemented in Paraglide. Interpolating components would almost certainly require a framework-specific runtime/renderer. However, if we just have message functions, how can such a renderer insert a component?

This could force us to switch to the AST approach, where instead of a message function, the message is compiled to an AST that a small runtime utility then renders.

const my_message = ["Please accept the ", ["component": "Terms and conditions"], "before continuing"]
m(my_message)

This would require major API changes so I would really appreciate alternative suggestions

Alternative Idea:

Another clever suggestion comes from this discussion:
https://github.com/orgs/opral/discussions/913#discussioncomment-9126828

It suggests having the messages return an array that can be used as a JSX value directly.

const my_message ({ link }) = ["Click on the" , link]

<h1> 
  {{ my_message({link: <a>test</a> }) }}
</h1>

Unfortunately this also has drawbacks :

  • Requires a runtime formatting function
  • JSX only

Proposal

??? - Not sure yet, might be a paraglide 2.0 feature

@LorisSigrist LorisSigrist self-assigned this Apr 11, 2024
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

1 participant