Skip to content

Commit 3e066d3

Browse files
committed
Merge branch 'develop' into travis/pinned_messages
2 parents 2d153a7 + 2667ed2 commit 3e066d3

69 files changed

Lines changed: 1793 additions & 579 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ You can configure the app by copying `config.sample.json` to
115115
addresses) to matrix IDs: see http://matrix.org/docs/spec/identity_service/unstable.html
116116
for more details. Currently the only public matrix identity servers are https://matrix.org
117117
and https://vector.im. In future identity servers will be decentralised.
118-
1. `integrations_ui_url`: URL to the web interface for the integrations server.
118+
1. `integrations_ui_url`: URL to the web interface for the integrations server. The integrations
119+
server is not Riot and normally not your Home Server either. The integration server settings
120+
may be left blank to disable integrations.
119121
1. `integrations_rest_url`: URL to the REST interface for the integrations server.
120122
1. `roomDirectory`: config for the public room directory. This section is optional.
121123
1. `roomDirectory.servers`: List of other Home Servers' directories to include in the drop

‎config.sample.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"integrations_rest_url": "https://scalar.vector.im/api",
77
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
88
"enableLabs": true,
9+
"default_federate": true,
910
"roomDirectory": {
1011
"servers": [
1112
"matrix.org"

‎docs/translating-dev.md‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,30 @@
66
- Be able to understand English
77
- Be able to understand the language you want to translate riot-web into
88

9+
## Translating strings vs. marking strings for translation
10+
11+
Translating strings are done with the `_t()` function found in matrix-react-sdk/lib/languageHandler.js. It is recommended to call this function wherever you introduce a string constant which should be translated. However, translating can not be performed until after the translation system has been initialized. Thus, sometimes translation must be performed at a different location in the source code than where the string is introduced. This breaks some tooling and makes it difficult to find translatable strings. Therefore, there is the alternative `_td()` function which is used to mark strings for translation, without actually performing the translation (which must still be performed separately, and after the translation system has been initialized).
12+
13+
Basically, whenever a translatable string is introduced, you should call either `_t()` immediately OR `_td()` and later `_t()`.
14+
15+
Example:
16+
```
17+
// Module-level constant
18+
const COLORS = {
19+
'#f8481c': _td('reddish orange'), // Can't call _t() here yet
20+
'#fc2647': _td('pinky red') // Use _td() instead so the text is picked up for translation anyway
21+
}
22+
23+
// Function that is called some time after i18n has been loaded
24+
function getColorName(hex) {
25+
return _t(COLORS[hex]); // Perform actual translation here
26+
}
27+
```
28+
929
## Adding new strings
1030

11-
1. Check if the import ``import { _t } from 'matrix-react-sdk/lib/languageHandler';`` is present. If not add it to the other import statements.
12-
2. Add ``_t()`` to your string. (Don't forget curly braces when you assign an expression to JSX attributes in the render method)
31+
1. Check if the import ``import { _t } from 'matrix-react-sdk/lib/languageHandler';`` is present. If not add it to the other import statements. Also import `_td` if needed.
32+
2. Add ``_t()`` to your string. (Don't forget curly braces when you assign an expression to JSX attributes in the render method). If the string is introduced at a point before the translation system has not yet been initialized, use `_td()` instead, and call `_t()` at the appropriate time.
1333
3. Add the String to the ``en_EN.json`` file in ``src/i18n/strings`` (respect which repository you are on).
1434

1535
## Adding variables inside a string.
@@ -21,6 +41,8 @@
2141

2242
## Things to know/Style Guides
2343

24-
- Do not use it inside ``getDefaultProps`` at the point where ``getDefaultProps`` is initialized the translations aren't loaded yet and it causes missing translations.
25-
- If using translated strings as constants, translated strings can't be in constants loaded at class-load time since the translations won't be loaded.
44+
- Do not use `_t()` inside ``getDefaultProps``: the translations aren't loaded when `getDefaultProps` is called, leading to missing translations. Use `_td()` to indicate that `_t()` will be called on the string later.
45+
- If using translated strings as constants, translated strings can't be in constants loaded at class-load time since the translations won't be loaded. Mark the strings using `_td()` instead and perform the actual translation later.
2646
- If a string is presented in the UI with punctuation like a full stop, include this in the translation strings, since punctuation varies between languages too.
47+
- Avoid "translation in parts", i.e. concatenating translated strings or using translated strings in variable substitutions. Context is important for translations, and translating partial strings this way is simply not always possible.
48+
- Concatenating strings often also introduces an implicit assumption about word order (e.g. that the subject of the sentence comes first), which is incorrect for many languages.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"build": {
153153
"appId": "im.riot.app",
154154
"category": "Network",
155-
"electronVersion": "1.7.5",
155+
"electronVersion": "1.7.9",
156156
"//asar=false": "https://github.com/electron-userland/electron-builder/issues/675",
157157
"asar": false,
158158
"dereference": true,

‎scripts/copy-res.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,15 @@ function genLangFile(lang, dest) {
160160
let translations = {};
161161
[reactSdkFile, riotWebFile].forEach(function(f) {
162162
if (fs.existsSync(f)) {
163-
Object.assign(
164-
translations,
165-
JSON.parse(fs.readFileSync(f).toString())
166-
);
163+
try {
164+
Object.assign(
165+
translations,
166+
JSON.parse(fs.readFileSync(f).toString())
167+
);
168+
} catch (e) {
169+
console.error("Failed: "+f, e);
170+
throw e;
171+
}
167172
}
168173
});
169174

‎src/components/structures/RoomSubList.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ var RoomSubList = React.createClass({
536536
var label = this.props.collapsed ? null : this.props.label;
537537

538538
let content;
539-
if (this.state.sortedList.length == 0 && !this.props.searchFilter && !this.props.extraTiles) {
539+
if (this.state.sortedList.length === 0 && !this.props.searchFilter && this.props.extraTiles.length === 0) {
540540
content = this.props.emptyContent;
541541
} else {
542542
content = this.makeRoomTiles();

‎src/components/views/context_menus/RoomTileContextMenu.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Promise from 'bluebird';
2121
import React from 'react';
2222
import classNames from 'classnames';
2323
import sdk from 'matrix-react-sdk';
24-
import { _t } from 'matrix-react-sdk/lib/languageHandler';
24+
import { _t, _td } from 'matrix-react-sdk/lib/languageHandler';
2525
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
2626
import dis from 'matrix-react-sdk/lib/dispatcher';
2727
import DMRoomMap from 'matrix-react-sdk/lib/utils/DMRoomMap';
@@ -185,7 +185,7 @@ module.exports = React.createClass({
185185
MatrixClientPeg.get().forget(this.props.room.roomId).done(function() {
186186
dis.dispatch({ action: 'view_next_room' });
187187
}, function(err) {
188-
var errCode = err.errcode || "unknown error code";
188+
var errCode = err.errcode || _td("unknown error code");
189189
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
190190
Modal.createTrackedDialog('Failed to forget room', '', ErrorDialog, {
191191
title: _t('Failed to forget room %(errCode)s', {errCode: errCode}),

‎src/components/views/elements/ImageView.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,16 @@ module.exports = React.createClass({
150150

151151
var eventMeta;
152152
if(showEventMeta) {
153+
// Figure out the sender, defaulting to mxid
154+
let sender = this.props.mxEvent.getSender();
155+
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
156+
if (room) {
157+
const member = room.getMember(sender);
158+
if (member) sender = member.name;
159+
}
160+
153161
eventMeta = (<div className="mx_ImageView_metadata">
154-
{ _t('Uploaded on %(date)s by %(user)s', {date: DateUtils.formatDate(new Date(this.props.mxEvent.getTs())), user: this.props.mxEvent.getSender()}) }
162+
{ _t('Uploaded on %(date)s by %(user)s', {date: DateUtils.formatDate(new Date(this.props.mxEvent.getTs())), user: sender}) }
155163
</div>);
156164
}
157165

‎src/components/views/login/VectorLoginHeader.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ limitations under the License.
1616

1717
'use strict';
1818

19-
var React = require('react');
19+
import React from 'react';
20+
import PropTypes from 'prop-types';
2021

2122
const i = [1, 2, 3, 4, 5][Math.floor(Math.random() * 5)];
22-
const DEFAULT_LOGO_URI = "img/logos/riot-logo-" + i + ".svg";
23+
const DEFAULT_LOGO_URI = "img/logos/riot-im-logo-" + i + ".svg";
2324

2425
module.exports = React.createClass({
2526
displayName: 'VectorLoginHeader',
2627
statics: {
2728
replaces: 'LoginHeader',
2829
},
2930
propTypes: {
30-
icon: React.PropTypes.string,
31+
icon: PropTypes.string,
3132
},
3233

3334
render: function() {

‎src/components/views/settings/Notifications.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ module.exports = React.createClass({
116116
UserSettingsStore.setEnableNotifications(event.target.checked);
117117
},
118118

119+
onEnableDesktopNotificationBodyChange: function(event) {
120+
UserSettingsStore.setEnableNotificationBody(event.target.checked);
121+
this.forceUpdate();
122+
},
123+
119124
onEnableEmailNotificationsChange: function(address, event) {
120125
var emailPusherPromise;
121126
if (event.target.checked) {
@@ -831,6 +836,21 @@ module.exports = React.createClass({
831836
</div>
832837
</div>
833838

839+
<div className="mx_UserNotifSettings_tableRow">
840+
<div className="mx_UserNotifSettings_inputCell">
841+
<input id="enableDesktopNotificationBody"
842+
ref="enableDesktopNotificationBody"
843+
type="checkbox"
844+
checked={ UserSettingsStore.getEnableNotificationBody() }
845+
onChange={ this.onEnableDesktopNotificationBodyChange } />
846+
</div>
847+
<div className="mx_UserNotifSettings_labelCell">
848+
<label htmlFor="enableDesktopNotificationBody">
849+
{ _t('Show message in desktop notification') }
850+
</label>
851+
</div>
852+
</div>
853+
834854
<div className="mx_UserNotifSettings_tableRow">
835855
<div className="mx_UserNotifSettings_inputCell">
836856
<input id="enableDesktopAudioNotifications"

0 commit comments

Comments
 (0)