Translate notification strings

This commit is contained in:
Kegan Dougal 2017-05-30 17:39:41 +01:00
parent 1b4444cc73
commit 2a122a25fa
3 changed files with 22 additions and 11 deletions

View File

@ -16,7 +16,7 @@ limitations under the License.
'use strict'; 'use strict';
var React = require('react'); var React = require('react');
import { _t } from 'matrix-react-sdk/lib/languageHandler'; import { _t, _tJsx } from 'matrix-react-sdk/lib/languageHandler';
var q = require("q"); var q = require("q");
var sdk = require('matrix-react-sdk'); var sdk = require('matrix-react-sdk');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
@ -535,7 +535,16 @@ module.exports = React.createClass({
// it corresponds to all content push rules (stored in self.state.vectorContentRule) // it corresponds to all content push rules (stored in self.state.vectorContentRule)
self.state.vectorPushRules.push({ self.state.vectorPushRules.push({
"vectorRuleId": "_keywords", "vectorRuleId": "_keywords",
"description" : (<span>Messages containing <span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>keywords</span></span>), "description" : (
<span>
{ _tJsx('Messages containing <span>keywords</span>',
/<span>(.*?)<\/span>/,
(sub) => {
return <span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>{sub}</span>;
}
)}
</span>
),
"vectorState": self.state.vectorContentRules.vectorState "vectorState": self.state.vectorContentRules.vectorState
}); });
} }
@ -549,7 +558,7 @@ module.exports = React.createClass({
self.state.vectorPushRules.push({ self.state.vectorPushRules.push({
"vectorRuleId": vectorRuleId, "vectorRuleId": vectorRuleId,
"description" : ruleDefinition.description, "description" : _t(ruleDefinition.description), // Text from VectorPushRulesDefinitions.js
"rule": rule, "rule": rule,
"vectorState": vectorState, "vectorState": vectorState,
}); });
@ -590,6 +599,7 @@ module.exports = React.createClass({
phase: self.phases.DISPLAY phase: self.phases.DISPLAY
}); });
}, function(error) { }, function(error) {
console.error(error);
self.setState({ self.setState({
phase: self.phases.ERROR phase: self.phases.ERROR
}); });
@ -624,7 +634,7 @@ module.exports = React.createClass({
return ( return (
<tr key={ className }> <tr key={ className }>
<th> <th>
{title} { title }
</th> </th>
<th> <th>

View File

@ -59,6 +59,7 @@
"Members": "Members", "Members": "Members",
"Mentions only": "Mentions only", "Mentions only": "Mentions only",
"Messages containing my display name": "Messages containing my display name", "Messages containing my display name": "Messages containing my display name",
"Messages containing <span>keywords</span>": "Messages containing <span>keywords</span>",
"Messages containing my user name": "Messages containing my user name", "Messages containing my user name": "Messages containing my user name",
"Messages in group chats": "Messages in group chats", "Messages in group chats": "Messages in group chats",
"Messages in one-to-one chats": "Messages in one-to-one chats", "Messages in one-to-one chats": "Messages in one-to-one chats",

View File

@ -65,7 +65,7 @@ module.exports = {
// Messages containing user's display name // Messages containing user's display name
".m.rule.contains_display_name": new VectorPushRuleDefinition({ ".m.rule.contains_display_name": new VectorPushRuleDefinition({
kind: "override", kind: "override",
description: "Messages containing my display name", description: "Messages containing my display name", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { // The actions for each vector state, or null to disable the rule. vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
on: StandardActions.ACTION_NOTIFY, on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND, loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND,
@ -76,7 +76,7 @@ module.exports = {
// Messages containing user's username (localpart/MXID) // Messages containing user's username (localpart/MXID)
".m.rule.contains_user_name": new VectorPushRuleDefinition({ ".m.rule.contains_user_name": new VectorPushRuleDefinition({
kind: "override", kind: "override",
description: "Messages containing my user name", description: "Messages containing my user name", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { // The actions for each vector state, or null to disable the rule. vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
on: StandardActions.ACTION_NOTIFY, on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND, loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND,
@ -87,7 +87,7 @@ module.exports = {
// Messages just sent to the user in a 1:1 room // Messages just sent to the user in a 1:1 room
".m.rule.room_one_to_one": new VectorPushRuleDefinition({ ".m.rule.room_one_to_one": new VectorPushRuleDefinition({
kind: "underride", kind: "underride",
description: "Messages in one-to-one chats", description: "Messages in one-to-one chats", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { vectorStateToActions: {
on: StandardActions.ACTION_NOTIFY, on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND, loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
@ -100,7 +100,7 @@ module.exports = {
// By opposition, all other room messages are from group chat rooms. // By opposition, all other room messages are from group chat rooms.
".m.rule.message": new VectorPushRuleDefinition({ ".m.rule.message": new VectorPushRuleDefinition({
kind: "underride", kind: "underride",
description: "Messages in group chats", description: "Messages in group chats", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { vectorStateToActions: {
on: StandardActions.ACTION_NOTIFY, on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND, loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
@ -111,7 +111,7 @@ module.exports = {
// Invitation for the user // Invitation for the user
".m.rule.invite_for_me": new VectorPushRuleDefinition({ ".m.rule.invite_for_me": new VectorPushRuleDefinition({
kind: "underride", kind: "underride",
description: "When I'm invited to a room", description: "When I'm invited to a room", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { vectorStateToActions: {
on: StandardActions.ACTION_NOTIFY, on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND, loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
@ -122,7 +122,7 @@ module.exports = {
// Incoming call // Incoming call
".m.rule.call": new VectorPushRuleDefinition({ ".m.rule.call": new VectorPushRuleDefinition({
kind: "underride", kind: "underride",
description: "Call invitation", description: "Call invitation", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { vectorStateToActions: {
on: StandardActions.ACTION_NOTIFY, on: StandardActions.ACTION_NOTIFY,
loud: StandardActions.ACTION_NOTIFY_RING_SOUND, loud: StandardActions.ACTION_NOTIFY_RING_SOUND,
@ -133,7 +133,7 @@ module.exports = {
// Notifications from bots // Notifications from bots
".m.rule.suppress_notices": new VectorPushRuleDefinition({ ".m.rule.suppress_notices": new VectorPushRuleDefinition({
kind: "override", kind: "override",
description: "Messages sent by bot", description: "Messages sent by bot", // passed through _t() translation in src/components/views/settings/Notifications.js
vectorStateToActions: { vectorStateToActions: {
// .m.rule.suppress_notices is a "negative" rule, we have to invert its enabled value for vector UI // .m.rule.suppress_notices is a "negative" rule, we have to invert its enabled value for vector UI
on: StandardActions.ACTION_DISABLED, on: StandardActions.ACTION_DISABLED,