Skip to content

Commit b9faddc

Browse files
Merge pull request #19 from cometchat-pro/localization
v1.2.9
2 parents f1571d1 + e4a95eb commit b9faddc

File tree

98 files changed

+4509
-1149
lines changed

Some content is hidden

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

98 files changed

+4509
-1149
lines changed

CometChat/components/AddMemberView/index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState } from "react";
22

33
/** @jsx jsx */
44
import { jsx } from '@emotion/core';
5+
import PropTypes from 'prop-types';
56

67
import Avatar from "../Avatar";
78
import StatusIndicator from "../StatusIndicator";
@@ -15,6 +16,7 @@ import {
1516
selectionBoxStyle
1617
} from "./style";
1718

19+
import { theme } from "../../resources/theme";
1820
import inactiveIcon from "./resources/checkbox-inactive.svg";
1921
import activeIcon from "./resources/checkbox-blue-active.svg";
2022

@@ -59,17 +61,11 @@ const AddMemberView = (props) => {
5961
onMouseEnter={event => toggleTooltip(event, true)}
6062
onMouseLeave={event => toggleTooltip(event, false)}>
6163
<div css={avatarStyle()} className="avatar">
62-
<Avatar
63-
image={props.user.avatar}
64-
cornerRadius="50%"
65-
borderColor={props.theme.color.secondary}
66-
borderWidth="1px" />
64+
<Avatar image={props.user.avatar} borderColor={props.theme.borderColor.primary} />
6765
<StatusIndicator
6866
widgetsettings={props.widgetsettings}
6967
status={props.user.status}
70-
cornerRadius="50%"
71-
borderColor={props.theme.color.darkSecondary}
72-
borderWidth="1px" />
68+
borderColor={props.theme.borderColor.primary} />
7369
</div>
7470
<div css={nameStyle()} className="name">{props.user.name}</div>
7571
</td>
@@ -86,4 +82,13 @@ const AddMemberView = (props) => {
8682
)
8783
}
8884

85+
// Specifies the default values for props:
86+
AddMemberView.defaultProps = {
87+
theme: theme
88+
};
89+
90+
AddMemberView.propTypes = {
91+
theme: PropTypes.object
92+
}
93+
8994
export default AddMemberView;

CometChat/components/Avatar/index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import React from "react";
22

33
/** @jsx jsx */
44
import { jsx } from '@emotion/core';
5+
import PropTypes from 'prop-types';
56

6-
import {
7-
imgStyle
8-
} from "./style";
7+
import { imgStyle } from "./style";
98

109
import srcIcon from "./resources/1px.png";
1110

