diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 1b8a5d71..a8c0c4f5 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -262,10 +262,10 @@ "jump_unread": "Jump to unread messages", "mark_read": "Mark as read", "jump_latest": "Jump to latest", - "user_typing_one": "{{user_one}} is typing...", - "user_typing_two": "{{user_one}} and {{user_two}} are typing...", - "user_typing_three": "{{user_one}}, {{user_two}} and {{user_three}} are typing...", - "user_typing_four": "{{user_one}}, {{user_two}}, {{user_three}} and {{user_four}} are typing...", + "user_typing_1": " is typing...", + "user_typing_2": " and are typing...", + "user_typing_3": ", and are typing...", + "user_typing_4": ", , and are typing...", "user_typing_other": "Several people are typing..." }, "RoomViewContent": { @@ -287,20 +287,23 @@ "room_settings_subtitle": "room settings" }, "RoomCommon": { - "user_joined": "{{user_name}} joined the room", - "user_left": "{{user_name}} left the room", - "user_invited": "{{inviter_name}} invited {{user_name}}", - "invite_cancelled": "{{inviter_name}} cancelled {{user_name}}'s invite", - "invite_rejected": "{{user_name}} rejected the invitation", - "user_kicked": "{{actor}} kicked {{user_name}}: {{reason}}", - "user_banned": "{{actor}} banned {{user_name}}: {{reason}}", - "user_unbanned": "{{actor}} unbanned {{user_name}}", - "avatar_set": "{{user_name}} set an avatar", - "avatar_changed": "{{user_name}} changed their avatar", - "avatar_removed": "{{user_name}} removed their avatar", - "name_set": "{{user_name}} set their display name to {{new_name}}", - "name_changed": "{{user_name}} changed their display name to {{new_name}}", - "name_removed": "{{user_name}} removed their display name {{new_name}}" + "user_joined": " joined the room", + "user_left": " left the room", + "user_left_reason": " left the room: ", + "user_invited": " invited ", + "invite_cancelled": " cancelled 's invite", + "invite_rejected": " rejected the invitation", + "user_kicked": " kicked ", + "user_kicked_reason": " kicked : ", + "user_banned": " banned ", + "user_banned_reason": " banned : ", + "user_unbanned": " unbanned ", + "avatar_set": " set an avatar", + "avatar_changed": " changed their avatar", + "avatar_removed": " removed their avatar", + "name_set": " set their display name to ", + "name_changed": " changed their display name to ", + "name_removed": " removed their display name " }, "PublicRooms": { "could_not_join_alias": "Unable to join {{alias}}. Either the room is private or doesn't exist", @@ -461,10 +464,10 @@ "close_tooltip": "Close" }, "FollowingMembers": { - "users_following_one": "{{user_one}} is following the conversation", - "users_following_two": "{{user_one}} and {{user_two}} are following the conversation", - "users_following_three": "{{user_one}}, {{user_two}}, and {{user_three}} are following the conversation", - "users_following_other": "{{user_one}}, {{user_two}}, {{user_three}} and {{other_count}} others are following the conversation" + "users_following_1": " is following the conversation", + "users_following_2": " and are following the conversation", + "users_following_3": ", , and are following the conversation", + "users_following_other": ", , and {{other_count}} others are following the conversation" }, "ImageUpload": { "prompt": "Upload", @@ -499,10 +502,10 @@ "unknown_user": "** Unknown user **", "edited": "(edited)", "edit_placeholder": "Edit message", - "user_reacted_one": "{{user_one}} reacted with ", - "user_reacted_two": "{{user_one}} and {{user_two}} reacted with ", - "user_reacted_three": "{{user_one}}, {{user_two}} and {{user_three}} reacted with ", - "user_reacted_other": "{{user_one}}, {{user_two}}, {{user_three}} and {{other_count}} others reacted with ", + "user_reacted_1": " reacted with ", + "user_reacted_2": " and reacted with ", + "user_reacted_3": ", and reacted with ", + "user_reacted_other": ", , and {{other_count}} others reacted with ", "add_reaction_tooltip": "Add reaction", "reply_tooltip": "Reply", "edit_tooltip": "Edit", diff --git a/src/app/molecules/following-members/FollowingMembers.jsx b/src/app/molecules/following-members/FollowingMembers.jsx index 758335c3..1232e728 100644 --- a/src/app/molecules/following-members/FollowingMembers.jsx +++ b/src/app/molecules/following-members/FollowingMembers.jsx @@ -12,7 +12,7 @@ import Text from '../../atoms/text/Text'; import RawIcon from '../../atoms/system-icons/RawIcon'; import TickMarkIC from '../../../../public/res/ic/outlined/tick-mark.svg'; -import { twemojify } from '../../../util/twemojify'; +import { twemojify, Twemojify } from '../../../util/twemojify'; import '../../i18n'; @@ -43,6 +43,12 @@ function FollowingMembers({ roomTimeline }) { const filteredM = followingMembers.filter((userId) => userId !== myUserId); + let i18nKey = 'Molecules.FollowingMembers.users_following'; + + if (filteredM.length <= 3) { + i18nKey += `_${filteredM.length}`; + } + return filteredM.length !== 0 && ( diff --git a/src/app/molecules/message/Message.jsx b/src/app/molecules/message/Message.jsx index 0a8e5637..d60a0c83 100644 --- a/src/app/molecules/message/Message.jsx +++ b/src/app/molecules/message/Message.jsx @@ -6,7 +6,7 @@ import PropTypes from 'prop-types'; import './Message.scss'; import { useTranslation, Trans } from 'react-i18next'; -import { twemojify } from '../../../util/twemojify'; +import { twemojify, Twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; import { getUsername, getUsernameOfRoomMember, parseReply } from '../../../util/matrixUtil'; @@ -353,21 +353,24 @@ function pickEmoji(e, roomId, eventId, roomTimeline) { } function genReactionMsg(userIds, reaction, shortcode) { + let i18nKey = 'Molecules.Message.user_reacted'; + + if (userIds.length <= 3) { + i18nKey += `_${userIds.length}`; + } + return ( - <> - {userIds.map((userId, index) => ( - - {twemojify(getUsername(userId))} - {index < userIds.length - 1 && ( - - {index === userIds.length - 2 ? ' and ' : ', '} - - )} - - ))} - {' reacted with '} - {twemojify(shortcode ? `:${shortcode}:` : reaction, { className: 'react-emoji' })} - + , + user_one: , + user_two: , + user_three: , + emoji: , + }} + /> ); } diff --git a/src/app/organisms/room/RoomViewFloating.jsx b/src/app/organisms/room/RoomViewFloating.jsx index 4adec02d..5a16ccb8 100644 --- a/src/app/organisms/room/RoomViewFloating.jsx +++ b/src/app/organisms/room/RoomViewFloating.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import './RoomViewFloating.scss'; import { useTranslation, Trans } from 'react-i18next'; -import { twemojify } from '../../../util/twemojify'; +import { twemojify, Twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; @@ -109,11 +109,13 @@ function RoomViewFloating({ setIsAtBottom(true); }; - console.log(typingMembers); - const typingMemberValues = [...typingMembers]; - console.log(typingMemberValues); + let i18nKey = 'Organisms.RoomViewFloating.user_typing'; + + if (typingMemberValues.length <= 4) { + i18nKey += `_${typingMemberValues.length}`; + } return ( <> @@ -129,15 +131,17 @@ function RoomViewFloating({
}} + components={{ + bold: , + user_one: , + user_two: , + user_three: , + user_four: , + }} />
diff --git a/src/app/organisms/room/common.jsx b/src/app/organisms/room/common.jsx index 334cad47..2eacea32 100644 --- a/src/app/organisms/room/common.jsx +++ b/src/app/organisms/room/common.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Trans } from 'react-i18next'; -import { twemojify } from '../../../util/twemojify'; +import { twemojify, Twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; import { getUsername, getUsernameOfRoomMember } from '../../../util/matrixUtil'; @@ -15,18 +15,20 @@ function getTimelineJSXMessages() { return ( }} + components={{ bold: , user: }} /> ); }, leave(user, reason) { - const reasonMsg = (typeof reason === 'string') ? `: ${reason}` : ''; return ( }} + context={(typeof reason === 'string') ? 'reason' : null} + components={{ + bold: , + user: , + reason: , + }} /> ); }, @@ -34,8 +36,11 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + inviter: , + }} /> ); }, @@ -43,8 +48,11 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + inviter: , + }} /> ); }, @@ -52,36 +60,38 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + }} /> ); }, kick(actor, user, reason) { - const reasonMsg = (typeof reason === 'string') ? `${reason}` : ''; return ( , + user: , + actor: , + reason: , }} - components={{ bold: }} /> ); }, ban(actor, user, reason) { - const reasonMsg = (typeof reason === 'string') ? `${reason}` : ''; return ( , + user: , + actor: , + reason: , }} - components={{ bold: }} /> ); }, @@ -89,8 +99,11 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + actor: , + }} /> ); }, @@ -98,8 +111,10 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + }} /> ); }, @@ -107,8 +122,10 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + }} /> ); }, @@ -116,8 +133,10 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + }} /> ); }, @@ -125,8 +144,11 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + new_name: , + }} /> ); }, @@ -134,8 +156,11 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + new_name: , + }} /> ); }, @@ -143,8 +168,11 @@ function getTimelineJSXMessages() { return ( }} + components={{ + bold: , + user: , + last_name: , + }} /> ); }, diff --git a/src/util/twemojify.jsx b/src/util/twemojify.jsx index 0a4fede7..09f01afc 100644 --- a/src/util/twemojify.jsx +++ b/src/util/twemojify.jsx @@ -5,6 +5,7 @@ import linkifyHtml from 'linkify-html'; import parse from 'html-react-parser'; import twemoji from 'twemoji'; import { sanitizeText } from './sanitize'; +import PropTypes from 'prop-types'; const Math = lazy(() => import('../app/atoms/math/Math')); @@ -51,3 +52,19 @@ export function twemojify(text, opts, linkify = false, sanitize = true, maths = } return parse(content, maths ? mathOptions : null); } + +export function Twemojify({ text }) { + return ( + <> + {twemojify(text)} + + ); +} + +Twemojify.defaultProps = { + text: null, +}; + +Twemojify.propTypes = { + text: PropTypes.string, +};