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

React Overlays do not work as documented #538

Open
sandalwoodbox opened this issue Apr 4, 2021 · 3 comments
Open

React Overlays do not work as documented #538

sandalwoodbox opened this issue Apr 4, 2021 · 3 comments

Comments

@sandalwoodbox
Copy link

sandalwoodbox commented Apr 4, 2021

According to https://github.com/projectfluent/fluent.js/wiki/React-Overlays, I should be able to do the following:

<Localized
    id="create-account"
    elems={{
        confirm: <button onClick={() => {console.log('hi')}}></button>,
        cancel: <a href="/"></a>
    }}
>
    <p>{'<confirm>Create account</confirm> or <cancel>go back</cancel>.'}</p>
</Localized>

And have it be rendered as:

<p>
    <button onClick={createAccount}>Create account</button> or <Link to="/">go back</Link>.
</p>

However, instead, it is rendered as:

<p>&lt;confirm&gt;Create account&lt;/confirm&gt; or &lt;cancel&gt;go back&lt;/cancel&gt;.</p>

Version: @fluent/react 0.13.0

@sandalwoodbox
Copy link
Author

It seems like possibly the issue here was that the overlays only actually kick in when you render a translation (vs. the default translated string). This still seems like a bug since it's not what I'd expect the behavior for rendering the default translation to be - but it shouldn't be impactful as long as a translated text exists.

@pitops
Copy link

pitops commented May 24, 2021

@sandalwoodbox have you figured out how to make it work with default locale?

@sandalwoodbox
Copy link
Author

sandalwoodbox commented May 26, 2021

@pitops In my experience it worked fine with the default locale as long as the default locale had a translation. But if fluent had to fall back to rendering the inline content, it would no longer do variable substitution. If you're having trouble with the default locale that sounds like a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants