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

add context prop to <Trans> Component #1464

Closed
zanona opened this issue Mar 8, 2022 · 5 comments
Closed

add context prop to <Trans> Component #1464

zanona opened this issue Mar 8, 2022 · 5 comments
Labels

Comments

@zanona
Copy link

zanona commented Mar 8, 2022

🚀 Feature Proposal

Add context prop to the Trans component. Previously mentioned over #837

Motivation

Just like we have <Trans count={n}>, we could also have the context prop to pass the option rather than having to define it under tOptions, which is less readable.

Example

//auth.title_login: 'Some nice <i>Title</i>'
<Trans context='login'>auth.title</Trans>
// instead of
<Trans tOptions={{context:'login'}}>auth.title</Trans>
@adrai
Copy link
Member

adrai commented Mar 8, 2022

Would you like to send a Pull Request to address this? Remember to add unit tests.

@stale
Copy link

stale bot commented Mar 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 17, 2022
@adrai
Copy link
Member

adrai commented Mar 17, 2022

Too bad you didn't get in touch... I quickly did it myself. I hope this is ok.
v11.16.0 has just been released.

@adrai adrai closed this as completed Mar 17, 2022
@zanona
Copy link
Author

zanona commented Mar 17, 2022

Wow, thanks a lot and sorry for not getting back to you. When thinking on the implementation, I've noticed that there could be a few problems with Typescript validation as the context would need to be tied to the custom type, but I believe in that case, it would need to be set to any as there's not much we can do there.

Thanks again for implementing this so quickly.

@adrai
Copy link
Member

adrai commented Mar 17, 2022

Sorry, missed to update the types: v11.16.1 should be better

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

No branches or pull requests

2 participants