-
Notifications
You must be signed in to change notification settings - Fork 31
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
Return translation as string #26
Comments
As a workaround I am now using counterpart directly to achieve this, but I still think that |
It would be also important to have that function for the placeholder/value parameter in input fields. |
Hi
The next version will have that functionality. Stay tuned.
You can already translate HTML element attribute values by using the <Translate
component="input"
type="text"
attributes={{ placeholder: 'the.key', title: 'other.key' }}
/> |
What about React props like |
Every prop that is not consumed by <Translate
component={MyCustomComponent}
content="translation.key"
className="foo"
onClick={myClickHandler}
/> |
Ok, great. One more question for the input. |
nvm I just needed findDOMNode |
When using a class MyTranslatedInput extends React.Component {
constructor(props) {
super(props);
this.focus = this.focus.bind(this);
}
focus() {
this.inputNode.focus();
}
render() {
return (
<Translate
component={MyCustomInput}
content="translation.key"
ref={(node) => { this.inputNode = node; }}
onClick={this.focus}
/>
);
}
} |
That's what I was doing already. But forgot to add Been trying multiple translate component, and this one is the best so far. |
Bump.
The trouble is, the counterpart.translate method won't update when the locale changes, unlike Translate components, so the axis labels etc. don't change even as the rest of the text on the page (including on buttons, menus etc.) changes. |
Actually some code the owner showed on 18 July 2014 of this issue solves the problem. You have to use counterpart and an event listener for locale changes. |
Hi,
I wanna use this package in combination with https://github.com/nfl/react-helmet to dynamically set localized page titles. The
<Helmet />
component only accepts strings... What do you think of exposing a utility function which returns just a stringgetTranslationAsString
? I could imagine that this might useful also for other uses cases.I can provide a pr, if you think this makes sense.
The text was updated successfully, but these errors were encountered: