-
Notifications
You must be signed in to change notification settings - Fork 13
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 'polyglotScope' prop to translated component. #36
Comments
guillaumearm
changed the title
add defaultPolyglotScope and add polyglotScope to translated component.
add 'polyglotScope' prop to translated component.
Oct 11, 2016
What is the use case for this ? |
hmm, i will write an example for this soon. |
I think it's more dynamic using react props, here an example. import React from 'react';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { translate } from 'redux-polyglot/translate';
// soon : import translate from 'react-redux-polyglot';
import { getCurrentBiz } from '../selectors';
const DummyTitle = ({ p }) => <p>{ p.tc('title') }</p>
const connectTranslated = compose(
connect(state => ({ polyglotScope: `catalog.${getCurrentBiz(state)}` }))
translate(), // according to #48
);
const TranslatedDummyTitle = connectTranslated(DummyTitle);
// with this phrases loaded :
const phrases = {
catalog: {
hotel: {
title: 'Hotel lists'
},
fly: {
title: 'Fly lists'
}
}
};
// then, just simply render TranslatedDummyTitle without any props. |
I'm not convinced about the reality of use case in real life ... but why not |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
need #35.
can set a polyglotScope with a prop:
The text was updated successfully, but these errors were encountered: