From 6c18e13f8ae4d8785b598adc0cb3e93c27cec849 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sat, 27 Feb 2016 08:19:03 -0800 Subject: [PATCH] Adding missing localization --- web/react/components/channel_loader.jsx | 14 ++++++++++++++ web/react/stores/socket_store.jsx | 6 ++---- web/react/utils/client.jsx | 17 +++++++++++++---- web/static/i18n/en.json | 2 ++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/web/react/components/channel_loader.jsx b/web/react/components/channel_loader.jsx index f3000ee055..e47f2aa501 100644 --- a/web/react/components/channel_loader.jsx +++ b/web/react/components/channel_loader.jsx @@ -6,6 +6,7 @@ AsyncClient with requests. */ import * as AsyncClient from '../utils/async_client.jsx'; +import * as Client from '../utils/client.jsx'; import SocketStore from '../stores/socket_store.jsx'; import ChannelStore from '../stores/channel_store.jsx'; import PostStore from '../stores/post_store.jsx'; @@ -45,6 +46,14 @@ const holders = defineMessages({ wrote: { id: 'channel_loader.wrote', defaultMessage: ' wrote: ' + }, + connectionError: { + id: 'channel_loader.connection_error', + defaultMessage: 'There appears to be a problem with your internet connection.' + }, + unknownError: { + id: 'channel_loader.unknown_error', + defaultMessage: 'We received an unexpected status code from the server.' } }); @@ -67,6 +76,11 @@ class ChannelLoader extends React.Component { wrote: formatMessage(holders.wrote) }); + Client.setTranslations({ + connectionError: formatMessage(holders.connectionError), + unknownError: formatMessage(holders.unknownError) + }); + this.state = {}; } componentDidMount() { diff --git a/web/react/stores/socket_store.jsx b/web/react/stores/socket_store.jsx index c07f597383..9b2b049b74 100644 --- a/web/react/stores/socket_store.jsx +++ b/web/react/stores/socket_store.jsx @@ -69,10 +69,8 @@ class SocketStoreClass extends EventEmitter { if (this.failCount > 0) { console.log('websocket re-established connection'); //eslint-disable-line no-console - if (ErrorStore.getLastError()) { - ErrorStore.clearLastError(); - ErrorStore.emitChange(); - } + ErrorStore.clearLastError(); + ErrorStore.emitChange(); AsyncClient.getChannels(); AsyncClient.getPosts(ChannelStore.getCurrentId()); diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 2d0377e721..f647e22965 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -4,6 +4,15 @@ import BrowserStore from '../stores/browser_store.jsx'; import TeamStore from '../stores/team_store.jsx'; import ErrorStore from '../stores/error_store.jsx'; +let translations = { + connectionError: 'There appears to be a problem with your internet connection.', + unknownError: 'We received an unexpected status code from the server.' +}; + +export function setTranslations(messages) { + translations = messages; +} + export function track(category, action, label, property, value) { global.window.analytics.track(action, {category, label, property, value}); } @@ -23,14 +32,14 @@ function handleError(methodName, xhr, status, err) { var msg = ''; if (e) { - msg = 'error in ' + methodName + ' msg=' + e.message + ' detail=' + e.detailed_error + ' rid=' + e.request_id; + msg = 'method=' + methodName + ' msg=' + e.message + ' detail=' + e.detailed_error + ' rid=' + e.request_id; } else { - msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err; + msg = 'method=' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err; if (xhr.status === 0) { - e = {message: 'There appears to be a problem with your internet connection'}; + e = {message: translations.connectionError}; } else { - e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'}; + e = {message: translations.unknownError + ' (' + xhr.status + ')'}; } } diff --git a/web/static/i18n/en.json b/web/static/i18n/en.json index 32ceb494fd..d7d0a90574 100644 --- a/web/static/i18n/en.json +++ b/web/static/i18n/en.json @@ -543,6 +543,8 @@ "channel_loader.uploadedFile": " uploaded a file", "channel_loader.uploadedImage": " uploaded an image", "channel_loader.wrote": " wrote: ", + "channel_loader.connection_error": "There appears to be a problem with your internet connection.", + "channel_loader.unknown_error": "We received an unexpected status code from the server.", "channel_members_modal.addNew": " Add New Members", "channel_members_modal.close": "Close", "channel_memebers_modal.members": " Members",