Skip to content

Commit 386fcb9

Browse files
authored
Merge pull request element-hq#4087 from vector-im/kegan/translation-ape
Translate src/notifications
2 parents 045c32b + 2a122a2 commit 386fcb9

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

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

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

1717
'use strict';
1818
var React = require('react');
19-
import { _t } from 'matrix-react-sdk/lib/languageHandler';
19+
import { _t, _tJsx } from 'matrix-react-sdk/lib/languageHandler';
2020
var q = require("q");
2121
var sdk = require('matrix-react-sdk');
2222
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
@@ -535,7 +535,16 @@ module.exports = React.createClass({
535535
// it corresponds to all content push rules (stored in self.state.vectorContentRule)
536536
self.state.vectorPushRules.push({
537537
"vectorRuleId": "_keywords",
538-
"description" : (<span>Messages containing <span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>keywords</span></span>),
538+
"description" : (
539+
<span>
540+
{ _tJsx('Messages containing <span>keywords</span>',
541+
/<span>(.*?)<\/span>/,
542+
(sub) => {
543+
return <span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>{sub}</span>;
544+
}
545+
)}
546+
</span>
547+
),
539548
"vectorState": self.state.vectorContentRules.vectorState
540549
});
541550
}
@@ -549,7 +558,7 @@ module.exports = React.createClass({
549558

550559
self.state.vectorPushRules.push({
551560
"vectorRuleId": vectorRuleId,
552-
"description" : ruleDefinition.description,
561+
"description" : _t(ruleDefinition.description), // Text from VectorPushRulesDefinitions.js
553562
"rule": rule,
554563
"vectorState": vectorState,
555564
});
@@ -590,6 +599,7 @@ module.exports = React.createClass({
590599
phase: self.phases.DISPLAY
591600
});
592601
}, function(error) {
602+
console.error(error);
593603
self.setState({
594604
phase: self.phases.ERROR
595605
});
@@ -624,7 +634,7 @@ module.exports = React.createClass({
624634
return (
625635
<tr key={ className }>
626636
<th>
627-
{title}
637+
{ title }
628638
</th>
629639

630640
<th>

‎src/i18n/strings/en_EN.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"Members": "Members",
6060
"Mentions only": "Mentions only",
6161
"Messages containing my display name": "Messages containing my display name",
62+
"Messages containing <span>keywords</span>": "Messages containing <span>keywords</span>",
6263
"Messages containing my user name": "Messages containing my user name",
6364
"Messages in group chats": "Messages in group chats",
6465
"Messages in one-to-one chats": "Messages in one-to-one chats",

‎src/notifications/VectorPushRulesDefinitions.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
// Messages containing user's display name
6666
".m.rule.contains_display_name": new VectorPushRuleDefinition({
6767
kind: "override",
68-
description: "Messages containing my display name",
68+
description: "Messages containing my display name", // passed through _t() translation in src/components/views/settings/Notifications.js
6969
vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
7070
on: StandardActions.ACTION_NOTIFY,
7171
loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND,
@@ -76,7 +76,7 @@ module.exports = {
7676
// Messages containing user's username (localpart/MXID)
7777
".m.rule.contains_user_name": new VectorPushRuleDefinition({
7878
kind: "override",
79-
description: "Messages containing my user name",
79+
description: "Messages containing my user name", // passed through _t() translation in src/components/views/settings/Notifications.js
8080
vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
8181
on: StandardActions.ACTION_NOTIFY,
8282
loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND,
@@ -87,7 +87,7 @@ module.exports = {
8787
// Messages just sent to the user in a 1:1 room
8888
".m.rule.room_one_to_one": new VectorPushRuleDefinition({
8989
kind: "underride",
90-
description: "Messages in one-to-one chats",
90+
description: "Messages in one-to-one chats", // passed through _t() translation in src/components/views/settings/Notifications.js
9191
vectorStateToActions: {
9292
on: StandardActions.ACTION_NOTIFY,
9393
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
@@ -100,7 +100,7 @@ module.exports = {
100100
// By opposition, all other room messages are from group chat rooms.
101101
".m.rule.message": new VectorPushRuleDefinition({
102102
kind: "underride",
103-
description: "Messages in group chats",
103+
description: "Messages in group chats", // passed through _t() translation in src/components/views/settings/Notifications.js
104104
vectorStateToActions: {
105105
on: StandardActions.ACTION_NOTIFY,
106106
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
@@ -111,7 +111,7 @@ module.exports = {
111111
// Invitation for the user
112112
".m.rule.invite_for_me": new VectorPushRuleDefinition({
113113
kind: "underride",
114-
description: "When I'm invited to a room",
114+
description: "When I'm invited to a room", // passed through _t() translation in src/components/views/settings/Notifications.js
115115
vectorStateToActions: {
116116
on: StandardActions.ACTION_NOTIFY,
117117
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
@@ -122,7 +122,7 @@ module.exports = {
122122
// Incoming call
123123
".m.rule.call": new VectorPushRuleDefinition({
124124
kind: "underride",
125-
description: "Call invitation",
125+
description: "Call invitation", // passed through _t() translation in src/components/views/settings/Notifications.js
126126
vectorStateToActions: {
127127
on: StandardActions.ACTION_NOTIFY,
128128
loud: StandardActions.ACTION_NOTIFY_RING_SOUND,
@@ -133,7 +133,7 @@ module.exports = {
133133
// Notifications from bots
134134
".m.rule.suppress_notices": new VectorPushRuleDefinition({
135135
kind: "override",
136-
description: "Messages sent by bot",
136+
description: "Messages sent by bot", // passed through _t() translation in src/components/views/settings/Notifications.js
137137
vectorStateToActions: {
138138
// .m.rule.suppress_notices is a "negative" rule, we have to invert its enabled value for vector UI
139139
on: StandardActions.ACTION_DISABLED,

0 commit comments

Comments
 (0)