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

fix(types): <Trans>can have an i18n props #1308

Merged
merged 1 commit into from
Dec 8, 2022
Merged

Conversation

renchap
Copy link
Contributor

@renchap renchap commented Dec 5, 2022

Sometimes you need to force the i18n instance used by <Trans>. In my case, it is to have a server-side render of a React PDF document, where I do not have a global i18n instance but several global ones (one per language).

The macro seems to properly handle this, and this patch works fine locally with our app.

For example:

component Test = () => {
    const i = useLingui()

  return <Text><Trans i18n={i.i18n}>Test String</Trans></Text>
}

Sometimes you need to force the `i18n` instance used by `<Trans>`. In my case, it is to have a server-side render of a React PDF document, where I do not have a global `i18n` instance but several global ones (one per language).

The macro seems to properly handle this, and this patch works fine locally with our app.

For example:

```
component Test = () => {
    const i = useLingui()

  return <Text><Trans i18n={i.i18n}>Test String</Trans></Text>
}
```
@vercel
Copy link

vercel bot commented Dec 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
js-lingui ❌ Failed (Inspect) Dec 5, 2022 at 9:38PM (UTC)

@codecov
Copy link

codecov bot commented Dec 5, 2022

Codecov Report

Base: 82.52% // Head: 82.52% // No change to project coverage 👍

Coverage data is based on head (d8b5fa9) compared to base (7c85cb7).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1308   +/-   ##
=======================================
  Coverage   82.52%   82.52%           
=======================================
  Files          56       56           
  Lines        1785     1785           
  Branches      500      500           
=======================================
  Hits         1473     1473           
  Misses        184      184           
  Partials      128      128           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@semoal semoal merged commit de01f8d into lingui:main Dec 8, 2022
@andrii-bodnar andrii-bodnar linked an issue Dec 29, 2022 that may be closed by this pull request
@renchap renchap deleted the patch-1 branch January 26, 2023 14:27
@vonovak vonovak mentioned this pull request Apr 26, 2023
7 tasks
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.

Provide custom I18n for macros.
2 participants