@@ -19,9 +18,9 @@ class Avatar extends React.Component {
1918

2019
render() {
2120

22-
const borderWidth = this.props.borderWidth || '1px';
23-
const borderColor = this.props.borderColor || '#AAA';
24-
const cornerRadius = this.props.cornerRadius || '50%';
21+
const borderWidth = this.props.borderWidth;
22+
const borderColor = this.props.borderColor;
23+
const cornerRadius = this.props.cornerRadius;
2524
const image = this.props.image;
2625

2726
let img = new Image();
@@ -36,9 +35,24 @@ class Avatar extends React.Component {
3635
const getStyle = () => ({ borderWidth: borderWidth, borderStyle: 'solid', borderColor: borderColor, 'borderRadius': cornerRadius });
3736

3837
return (
39-
<img src={srcIcon} data-src={image} css={imgStyle()} alt="Avatar" style={getStyle()} ref={el => { this.imgRef = el;}} />
38+
<img src={srcIcon} data-src={image} css={imgStyle()} alt={image} style={getStyle()} ref={el => { this.imgRef = el;}} />
4039
);
4140
}
4241
}
4342

43+
// Specifies the default values for props:
44+
Avatar.defaultProps = {
45+
borderWidth: "1px",
46+
borderColor: "#AAA",
47+
cornerRadius: "50%",
48+
image: srcIcon
49+
};
50+
51+
Avatar.propTypes = {
52+
borderWidth: PropTypes.string,
53+
borderColor: PropTypes.string,
54+
cornerRadius: PropTypes.string,
55+
image: PropTypes.string
56+
}
57+
4458
export default Avatar;

CometChat/components/Backdrop/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @jsx jsx */
22
import { jsx } from '@emotion/core';
3+
import PropTypes from 'prop-types';
34

45
import {
56
backdropStyle
@@ -9,4 +10,15 @@ const backdrop = (props) => (
910
props.show ? <div css={backdropStyle()} className="modal__backdrop" onClick={props.clicked}></div> : null
1011
);
1112

13+
// Specifies the default values for props:
14+
backdrop.defaultProps = {
15+
count: 0,
16+
clicked: () => {}
17+
};
18+
19+
backdrop.propTypes = {
20+
show: PropTypes.bool,
21+
clicked: PropTypes.func,
22+
}
23+
1224
export default backdrop;
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** @jsx jsx */
22
import { jsx } from '@emotion/core';
3+
import PropTypes from 'prop-types';
34

4-
import {
5-
badgeStyle
6-
} from "./style";
5+
import { theme } from "../../resources/theme";
6+
import { badgeStyle } from "./style";
77

88
const badgecount = (props) => {
99

@@ -14,7 +14,19 @@ const badgecount = (props) => {
1414
<span css={badgeStyle(props)} className="unread-count">{props.count}</span>
1515
);
1616
}
17+
1718
return count;
1819
}
1920

21+
// Specifies the default values for props:
22+
badgecount.defaultProps = {
23+
count: 0,
24+
theme: theme
25+
};
26+
27+
badgecount.propTypes = {
28+
count: PropTypes.number,
29+
theme: PropTypes.object
30+
}
31+
2032
export default badgecount;

CometChat/components/BanMemberView/index.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @jsx jsx */
22
import { jsx } from '@emotion/core';
3+
import PropTypes from 'prop-types';
34

45
import { CometChat } from "@cometchat-pro/chat";
56

@@ -14,18 +15,20 @@ import {
1415
actionStyle
1516
} from "./style";
1617

18+
import Translator from "../../resources/localization/translator";
19+
import { theme } from "../../resources/theme";
1720
import unban from "./resources/block.png";
1821

1922
const memberview = (props) => {
2023

2124
const roles = {}
22-
roles[CometChat.GROUP_MEMBER_SCOPE.ADMIN] = "Administrator";
23-
roles[CometChat.GROUP_MEMBER_SCOPE.MODERATOR] = "Moderator";
24-
roles[CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT] = "Participant";
25+
roles[CometChat.GROUP_MEMBER_SCOPE.ADMIN] = Translator.translate("ADMINISTRATOR", props.lang);
26+
roles[CometChat.GROUP_MEMBER_SCOPE.MODERATOR] = Translator.translate("MODERATOR", props.lang);
27+
roles[CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT] = Translator.translate("PARTICIPANT", props.lang);
2528

2629
let name = props.member.name;
2730
let scope = roles[props.member.scope];
28-
let unBan = (<img src={unban} alt="Unban" onClick={() => {props.actionGenerated("unban", props.member)}} />);
31+
let unBan = (<img src={unban} alt={Translator.translate("UNBAN", props.lang)} onClick={() => {props.actionGenerated("unban", props.member)}} />);
2932

3033
//if the loggedin user is moderator, don't allow unban of banned moderators or administrators
3134
if(props.item.scope === CometChat.GROUP_MEMBER_SCOPE.MODERATOR
@@ -57,25 +60,19 @@ const memberview = (props) => {
5760
} else {
5861
nameContainer.removeAttribute("title");
5962
}
60-
}
63+
}
6164

6265
return (
6366
<tr css={tableRowStyle(props)}>
6467
<td
6568
onMouseEnter={event => toggleTooltip(event, true)}
6669
onMouseLeave={event => toggleTooltip(event, false)}>
6770
<div css={avatarStyle()} className="avatar">
68-
<Avatar
69-
image={props.member.avatar}
70-
cornerRadius="18px"
71-
borderColor={props.theme.borderColor.primary}
72-
borderWidth="1px" />
71+
<Avatar image={props.member.avatar} borderColor={props.theme.borderColor.primary} />
7372
<StatusIndicator
7473
widgetsettings={props.widgetsettings}
7574
status={props.member.status}
76-
cornerRadius="50%"
77-
borderColor={props.theme.borderColor.primary}
78-
borderWidth="1px" />
75+
borderColor={props.theme.borderColor.primary} />
7976
</div>
8077
<div css={nameStyle()} className="name">{name}</div>
8178
</td>
@@ -85,4 +82,15 @@ const memberview = (props) => {
8582
);
8683
}
8784

85+
// Specifies the default values for props:
86+
memberview.defaultProps = {
87+
lang: Translator.getDefaultLanguage(),
88+
theme: theme
89+
};
90+
91+
memberview.propTypes = {
92+
lang: PropTypes.string,
93+
theme: PropTypes.object
94+
}
95+
8896
export default memberview;

CometChat/components/BanMemberView/style.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ export const tableRowStyle = (props) => {
88
fontSize: "14px",
99
"td": {
1010
padding: ".625em",
11-
"img": {
12-
width: "36px",
13-
height: "36px",
14-
float: "left",
15-
}
1611
}
1712
}
1813
}
@@ -22,10 +17,9 @@ export const avatarStyle = () => {
2217
return {
2318
display: "inline-block",
2419
float: "left",
25-
"span": {
26-
top: "26px",
27-
left: "-8px",
28-
}
20+
width: "36px",
21+
height: "36px",
22+
marginRight: "8px",
2923
}
3024
}
3125

