Browse Source

Merge pull request #1067 from gre/fix-error

Fix a bug with error.message not exposed to t()
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
c0d5422f9c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/components/TranslatedError.js

6
src/components/TranslatedError.js

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

Loading…
Cancel
Save