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

Inject components into translation #222

Closed
pgom opened this issue Jan 12, 2017 · 3 comments
Closed

Inject components into translation #222

pgom opened this issue Jan 12, 2017 · 3 comments

Comments

@pgom
Copy link

pgom commented Jan 12, 2017

I'm wondering if I'm are the only one with this kind of needs.
On the current application I'm working on, it might be useful if we could use a component as value. For example:

render() {
 return I18n.t('key', { value: <Link onclick={() => } />}
}

In this example, Link returns a link with predefined set of props that we use everywhere.
@jamuhl , does something like this makes sense to add? If so, how would you suggest to do it?

@jamuhl
Copy link
Member

jamuhl commented Jan 12, 2017

No idea how to do so...i18n.t calls the function of i18next which itself returns always a string and also only interpolates strings.

For this case we created an extra interpolation component doing what you want: https://github.com/i18next/react-i18next#interpolate-component

@pgom
Copy link
Author

pgom commented Jan 12, 2017

Yes, I'm doing just that. My intention was to keep the components "clean" and just invoke translation without creating another component. But still, this is pure gold...nice work.

@jamuhl
Copy link
Member

jamuhl commented Jan 12, 2017

if you find a simpler solution i'm more then open to it...just got no idea how to make that possible.

@jamuhl jamuhl closed this as completed Feb 13, 2017
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

2 participants