Browse Source

Merge pull request #748 from gre/error-subfields

errors.yml now have sub field ('title' by default)
master
NastiaS 7 years ago
committed by GitHub
parent
commit
19103ca8ca
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/components/ManagerPage/AppsList.js
  2. 15
      src/components/TranslatedError.js
  3. 129
      static/i18n/en/errors.yml

12
src/components/ManagerPage/AppsList.js

@ -205,7 +205,17 @@ class AppsList extends PureComponent<Props, State> {
textAlign="center" textAlign="center"
style={{ maxWidth: 350 }} style={{ maxWidth: 350 }}
> >
<TranslatedError error={error} /> <TranslatedError error={error} field="title" />
</Box>
<Box
color="graphite"
mt={4}
fontSize={6}
ff="Open Sans"
textAlign="center"
style={{ maxWidth: 350 }}
>
<TranslatedError error={error} field="description" />
</Box> </Box>
</ModalContent> </ModalContent>
<ModalFooter horizontal justifyContent="flex-end" style={{ width: '100%' }}> <ModalFooter horizontal justifyContent="flex-end" style={{ width: '100%' }}>

15
src/components/TranslatedError.js

@ -12,21 +12,24 @@ import type { T } from 'types/common'
type Props = { type Props = {
error: ?Error, error: ?Error,
t: T, t: T,
field: 'title' | 'description',
} }
class TranslatedError extends PureComponent<Props> { class TranslatedError extends PureComponent<Props> {
static defaultProps = {
field: 'title',
}
render() { render() {
const { t, error } = this.props const { t, error, field } = this.props
if (!error) return null if (!error) return null
if (typeof error === 'string') return error if (typeof error === 'string') return error
if (error.name) { if (error.name) {
const translation = t(`errors:${error.name}`, error) const translation = t(`errors:${error.name}.${field}`, error)
if (translation) { // FIXME in case the error don't exist in t we should not return and fallback code after. I just don't know how to check this. FIXME
return translation return translation
}
} }
logger.warn(`TranslatedError: no translation for '${error.name}'`, error) logger.warn(`TranslatedError: no translation for '${error.name}'`, error)
return error.message || error.name || t('errors:generic') return error.message || error.name || t(`errors:generic.${field}`)
} }
} }

129
static/i18n/en/errors.yml

@ -1,32 +1,97 @@
BtcUnmatchedApp: 'Open the ‘{{currencyName}}’ app on your Ledger device to proceed.' # the error codes are alphabetically sorted
DeviceNotGenuine: Device is not genuine BtcUnmatchedApp:
DeviceSocketFail: Oops, device connection failed. Please try again. [device-fail] title: 'Open the ‘{{currencyName}}’ app on your Ledger device to proceed.'
DeviceSocketNoBulkStatus: Oops, device connection failed. Please try again [bulk]. description: ''
DeviceSocketNoHandler: Oops, device connection failed (handler {{query}}). Please try again. DeviceNotGenuine:
DisconnectedDevice: 'The device was disconnected.' title: Device is not genuine
Error: '{{message}}' description: ''
FeeEstimationFailed: 'Fee estimation error. Try again or set a custom fee (status: {{status}})' DeviceSocketFail:
generic: Oops, an unknown error occurred. Please try again or contact Ledger Support. title: Oops, device connection failed. Please try again. [device-fail]
HardResetFail: Reset failed. Please try again. description: ''
LatestMCUInstalledError: MCU on device already up to date. DeviceSocketNoBulkStatus:
LedgerAPIError: 'Ledger API error. Try again. (HTTP {{status}})' title: Oops, device connection failed. Please try again [bulk].
LedgerAPIErrorWithMessage: '{{message}}' description: ''
LedgerAPINotAvailable: 'Ledger API not available for {{currencyName}}.' DeviceSocketNoHandler:
ManagerAPIsFail: Services are unavailable. Please try again. title: Oops, device connection failed (handler {{query}}). Please try again.
ManagerAppAlreadyInstalled: App is already installed description: ''
ManagerAppRelyOnBTC: You must install Bitcoin application first DisconnectedDevice:
ManagerDeviceLocked: Device is locked title: 'The device was disconnected.'
ManagerNotEnoughSpace: Not enough storage on device. Uninstall some apps and try again. description: ''
ManagerUnexpected: Unexpected error occurred ({{msg}}). Please try again. Error: # as this is a generic unhandled error i think it's ok to have a generic title. but keep description to {{message}}
ManagerUninstallBTCDep: You must uninstall other altcoins first title: 'Oops, an error occurred'
NetworkDown: 'Your internet connection seems down.' description: '{{message}}'
NoAddressesFound: 'No accounts were found.' FeeEstimationFailed:
NotEnoughBalance: 'Insufficient funds to proceed.' title: 'Fee estimation error. Try again or set a custom fee (status: {{status}})'
RangeError: '{{message}}' description: ''
TimeoutError: 'The request timed out.' generic:
TransportStatusError: '{{message}}' title: Oops, an unknown error occurred. Please try again or contact Ledger Support.
UserRefusedOnDevice: Transaction refused on device. description: ''
WebsocketConnectionError: Oops, device connection failed. Please try again. [web-err] HardResetFail:
WebsocketConnectionFailed: Oops, device connection failed. Please try again. [web-fail] title: Reset failed. Please try again.
WrongAppOpened: 'Open the ‘{{currencyName}}’ app on your Ledger device to proceed.' description: ''
WrongDeviceForAccount: 'Use the device associated with the account ‘{{accountName}}’.' LatestMCUInstalledError:
title: MCU on device already up to date.
description: ''
LedgerAPIError:
title: 'Ledger API error. Try again. (HTTP {{status}})'
description: ''
LedgerAPIErrorWithMessage:
title: '{{message}}'
description: ''
LedgerAPINotAvailable:
title: 'Ledger API not available for {{currencyName}}.'
description: ''
ManagerAPIsFail:
title: Services are unavailable. Please try again.
description: ''
ManagerAppAlreadyInstalled:
title: App is already installed
description: ''
ManagerAppRelyOnBTC:
title: You must install Bitcoin application first
description: ''
ManagerDeviceLocked:
title: Device is locked
description: ''
ManagerNotEnoughSpace:
title: Not enough storage on device
description: Uninstall some apps and try again.
ManagerUnexpectedError:
title: Unexpected error occurred ({{msg}})
description: Please try again.
ManagerUninstallBTCDep:
title: You must uninstall other altcoins first
description: ''
NetworkDown:
title: 'Your internet connection seems down.'
description: ''
NoAddressesFound:
title: 'No accounts were found.'
description: ''
NotEnoughBalance:
title: 'Insufficient funds to proceed.'
description: ''
RangeError:
title: '{{message}}'
description: ''
TimeoutError:
title: 'The request timed out.'
description: ''
TransportStatusError:
title: '{{message}}'
description: ''
UserRefusedOnDevice:
title: Transaction refused on device.
description: ''
WebsocketConnectionError:
title: Oops, device connection failed. Please try again. [web-err]
description: ''
WebsocketConnectionFailed:
title: Oops, device connection failed. Please try again. [web-fail]
description: ''
WrongAppOpened:
title: 'Open the ‘{{currencyName}}’ app on your Ledger device to proceed.'
description: ''
WrongDeviceForAccount:
title: 'Use the device associated with the account ‘{{accountName}}’.'
description: ''

Loading…
Cancel
Save