fix: more i18n changes

pull/3206/head
Audric Ackermann 9 months ago
parent 4f44eecd6b
commit 1f366b6d8b

@ -300,8 +300,8 @@
"disappearingMessagesOnlyAdmins": "Only group admins can change this setting.", "disappearingMessagesOnlyAdmins": "Only group admins can change this setting.",
"disappearingMessagesSent": "Sent", "disappearingMessagesSent": "Sent",
"disappearingMessagesSet": "<b>{name}</b> has set messages to disappear {time} after they have been {disappearing_messages_type}.", "disappearingMessagesSet": "<b>{name}</b> has set messages to disappear {time} after they have been {disappearing_messages_type}.",
"disappearingMessagesSetYou": "<b>You</b> set messages to disappear {time} after they have been {disappearing_messages_type}.",
"disappearingMessagesTimer": "Timer", "disappearingMessagesTimer": "Timer",
"disappearingMessagesSetYou": "<b>You</b> set messages to disappear {time} after they have been {disappearing_messages_type}.",
"disappearingMessagesTurnedOff": "<b>{name}</b> has turned disappearing messages off. Messages they send will no longer disappear.", "disappearingMessagesTurnedOff": "<b>{name}</b> has turned disappearing messages off. Messages they send will no longer disappear.",
"disappearingMessagesTurnedOffYou": "<b>You</b> turned <b>off</b> disappearing messages. Messages you send will no longer disappear.", "disappearingMessagesTurnedOffYou": "<b>You</b> turned <b>off</b> disappearing messages. Messages you send will no longer disappear.",
"disappearingMessagesTypeRead": "read", "disappearingMessagesTypeRead": "read",

