From 0fb6a305a316c39f32259aea5434336c864a7d9c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 26 May 2017 09:45:30 +0100 Subject: [PATCH 01/15] uber basic multi-profile support for electron app Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron_app/package.json | 3 ++- electron_app/src/electron-main.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/electron_app/package.json b/electron_app/package.json index df9c3bd261..e001f51de6 100644 --- a/electron_app/package.json +++ b/electron_app/package.json @@ -6,6 +6,7 @@ "description": "A feature-rich client for Matrix.org", "author": "Vector Creations Ltd.", "dependencies": { - "electron-window-state": "^4.1.0" + "electron-window-state": "^4.1.0", + "minimist": "^1.2.0" } } diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index 26f8f972f3..9170d4b495 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -23,6 +23,7 @@ limitations under the License. const check_squirrel_hooks = require('./squirrelhooks'); if (check_squirrel_hooks()) return; +const argv = require('minimist')(process.argv); const electron = require('electron'); const tray = require('./tray'); @@ -32,6 +33,10 @@ const webContentsHandler = require('./webcontents-handler'); const windowStateKeeper = require('electron-window-state'); +if (argv.profile) { + electron.app.setPath('userData', `${electron.app.getPath('userData')}-${argv.profile}`); +} + let vectorConfig = {}; try { vectorConfig = require('../../webapp/config.json'); @@ -191,7 +196,7 @@ electron.app.on('ready', () => { brand: vectorConfig.brand || 'Riot' }); - if (!process.argv.includes('--hidden')) { + if (!argv.hidden) { mainWindow.once('ready-to-show', () => { mainWindow.show(); }); From e63baf62c44e54a6704597570067f8380989b6e3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 26 May 2017 09:49:23 +0100 Subject: [PATCH 02/15] quit -> exit as screen is not accessible in alt instance when using makeSingleInstance which leads to a weird error Unhandled exception { Error: Cannot find module '../screen' Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron_app/src/electron-main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index 9170d4b495..0df1662b80 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -156,7 +156,7 @@ const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirector if (shouldQuit) { console.log("Other instance detected: exiting"); - electron.app.quit() + electron.app.exit(); } electron.app.on('ready', () => { From 52ddcd8a600bba9b66f66b04a7cc5640a705b81b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 31 May 2017 14:51:08 +0100 Subject: [PATCH 03/15] Translate src/vector/platform --- src/i18n/strings/en_EN.json | 4 ++++ src/vector/index.js | 1 - src/vector/platform/ElectronPlatform.js | 5 +++-- src/vector/platform/VectorBasePlatform.js | 6 ++++-- src/vector/platform/WebPlatform.js | 9 ++++++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index adf0800d3e..494ad65dea 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1,4 +1,5 @@ { + "%(appName)s via %(browserName)s on %(osName)s": "%(appName)s via %(browserName)s on %(osName)s", "Safari and Opera work too.": "Safari and Opera work too.", "Add an email address above to configure email notifications": "Add an email address above to configure email notifications", "Advanced notification settings": "Advanced notification settings", @@ -88,6 +89,7 @@ "remove %(name)s from the directory": "remove %(name)s from the directory", "Remove from Directory": "Remove from Directory", "Resend": "Resend", + "Riot Desktop on %(platformName)": "Riot Desktop on %(platformName)", "Riot does not know how to join a room on this network": "Riot does not know how to join a room on this network", "Riot uses many advanced browser features, some of which are not available or experimental in your current browser.": "Riot uses many advanced browser features, some of which are not available or experimental in your current browser.", "Room directory": "Room directory", @@ -106,6 +108,7 @@ "Unable to join network": "Unable to join network", "Unable to look up room ID from server": "Unable to look up room ID from server", "Unhide Preview": "Unhide Preview", + "Unknown device": "Unknown device", "unknown error code": "unknown error code", "Unnamed room": "Unnamed room", "Uploaded on %(date)s by %(user)s": "Uploaded on %(date)s by %(user)s", @@ -126,6 +129,7 @@ "Saturday": "Saturday", "Today": "Today", "Yesterday": "Yesterday", + "You need to be using HTTPS to place a screen-sharing call.": "You need to be using HTTPS to place a screen-sharing call.", "Welcome page": "Welcome page", "With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!": "With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!" } diff --git a/src/vector/index.js b/src/vector/index.js index 432710fbc2..716e9c53e5 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -278,7 +278,6 @@ async function loadApp() { , document.getElementById('matrixchat')); } else if (validBrowser) { UpdateChecker.start(); - const MatrixChat = sdk.getComponent('structures.MatrixChat'); window.matrixChat = ReactDOM.render( Date: Wed, 31 May 2017 15:06:03 +0100 Subject: [PATCH 04/15] Translate src/vector --- src/i18n/strings/en_EN.json | 5 +++++ src/vector/index.html | 2 +- src/vector/index.js | 4 ++-- src/vector/submit-rageshake.js | 9 +++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 494ad65dea..2c8bb19aae 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -12,6 +12,8 @@ "Can't update user notification settings": "Can't update user notification settings", "Close": "Close", "Collapse panel": "Collapse panel", + "Collecting app version information": "Collecting app version information", + "Collecting logs": "Collecting logs", "Create new room": "Create new room", "Couldn't find a matching Matrix room": "Couldn't find a matching Matrix room", "Custom Server Options": "Custom Server Options", @@ -91,6 +93,7 @@ "Resend": "Resend", "Riot Desktop on %(platformName)": "Riot Desktop on %(platformName)", "Riot does not know how to join a room on this network": "Riot does not know how to join a room on this network", + "Riot is not supported on mobile web. Install the app?": "Riot is not supported on mobile web. Install the app?", "Riot uses many advanced browser features, some of which are not available or experimental in your current browser.": "Riot uses many advanced browser features, some of which are not available or experimental in your current browser.", "Room directory": "Room directory", "Room not found": "Room not found", @@ -112,8 +115,10 @@ "unknown error code": "unknown error code", "Unnamed room": "Unnamed room", "Uploaded on %(date)s by %(user)s": "Uploaded on %(date)s by %(user)s", + "Uploading report": "Uploading report", "View Decrypted Source": "View Decrypted Source", "View Source": "View Source", + "Waiting for response from server": "Waiting for response from server", "When I'm invited to a room": "When I'm invited to a room", "World readable": "World readable", "You cannot delete this image. (%(code)s)": "You cannot delete this image. (%(code)s)", diff --git a/src/vector/index.html b/src/vector/index.html index 38810f62c1..49c2979ed1 100644 --- a/src/vector/index.html +++ b/src/vector/index.html @@ -36,7 +36,7 @@
- + <% for (var i=0; i < htmlWebpackPlugin.files.js.length; i++) { // Not a particularly graceful way of not putting the indexeddb worker script // into the main page diff --git a/src/vector/index.js b/src/vector/index.js index 716e9c53e5..9f16205164 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -245,13 +245,13 @@ async function loadApp() { if (!preventRedirect) { if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) { - if (confirm("Riot is not supported on mobile web. Install the app?")) { + if (confirm(languageHandler._t("Riot is not supported on mobile web. Install the app?"))) { window.location = "https://itunes.apple.com/us/app/vector.im/id1083446067"; return; } } else if (/Android/.test(navigator.userAgent)) { - if (confirm("Riot is not supported on mobile web. Install the app?")) { + if (confirm(languageHandler._t("Riot is not supported on mobile web. Install the app?"))) { window.location = "https://play.google.com/store/apps/details?id=im.vector.alpha"; return; } diff --git a/src/vector/submit-rageshake.js b/src/vector/submit-rageshake.js index 45b427e899..c6c551c61f 100644 --- a/src/vector/submit-rageshake.js +++ b/src/vector/submit-rageshake.js @@ -19,6 +19,7 @@ import q from "q"; import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; +import { _t } from 'matrix-react-sdk/lib/languageHandler'; import rageshake from './rageshake' @@ -53,7 +54,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) { opts = opts || {}; const progressCallback = opts.progressCallback || (() => {}); - progressCallback("Collecting app version information"); + progressCallback(_t("Collecting app version information")); let version = "UNKNOWN"; try { version = await PlatformPeg.get().getAppVersion(); @@ -81,7 +82,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) { } if (opts.sendLogs) { - progressCallback("Collecting logs"); + progressCallback(_t("Collecting logs")); const logs = await rageshake.getLogsForReport(); for (let entry of logs) { // encode as UTF-8 @@ -94,7 +95,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) { } } - progressCallback("Uploading report"); + progressCallback(_t("Uploading report")); await _submitReport(bugReportEndpoint, body, progressCallback); } @@ -106,7 +107,7 @@ function _submitReport(endpoint, body, progressCallback) { req.timeout = 5 * 60 * 1000; req.onreadystatechange = function() { if (req.readyState === XMLHttpRequest.LOADING) { - progressCallback("Waiting for response from server"); + progressCallback(_t("Waiting for response from server")); } else if (req.readyState === XMLHttpRequest.DONE) { on_done(); } From 162f3872e5d2182b30346e6f2903b30691d40cf6 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 31 May 2017 15:40:49 +0100 Subject: [PATCH 05/15] Translate src/components/context_menus|dialogs --- .../views/context_menus/MessageContextMenu.js | 2 +- .../views/dialogs/BugReportDialog.js | 34 +++++++++++-------- .../views/dialogs/ChangelogDialog.js | 7 ++-- src/i18n/strings/en_EN.json | 14 ++++++++ 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 5445fd4fb8..e3f4d14042 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -182,7 +182,7 @@ module.exports = React.createClass({ if (content.msgtype && content.msgtype !== 'm.bad.encrypted' && content.hasOwnProperty('body')) { forwardButton = (
- Forward Message + { _t('Forward Message') }
); } diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js index 7a65ac587f..0db425e33f 100644 --- a/src/components/views/dialogs/BugReportDialog.js +++ b/src/components/views/dialogs/BugReportDialog.js @@ -17,6 +17,7 @@ limitations under the License. import React from 'react'; import sdk from 'matrix-react-sdk'; import SdkConfig from 'matrix-react-sdk/lib/SdkConfig'; +import { _t } from 'matrix-react-sdk/lib/languageHandler'; export default class BugReportDialog extends React.Component { constructor(props, context) { @@ -49,12 +50,12 @@ export default class BugReportDialog extends React.Component { const userText = this.state.text; if (!sendLogs && userText.trim().length === 0) { this.setState({ - err: "Please describe the bug and/or send logs.", + err: _t("Please describe the bug and/or send logs."), }); return; } this.setState({ busy: true, progress: null, err: null }); - this._sendProgressCallback("Loading bug report module"); + this._sendProgressCallback(_t("Loading bug report module")); require(['../../../vector/submit-rageshake'], (s) => { s(SdkConfig.get().bug_report_endpoint_url, { @@ -69,8 +70,9 @@ export default class BugReportDialog extends React.Component { }, (err) => { if (!this._unmounted) { this.setState({ - busy: false, progress: null, - err: `Failed to send report: ${err.message}`, + busy: false, + progress: null, + err: _t("Failed to send report: ") + `${err.message}`, }); } }); @@ -105,7 +107,7 @@ export default class BugReportDialog extends React.Component { let cancelButton = null; if (!this.state.busy) { cancelButton = ; } @@ -122,25 +124,27 @@ export default class BugReportDialog extends React.Component { return (
- Report a bug + { _t("Report a bug") }
-

Please describe the bug. What did you do? - What did you expect to happen? - What actually happened?

+

+ { _t("Please describe the bug. What did you do? What did you expect to happen? What actually happened?") } +