Translating Uniforms (with simpl-schema) using React intl

I’m leaving this here, because I couldn’t find any description on how to translate my form labels. More specifically using react-intl.

I’ve put this in my render function or if you use react-redux-meteor-data you can put it in your tracker function.

// render() {
// schema === SimpleSchema instance
if(this.props.translationPrefix) {
  schema._schema = _.mapValues(schema._schema, (props, key) => {
    return {
      ...props,
      label: this.props.intl.formatMessage({id: `${this.props.translationPrefix}schema.${key}`})
    };
  });
}
return (
    <AutoForm schema={schema} placeholder />
);

...

Also don’t forget to put injectIntl on your component

2 Likes