Browse Source

Fix a bug with error.message not exposed to t()

master
Gaëtan Renaudeau 7 years ago
parent
commit
70b7604b6c
  1. 6
      src/components/TranslatedError.js

6
src/components/TranslatedError.js

@ -30,14 +30,16 @@ class TranslatedError extends PureComponent<Props> {
} }
return null return null
} }
// $FlowFixMe
const arg: Object = Object.assign({ message: error.message }, error)
if (error.name) { if (error.name) {
const translation = t(`errors:${error.name}.${field}`, error) const translation = t(`errors:${error.name}.${field}`, arg)
if (translation !== `${error.name}.${field}`) { if (translation !== `${error.name}.${field}`) {
// It is translated // It is translated
return translation return translation
} }
} }
return t(`errors:generic.${field}`, error) return t(`errors:generic.${field}`, arg)
} }
} }

Loading…
Cancel
Save