From e33e0effa3aa88f2e3c4b344cbc78167c2dde40b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 22 Jun 2017 15:05:13 +0100 Subject: [PATCH] use `_t` on string literals and i18n 'warning' Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/globals/UpdateCheckBar.js | 32 +++++++++++++------ src/i18n/strings/en_EN.json | 1 + 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/components/views/globals/UpdateCheckBar.js b/src/components/views/globals/UpdateCheckBar.js index d19a21cb8..926ccbccc 100644 --- a/src/components/views/globals/UpdateCheckBar.js +++ b/src/components/views/globals/UpdateCheckBar.js @@ -22,13 +22,6 @@ import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; import {updateCheckStatusEnum} from '../../../vector/platform/VectorBasePlatform'; import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton'; -const statusText = { - CHECKING: 'Checking for an update...', - ERROR: 'Error encountered (%(errorDetail)s).', - NOTAVAILABLE: 'No update available.', - DOWNLOADING: 'Downloading update...', -}; - const doneStatuses = [ updateCheckStatusEnum.ERROR, updateCheckStatusEnum.NOTAVAILABLE, @@ -42,16 +35,37 @@ export default React.createClass({ detail: React.PropTypes.string, }, + getDefaultProps: function() { + return { + detail: '', + } + }, + + getStatusText: function() { + switch(this.props.status) { + case updateCheckStatusEnum.ERROR: + return _t('Error encountered (%(errorDetail)s).', { errorDetail: this.props.detail }); + case updateCheckStatusEnum.CHECKING: + return _t('Checking for an update...'); + case updateCheckStatusEnum.NOTAVAILABLE: + return _t('No update available.'); + case updateCheckStatusEnum.DOWNLOADING: + return _t('Downloading update...'); + } + } + , + hideToolbar: function() { PlatformPeg.get().stopUpdateCheck(); }, render: function() { - const message = _t(statusText[this.props.status], { errorDetail: this.props.detail || '' }); + const message = this.getStatusText(); + const warning = _t('Warning'); let image; if (doneStatuses.includes(this.props.status)) { - image = Warning; + image = {warning}/; } else { image = {message}/; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index a535ced6c..10c21a62d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -159,6 +159,7 @@ "Today": "Today", "Yesterday": "Yesterday", "OK": "OK", + "Warning": "Warning", "Checking for an update...": "Checking for an update...", "Error encountered (%(errorDetail)s).": "Error encountered (%(errorDetail)s).", "No update available.": "No update available.",