@ -96,7 +96,6 @@ export const NoMessageInConversation = () => {
const isMe = useSelectedIsNoteToSelf(); const isMe = useSelectedIsNoteToSelf();
const canWrite = useSelector(getSelectedCanWrite); const canWrite = useSelector(getSelectedCanWrite);
const privateBlindedAndBlockingMsgReqs = useSelectedHasDisabledBlindedMsgRequests(); const privateBlindedAndBlockingMsgReqs = useSelectedHasDisabledBlindedMsgRequests();
// TODOLATER use this selector across the whole application (left pane excluded)
const name = useSelectedNicknameOrProfileNameOrShortenedPubkey(); const name = useSelectedNicknameOrProfileNameOrShortenedPubkey();
const messageText = useMemo(() => { const messageText = useMemo(() => {

@ -390,6 +390,13 @@ class CompositionBoxInner extends Component<Props, State> {
private renderCompositionView() { private renderCompositionView() {
const { showEmojiPanel } = this.state; const { showEmojiPanel } = this.state;
const { typingEnabled } = this.props; const { typingEnabled } = this.props;
// we can only send a message if the conversation allows writing in it
// - we've got a message body
// - or we've got a staged attachments
const showSendButton =
typingEnabled && (!isEmpty(this.state.draft) || !isEmpty(this.props.stagedAttachments));
/* eslint-disable @typescript-eslint/no-misused-promises */ /* eslint-disable @typescript-eslint/no-misused-promises */
return ( return (
@ -432,7 +439,7 @@ class CompositionBoxInner extends Component<Props, State> {
{typingEnabled && ( {typingEnabled && (
<ToggleEmojiButton ref={this.emojiPanelButton} onClick={this.toggleEmojiPanel} /> <ToggleEmojiButton ref={this.emojiPanelButton} onClick={this.toggleEmojiPanel} />
)} )}
{typingEnabled && <SendMessageButton onClick={this.onSendMessage} />} {showSendButton && <SendMessageButton onClick={this.onSendMessage} />}
{typingEnabled && showEmojiPanel && ( {typingEnabled && showEmojiPanel && (
<StyledEmojiPanelContainer role="button" dir={this.props.htmlDirection}> <StyledEmojiPanelContainer role="button" dir={this.props.htmlDirection}>
<SessionEmojiPanel <SessionEmojiPanel
@ -815,11 +822,10 @@ class CompositionBoxInner extends Component<Props, State> {
return; return;
} }
if (!selectedConversation.isPrivate && selectedConversation.left) { if (
ToastUtils.pushYouLeftTheGroup(); !selectedConversation.isPrivate &&
return; (selectedConversation.left || selectedConversation.isKickedFromGroup)
} ) {
if (!selectedConversation.isPrivate && selectedConversation.isKickedFromGroup) {
ToastUtils.pushYouLeftTheGroup(); ToastUtils.pushYouLeftTheGroup();
return; return;
} }

@ -137,7 +137,7 @@ function formatTimeLeft({ timeLeftMs }: { timeLeftMs: number }) {
const weeks = Math.floor(days / 7); const weeks = Math.floor(days / 7);
const daysLeft = days % 7; const daysLeft = days % 7;
const extraUnit = daysLeft ? ` ${daysLeft}d` : ''; const extraUnit = daysLeft ? ` ${daysLeft}d` : '';
return window.i18n('disappearingMessagesCountdownBig', { time_large: `${weeks}w${extraUnit}` }); return window.i18n('', { time_large: `${weeks}w${extraUnit}` });
} }
return '...'; return '...';

@ -4,6 +4,10 @@ import {
PropsForGroupUpdate, PropsForGroupUpdate,
PropsForGroupUpdateType, PropsForGroupUpdateType,
} from '../../../../state/ducks/conversations'; } from '../../../../state/ducks/conversations';
import {
useSelectedDisplayNameInProfile,
useSelectedNicknameOrProfileNameOrShortenedPubkey,
} from '../../../../state/selectors/selectedConversation';
import { assertUnreachable } from '../../../../types/sqlSharedTypes'; import { assertUnreachable } from '../../../../types/sqlSharedTypes';
import { ExpirableReadableMessage } from './ExpirableReadableMessage'; import { ExpirableReadableMessage } from './ExpirableReadableMessage';
import { NotificationBubble } from './notification-bubble/NotificationBubble'; import { NotificationBubble } from './notification-bubble/NotificationBubble';
@ -25,10 +29,10 @@ const ChangeItemKicked = (kicked: Array<string>): string => {
throw new Error('Group update kicked is missing contacts'); throw new Error('Group update kicked is missing contacts');
} }
const names = useConversationsUsernameWithQuoteOrFullPubkey(kicked); const names = useConversationsUsernameWithQuoteOrFullPubkey(kicked);
const groupName = useSelectedNicknameOrProfileNameOrShortenedPubkey();
if (arrayContainsUsOnly(kicked)) { if (arrayContainsUsOnly(kicked)) {
// TODO - add group name return window.i18n('groupRemovedYou', { group_name: groupName });
return window.i18n('groupRemovedYou', { group_name: '' });
} }
// TODO - support bold // TODO - support bold

@ -46,9 +46,13 @@ export const InteractionNotification = (props: PropsForInteractionNotification)
break; break;
case ConversationInteractionType.Leave: case ConversationInteractionType.Leave:
text = isCommunity text = isCommunity
? window.i18n('communityLeaveError', { community_name: displayName }) ? window.i18n('communityLeaveError', {
community_name: displayName || window.i18n('communityUnknown'),
})
: isGroup : isGroup
? window.i18n('groupLeaveErrorFailed', { group_name: displayName }) ? window.i18n('groupLeaveErrorFailed', {
group_name: displayName || window.i18n('groupUnknown'),
})
: ''; // we cannot fail to do other actions, so not printing anything : ''; // we cannot fail to do other actions, so not printing anything
break; break;
default: default:

@ -1,27 +1,18 @@
import { useConversationUsername } from '../../../../hooks/useParamSelector'; import { useNicknameOrProfileNameOrShortenedPubkey } from '../../../../hooks/useParamSelector';
import { PropsForMessageRequestResponse } from '../../../../models/messageType'; import { PropsForMessageRequestResponse } from '../../../../models/messageType';
import { UserUtils } from '../../../../session/utils'; import { UserUtils } from '../../../../session/utils';
import { Flex } from '../../../basic/Flex'; import { Flex } from '../../../basic/Flex';
import { SpacerSM, Text } from '../../../basic/Text'; import { I18n } from '../../../basic/I18n';
import { SpacerSM, TextWithChildren } from '../../../basic/Text';
import { ReadableMessage } from './ReadableMessage'; import { ReadableMessage } from './ReadableMessage';
// Note this should not respond to the disappearing message conversation setting so we use the ReadableMessage // Note this should not respond to the disappearing message conversation setting so we use the ReadableMessage
export const MessageRequestResponse = (props: PropsForMessageRequestResponse) => { export const MessageRequestResponse = (props: PropsForMessageRequestResponse) => {
const { messageId, isUnread, receivedAt, conversationId } = props; const { messageId, isUnread, receivedAt, conversationId } = props;
const profileName = useConversationUsername(conversationId); const profileName = useNicknameOrProfileNameOrShortenedPubkey(conversationId);
const isFromSync = props.source === UserUtils.getOurPubKeyStrFromCache(); const isFromSync = props.source === UserUtils.getOurPubKeyStrFromCache();
let msgText = '';
if (isFromSync) {
msgText = window.i18n('messageRequestYouHaveAccepted', {
// TODO - check if we can have a better fallback
name: profileName ?? '',
});
} else {
msgText = window.i18n('messageRequestsAccepted');
}
return ( return (
<ReadableMessage <ReadableMessage
messageId={messageId} messageId={messageId}
@ -39,7 +30,18 @@ export const MessageRequestResponse = (props: PropsForMessageRequestResponse) =>
id={`msg-${messageId}`} id={`msg-${messageId}`}
> >
<SpacerSM /> <SpacerSM />
<Text text={msgText} subtle={true} ellipsisOverflow={false} textAlign="center" /> <TextWithChildren subtle={true} ellipsisOverflow={false} textAlign="center">
{isFromSync ? (
<I18n
token="messageRequestYouHaveAccepted"
args={{
name: profileName || window.i18n('unknown'),
}}
/>
) : (
<I18n token="messageRequestsAccepted" />
)}
</TextWithChildren>
</Flex> </Flex>
</ReadableMessage> </ReadableMessage>
); );

@ -1,5 +1,6 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { SessionIcon, SessionIconType } from '../../../../icon'; import { SessionIcon, SessionIconType } from '../../../../icon';
import { SessionHtmlRenderer } from '../../../../basic/SessionHTMLRenderer';
const NotificationBubbleFlex = styled.div` const NotificationBubbleFlex = styled.div`
display: flex; display: flex;
@ -44,7 +45,9 @@ export const NotificationBubble = (props: {
/> />
</NotificationBubbleIconContainer> </NotificationBubbleIconContainer>
)} )}
<NotificationBubbleText>{notificationText}</NotificationBubbleText> <NotificationBubbleText>
<SessionHtmlRenderer html={notificationText} />
</NotificationBubbleText>
{iconType && <NotificationBubbleIconContainer />} {iconType && <NotificationBubbleIconContainer />}
</NotificationBubbleFlex> </NotificationBubbleFlex>
); );

@ -264,8 +264,9 @@ export const OverlayRightPanelSettings = () => {
lastMessage?.interactionStatus === ConversationInteractionStatus.Error lastMessage?.interactionStatus === ConversationInteractionStatus.Error
? window.i18n('conversationsDelete') ? window.i18n('conversationsDelete')
: isKickedFromGroup : isKickedFromGroup
? // TODO - add group name ? window.i18n('groupRemovedYou', {
window.i18n('groupRemovedYou', { group_name: '' }) group_name: selectedUsername || window.i18n('groupUnknown'),
})
: left : left
? window.i18n('groupMemberYouLeft') ? window.i18n('groupMemberYouLeft')
: window.i18n('groupLeave'); : window.i18n('groupLeave');

@ -158,7 +158,7 @@ export const UpdateGroupMembersDialog = (props: Props) => {
const onAdd = (member: string) => { const onAdd = (member: string) => {
if (!weAreAdmin) { if (!weAreAdmin) {
ToastUtils.pushOnlyAdminCanRemove(); window?.log?.warn('Only group admin can add members!');
return; return;
} }
@ -168,8 +168,6 @@ export const UpdateGroupMembersDialog = (props: Props) => {
const onRemove = (member: string) => { const onRemove = (member: string) => {
if (!weAreAdmin) { if (!weAreAdmin) {
window?.log?.warn('Only group admin can remove members!'); window?.log?.warn('Only group admin can remove members!');
ToastUtils.pushOnlyAdminCanRemove();
return; return;
} }
if (convoProps.groupAdmins?.includes(member)) { if (convoProps.groupAdmins?.includes(member)) {

@ -98,10 +98,7 @@ export class UpdateGroupNameDialog extends Component<Props, State> {
public render() { public render() {
const okText = window.i18n('okay'); const okText = window.i18n('okay');
const cancelText = window.i18n('cancel'); const cancelText = window.i18n('cancel');
// TODO: String localization - remove const titleText = window.i18n('groupInformationSet');
const titleText = window.i18n('updateGroupDialogTitle', {
name: this.convo.getRealSessionUsername() ?? window.i18n('unknown'),
});
const errorMsg = this.state.errorMessage; const errorMsg = this.state.errorMessage;
const isAdmin = !this.convo.isPublic(); const isAdmin = !this.convo.isPublic();

@ -59,9 +59,9 @@ export const InteractionItem = (props: InteractionItemProps) => {
let text = storedLastMessageText || ''; let text = storedLastMessageText || '';
let errorText = ''; let errorText = '';
const name = const name = getConversationController()
getConversationController().get(conversationId)?.getNicknameOrRealUsernameOrPlaceholder() || .get(conversationId)
window.i18n('unknown'); ?.getNicknameOrRealUsernameOrPlaceholder();
switch (interactionType) { switch (interactionType) {
case ConversationInteractionType.Hide: case ConversationInteractionType.Hide:
@ -69,7 +69,9 @@ export const InteractionItem = (props: InteractionItemProps) => {
break; break;
case ConversationInteractionType.Leave: case ConversationInteractionType.Leave:
errorText = isCommunity errorText = isCommunity
? window.i18n('communityLeaveError', { community_name: name }) ? window.i18n('communityLeaveError', {
community_name: name || window.i18n('unknown'),
})
: isGroup : isGroup
? window.i18n('groupLeaveErrorFailed', { group_name: name }) ? window.i18n('groupLeaveErrorFailed', { group_name: name })
: ''; // this cannot happen : ''; // this cannot happen

@ -57,10 +57,7 @@ export const SessionNotificationGroupSettings = () => {
} }
Notifications.addPreviewNotification({ Notifications.addPreviewNotification({
conversationId: `preview-notification-${Date.now()}`, conversationId: `preview-notification-${Date.now()}`,
message: message: items.find(m => m.value === initialNotificationEnabled)?.label || 'Message body',
items.find(m => m.value === initialNotificationEnabled)?.label ||
window?.i18n?.('messageBody') ||
'Message body',
title: window.i18n('preview'), title: window.i18n('preview'),
iconUrl: null, iconUrl: null,
isExpiringMessage: false, isExpiringMessage: false,

@ -276,7 +276,9 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string) {
title: isMe ? window.i18n('noteToSelfHide') : window.i18n('conversationsDelete'), title: isMe ? window.i18n('noteToSelfHide') : window.i18n('conversationsDelete'),
message: isMe message: isMe
? window.i18n('noteToSelfHideDescription') ? window.i18n('noteToSelfHideDescription')
: window.i18n('deleteMessagesDescriptionEveryone'), : window.i18n('conversationsDeleteDescription', {
name: conversation.getNicknameOrRealUsernameOrPlaceholder(),
}),
onClickOk, onClickOk,
okText: isMe ? window.i18n('hide') : window.i18n('delete'), okText: isMe ? window.i18n('hide') : window.i18n('delete'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,

@ -120,7 +120,7 @@ const acceptOpenGroupInvitationV2 = (completeUrl: string, roomName?: string) =>
updateConfirmModal({ updateConfirmModal({
title: window.i18n('communityJoin'), title: window.i18n('communityJoin'),
message: window.i18n('communityJoinDescription', { message: window.i18n('communityJoinDescription', {
community_name: roomName ?? window.i18n('unknown'), community_name: roomName || window.i18n('unknown'),
}), }),
onClickOk: async () => { onClickOk: async () => {
await joinOpenGroupV2WithUIEvents(completeUrl, true, false); await joinOpenGroupV2WithUIEvents(completeUrl, true, false);

@ -1337,6 +1337,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (this.isPrivate()) { if (this.isPrivate()) {
return window.i18n('anonymous'); return window.i18n('anonymous');
} }
if (this.isPublic()) {
return window.i18n('communityUnknown');
}
return window.i18n('unknown'); return window.i18n('unknown');
} }

@ -96,7 +96,9 @@ async function joinOpenGroupV2(
if (!conversation) { if (!conversation) {
window?.log?.warn('Failed to join open group v2'); window?.log?.warn('Failed to join open group v2');
// TODO - Check that this is the room name // TODO - Check that this is the room name
throw new Error(window.i18n('groupErrorJoin', { group_name: roomId })); throw new Error(
window.i18n('communityJoinError', { community_name: roomId || window.i18n('unknown') })
);
} }
// here we managed to connect to the group. // here we managed to connect to the group.
@ -182,12 +184,18 @@ export async function joinOpenGroupV2WithUIEvents(
if (showToasts) { if (showToasts) {
// TODO - Check that this is the room name // TODO - Check that this is the room name
ToastUtils.pushToastError( ToastUtils.pushToastError(
'connectToServerFail', 'communityJoinError',
window.i18n('groupErrorJoin', { group_name: parsedRoom.roomId }) window.i18n('communityJoinError', {
community_name: parsedRoom.roomId || window.i18n('unknown'),
})
); );
} }
if (errorHandler) { if (errorHandler) {
errorHandler(window.i18n('groupErrorJoin', { group_name: parsedRoom.roomId })); errorHandler(
window.i18n('communityJoinError', {
community_name: parsedRoom.roomId || window.i18n('unknown'),
})
);
} }
uiCallback?.({ loadingState: 'failed', conversationKey: conversationID }); uiCallback?.({ loadingState: 'failed', conversationKey: conversationID });
@ -196,12 +204,14 @@ export async function joinOpenGroupV2WithUIEvents(
if (showToasts) { if (showToasts) {
// TODO - Check that this is the room name // TODO - Check that this is the room name
ToastUtils.pushToastError( ToastUtils.pushToastError(
'connectToServerFail', 'communityJoinError',
window.i18n('groupErrorJoin', { group_name: 'unknown' }) window.i18n('communityJoinError', { community_name: window.i18n('unknown') })
); );
} }
if (errorHandler) { if (errorHandler) {
errorHandler(window.i18n('groupErrorJoin', { group_name: completeUrl })); // we don't have a parsed room, so let's show the whole url in this case errorHandler(
window.i18n('communityJoinError', { community_name: window.i18n('unknown') })
); // we don't have a parsed room, so let's show the whole url in this case
} }
uiCallback?.({ loadingState: 'failed', conversationKey: null }); uiCallback?.({ loadingState: 'failed', conversationKey: null });
} }

@ -224,7 +224,6 @@ export class OpenGroupManagerV2 {
} catch (e) { } catch (e) {
window?.log?.warn('Failed to join open group v2', e.message); window?.log?.warn('Failed to join open group v2', e.message);
await OpenGroupData.removeV2OpenGroupRoom(conversationId); await OpenGroupData.removeV2OpenGroupRoom(conversationId);
// throw new Error(window.i18n('connectToServerFail'));
return undefined; return undefined;
} }
} }

@ -169,7 +169,7 @@ async function sendToGroupMembers(
window.inboxStore?.dispatch( window.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: window.i18n('groupInviteFailed'), title: window.i18n('groupError'),
message, message,
okText: window.i18n('resend'), okText: window.i18n('resend'),
onClickOk: async () => { onClickOk: async () => {

@ -139,9 +139,6 @@ export function pushedMissedCallCauseOfPermission(conversationName: string) {
); );
} }
export function pushedMissedCallNotApproved(name: string) {
pushToastInfo('missedCall', window.i18n('callsMissedCallFrom', { name }));
}
export function pushVideoCallPermissionNeeded() { export function pushVideoCallPermissionNeeded() {
pushToastInfo( pushToastInfo(
@ -193,10 +190,6 @@ export function pushCannotRemoveCreatorFromGroup() {
pushToastWarning('cannotRemoveCreatorFromGroup', window.i18n('adminCannotBeRemoved')); pushToastWarning('cannotRemoveCreatorFromGroup', window.i18n('adminCannotBeRemoved'));
} }
export function pushOnlyAdminCanRemove() {
pushToastInfo('onlyAdminCanRemoveMembers', window.i18n('onlyAdminCanRemoveMembersDesc'));
}
export function pushFailedToAddAsModerator() { export function pushFailedToAddAsModerator() {
pushToastWarning('failedToAddAsModerator', window.i18n('adminPromotionFailed')); pushToastWarning('failedToAddAsModerator', window.i18n('adminPromotionFailed'));
} }

@ -1296,7 +1296,7 @@ export async function handleMissedCall(
ToastUtils.pushedMissedCall(displayname); ToastUtils.pushedMissedCall(displayname);
break; break;
case 'not-approved': case 'not-approved':
ToastUtils.pushedMissedCallNotApproved(displayname); // no toast for this case
break; break;
case 'too-old-timestamp': case 'too-old-timestamp':
// no toast for this case, the missed call notification is enough // no toast for this case, the missed call notification is enough
@ -1304,7 +1304,9 @@ export async function handleMissedCall(
default: default:
} }
await addMissedCallMessage(sender, incomingOfferTimestamp, details); if (reason !== 'not-approved') {
await addMissedCallMessage(sender, incomingOfferTimestamp, details);
}
} }
async function addMissedCallMessage( async function addMissedCallMessage(

Loading…
Cancel
Save