CometChat/components/CallAlert/index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import React from "react";
22

33
/** @jsx jsx */
44
import { jsx, keyframes } from "@emotion/core";
5+
import PropTypes from 'prop-types';
6+
57
import { CometChat } from "@cometchat-pro/chat";
68

79
import { CometChatManager } from "../../util/controller";
810
import * as enums from '../../util/enums.js';
9-
11+
import { validateWidgetSettings } from "../../util/common";
12+
import Translator from "../../resources/localization/translator";
1013
import Avatar from "../Avatar";
1114
import { SvgAvatar } from '../../util/svgavatar';
12-
import { validateWidgetSettings } from "../../util/common";
15+
1316
import { CallAlertManager } from "./controller";
1417

1518
import {
@@ -172,13 +175,13 @@ class CallAlert extends React.PureComponent {
172175

173176
let callType = (
174177
<React.Fragment>
175-
<img src={audioCallIcon} alt="Incoming audio call" /><span>Incoming audio call</span>
178+
<img src={audioCallIcon} alt={Translator.translate("INCOMING_AUDIO_CALL", this.props.lang)} /><span>{Translator.translate("INCOMING_AUDIO_CALL", this.props.lang)}</span>
176179
</React.Fragment>
177180
);
178181
if (this.state.incomingCall.type === "video") {
179182
callType = (
180183
<React.Fragment>
181-
<img src={videoCallIcon} alt="Incoming video call" /><span>Incoming video call</span>
184+
<img src={videoCallIcon} alt={Translator.translate("INCOMING_VIDEO_CALL", this.props.lang)} /><span>{Translator.translate("INCOMING_VIDEO_CALL", this.props.lang)}</span>
182185
</React.Fragment>
183186
);
184187
}
@@ -191,11 +194,13 @@ class CallAlert extends React.PureComponent {
191194
<div css={nameStyle()} className="name">{this.state.incomingCall.sender.name}</div>
192195
<div css={callTypeStyle(this.props)} className="calltype">{callType}</div>
193196
</div>
194-
<div css={thumbnailStyle()} className="header__thumbnail"><Avatar cornerRadius="50%" image={this.state.incomingCall.sender.avatar} /></div>
197+
<div css={thumbnailStyle()} className="header__thumbnail">
198+
<Avatar cornerRadius="50%" image={this.state.incomingCall.sender.avatar} />
199+
</div>
195200
</div>
196201
<div css={headerButtonStyle()} className="callalert__buttons">
197-
<button css={ButtonStyle(this.props, 0)} className="button button__decline" onClick={this.rejectCall}>Decline</button>
198-
<button css={ButtonStyle(this.props, 1)} className="button button__accept" onClick={this.acceptCall}>Accept</button>
202+
<button css={ButtonStyle(this.props, 0)} className="button button__decline" onClick={this.rejectCall}>{Translator.translate("DECLINE", this.props.lang)}</button>
203+
<button css={ButtonStyle(this.props, 1)} className="button button__accept" onClick={this.acceptCall}>{Translator.translate("ACCEPT", this.props.lang)}</button>
199204
</div>
200205
</div>
201206
</div>
@@ -206,4 +211,13 @@ class CallAlert extends React.PureComponent {
206211
}
207212
}
208213

214+
// Specifies the default values for props:
215+
CallAlert.defaultProps = {
216+
lang: Translator.getDefaultLanguage(),
217+
};
218+
219+
CallAlert.propTypes = {
220+
lang: PropTypes.string,
221+
}
222+
209223
export default CallAlert;

0 commit comments

Comments
 (0)