From 87986914c908b504311863384d90a2be103d9482 Mon Sep 17 00:00:00 2001 From: Ryan Miller Date: Tue, 12 Mar 2024 17:06:44 +1100 Subject: [PATCH] chore: disappearing messages string changes --- .../conversation/TimerNotification.tsx | 62 ++++++++++++------- .../header/ConversationHeaderTitle.tsx | 4 +- .../message-content/MessageReactBar.tsx | 18 ++++-- .../message-content/quote/QuoteText.tsx | 4 +- .../overlay/OverlayRightPanelSettings.tsx | 12 ++-- .../OverlayDisappearingMessages.tsx | 4 +- ts/components/dialog/SessionConfirm.tsx | 6 +- ts/models/conversation.ts | 10 +-- ts/state/selectors/selectedConversation.ts | 14 ++--- 9 files changed, 79 insertions(+), 55 deletions(-) diff --git a/ts/components/conversation/TimerNotification.tsx b/ts/components/conversation/TimerNotification.tsx index 7e5150cd7..e823cb8d0 100644 --- a/ts/components/conversation/TimerNotification.tsx +++ b/ts/components/conversation/TimerNotification.tsx @@ -47,7 +47,10 @@ function useFollowSettingsButtonClick( : window.i18n('timerModeSent'); const message = props.disabled ? window.i18n('followSettingDisabled') - : window.i18n('followSettingTimeAndType', [props.timespanText, mode]); + : window.i18n('followSettingTimeAndType', { + time: props.timespanText, + type: mode, + }); const okText = props.disabled ? window.i18n('confirm') : window.i18n('set'); dispatch( updateConfirmModal({ @@ -148,30 +151,43 @@ function useTextToRender(props: PropsForExpirationTimer) { : window.i18n('timerModeSent'); switch (type) { case 'fromOther': - return disabled - ? window.i18n( - ownSideOnly ? 'theyDisabledTheirDisappearingMessages' : 'disabledDisappearingMessages', - [contact, timespanText] - ) - : mode - ? window.i18n(ownSideOnly ? 'theySetTheirDisappearingMessages' : 'theyChangedTheTimer', [ - contact, - timespanText, - mode, - ]) - : window.i18n('theyChangedTheTimerLegacy', [contact, timespanText]); + if (disabled) { + return ownSideOnly + ? window.i18n('theyDisabledTheirDisappearingMessages', { name: contact }) + : window.i18n('disappearingMessagesTurnedOff', { name: contact }); + } + + if (mode) { + return ownSideOnly + ? window.i18n('theySetTheirDisappearingMessages', { + name: contact, + time: timespanText, + type: mode, + }) + : window.i18n('theyChangedTheTimer', { + name: contact, + time: timespanText, + // TODO: check this mode + mode: '', + }); + } + + return window.i18n('theyChangedTheTimerLegacy', { name: contact, time: timespanText }); + case 'fromMe': case 'fromSync': - return disabled - ? window.i18n( - ownSideOnly ? 'youDisabledYourDisappearingMessages' : 'youDisabledDisappearingMessages' - ) - : mode - ? window.i18n(ownSideOnly ? 'youSetYourDisappearingMessages' : 'youChangedTheTimer', [ - timespanText, - mode, - ]) - : window.i18n('youChangedTheTimerLegacy', [timespanText]); + if (disabled) { + return ownSideOnly + ? window.i18n('youDisabledYourDisappearingMessages') + : window.i18n('disappearingMessagesTurnedOff', { name: contact }); + } + if (mode) { + return ownSideOnly + ? window.i18n('youSetYourDisappearingMessages', { time: timespanText, type: mode }) + : window.i18n('youChangedTheTimer', { time: timespanText, mode }); + } + return window.i18n('youChangedTheTimerLegacy', { time: timespanText }); + default: assertUnreachable(type, `TimerNotification: Missing case error "${type}"`); } diff --git a/ts/components/conversation/header/ConversationHeaderTitle.tsx b/ts/components/conversation/header/ConversationHeaderTitle.tsx index d496b846a..e8d56aa5b 100644 --- a/ts/components/conversation/header/ConversationHeaderTitle.tsx +++ b/ts/components/conversation/header/ConversationHeaderTitle.tsx @@ -61,7 +61,7 @@ export const ConversationHeaderTitle = () => { const { i18n } = window; const notificationSubtitle = useMemo( - () => (notificationSetting ? i18n('notificationSubtitle', [notificationSetting]) : null), + () => (notificationSetting ? i18n('sessionNotifications') : null), [i18n, notificationSetting] ); @@ -77,7 +77,7 @@ export const ConversationHeaderTitle = () => { if (isGroup && memberCount > 0 && !isKickedFromGroup) { const count = String(memberCount); - return isPublic ? i18n('activeMembers', [count]) : i18n('members', [count]); + return i18n(isPublic ? 'activeMembers' : 'members', { count }); } return null; diff --git a/ts/components/conversation/message/message-content/MessageReactBar.tsx b/ts/components/conversation/message/message-content/MessageReactBar.tsx index 2d7d0cad6..b9170ae8f 100644 --- a/ts/components/conversation/message/message-content/MessageReactBar.tsx +++ b/ts/components/conversation/message/message-content/MessageReactBar.tsx @@ -102,22 +102,30 @@ function formatTimeLeft({ timeLeftMs }: { timeLeftMs: number }) { } if (timeLeft.isBefore(moment.utc(0).add(1, 'minute'))) { - return window.i18n('messageWillDisappear', [`${timeLeft.seconds()}s`]); + return window.i18n('messageWillDisappear', { + countAndUnit: `${timeLeft.seconds()}s`, + }); } if (timeLeft.isBefore(moment.utc(0).add(1, 'hour'))) { const extraUnit = timeLeft.seconds() ? ` ${timeLeft.seconds()}s` : ''; - return window.i18n('messageWillDisappear', [`${timeLeft.minutes()}m${extraUnit}`]); + return window.i18n('messageWillDisappear', { + countAndUnit: `${timeLeft.minutes()}m${extraUnit}`, + }); } if (timeLeft.isBefore(moment.utc(0).add(1, 'day'))) { const extraUnit = timeLeft.minutes() ? ` ${timeLeft.minutes()}m` : ''; - return window.i18n('messageWillDisappear', [`${timeLeft.hours()}h${extraUnit}`]); + return window.i18n('messageWillDisappear', { + countAndUnit: `${timeLeft.hours()}h${extraUnit}`, + }); } if (timeLeft.isBefore(moment.utc(0).add(7, 'day'))) { const extraUnit = timeLeft.hours() ? ` ${timeLeft.hours()}h` : ''; - return window.i18n('messageWillDisappear', [`${timeLeft.dayOfYear() - 1}d${extraUnit}`]); + return window.i18n('messageWillDisappear', { + countAndUnit: `${timeLeft.dayOfYear() - 1}d${extraUnit}`, + }); } if (timeLeft.isBefore(moment.utc(0).add(31, 'day'))) { @@ -125,7 +133,7 @@ function formatTimeLeft({ timeLeftMs }: { timeLeftMs: number }) { const weeks = Math.floor(days / 7); const daysLeft = days % 7; const extraUnit = daysLeft ? ` ${daysLeft}d` : ''; - return window.i18n('messageWillDisappear', [`${weeks}w${extraUnit}`]); + return window.i18n('messageWillDisappear', { countAndUnit: `${weeks}w${extraUnit}` }); } return '...'; diff --git a/ts/components/conversation/message/message-content/quote/QuoteText.tsx b/ts/components/conversation/message/message-content/quote/QuoteText.tsx index 9caa40004..9a6dde4c9 100644 --- a/ts/components/conversation/message/message-content/quote/QuoteText.tsx +++ b/ts/components/conversation/message/message-content/quote/QuoteText.tsx @@ -48,7 +48,7 @@ function getTypeLabel({ return window.i18n('image'); } if (MIME.isAudio(contentType) && isVoiceMessage) { - return window.i18n('voiceMessage'); + return window.i18n('messageVoice'); } if (MIME.isAudio(contentType)) { return window.i18n('audio'); @@ -75,7 +75,7 @@ export const QuoteText = ( return ( { {showMemberCount && (
- {window.i18n('members', [`${subscriberCount}`])} + {window.i18n('members', { count: `${subscriberCount}` })}
@@ -259,15 +259,15 @@ export const OverlayRightPanelSettings = () => { const commonNoShow = isKickedFromGroup || left || isBlocked || !isActive; const hasDisappearingMessages = !isPublic && !commonNoShow; const leaveGroupString = isPublic - ? window.i18n('leaveCommunity') + ? window.i18n('communityLeave') : lastMessage?.interactionType === ConversationInteractionType.Leave && lastMessage?.interactionStatus === ConversationInteractionStatus.Error - ? window.i18n('deleteConversation') + ? window.i18n('conversationsDelete') : isKickedFromGroup ? window.i18n('youGotKickedFromGroup') : left - ? window.i18n('youLeftTheGroup') - : window.i18n('leaveGroup'); + ? window.i18n('groupMemberYouLeft') + : window.i18n('groupLeave'); const showUpdateGroupNameButton = isGroup && weAreAdmin && !commonNoShow; // legacy groups non-admin cannot change groupname anymore const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic; @@ -285,7 +285,7 @@ export const OverlayRightPanelSettings = () => { {showUpdateGroupNameButton && ( { void showUpdateGroupNameByConvoId(selectedConvoKey); }} diff --git a/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx b/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx index 8c50402d7..79dc0903c 100644 --- a/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx +++ b/ts/components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages.tsx @@ -208,9 +208,9 @@ export const OverlayDisappearingMessages = () => { <> - {window.i18n('settingAppliesToEveryone')} + {window.i18n('disappearingMessagesDescription')}
- {window.i18n('onlyGroupAdminsCanChange')} + {window.i18n('disappearingMessagesOnlyAdmins')}
)} diff --git a/ts/components/dialog/SessionConfirm.tsx b/ts/components/dialog/SessionConfirm.tsx index 550c8439e..1177765be 100644 --- a/ts/components/dialog/SessionConfirm.tsx +++ b/ts/components/dialog/SessionConfirm.tsx @@ -217,11 +217,11 @@ export const showLinkVisitWarningDialog = (urlToOpen: string, dispatch: Dispatch dispatch( updateConfirmModal({ - title: window.i18n('linkVisitWarningTitle'), - message: window.i18n('linkVisitWarningMessage', [urlToOpen]), + title: window.i18n('urlOpen'), + message: window.i18n('urlOpenDescription', { url: urlToOpen }), okText: window.i18n('open'), okTheme: SessionButtonColor.Primary, - cancelText: window.i18n('editMenuCopy'), + cancelText: window.i18n('copy'), showExitIcon: true, onClickOk, onClickClose: () => { diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index e6d84d3f9..3cd2a28f9 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1681,7 +1681,7 @@ export class ConversationModel extends Backbone.Model { const pubkey = this.id; if (UserUtils.isUsFromCache(pubkey)) { - return window.i18n('you'); + return window.i18n('onionRoutingPathYou'); } const profileName = this.get('displayNameInProfile'); @@ -1741,7 +1741,7 @@ export class ConversationModel extends Backbone.Model { const isFirstMessageOfConvo = (await Data.getMessagesByConversation(this.id, { messageId: null })).messages.length === 1; if (hadNoRequestsPrior && isFirstMessageOfConvo) { - friendRequestText = window.i18n('youHaveANewFriendRequest'); + friendRequestText = window.i18n('messageRequestsNew'); } else { window?.log?.info( 'notification cancelled for as pending requests already exist', @@ -1825,9 +1825,9 @@ export class ConversationModel extends Backbone.Model { conversationId, iconUrl, isExpiringMessage: false, - message: window.i18n('incomingCallFrom', [ - this.getNicknameOrRealUsername() || window.i18n('anonymous'), - ]), + message: window.i18n('callsIncoming', { + name: this.getNicknameOrRealUsername() || window.i18n('anonymous'), + }), messageSentAt: now, title: this.getNicknameOrRealUsernameOrPlaceholder(), }); diff --git a/ts/state/selectors/selectedConversation.ts b/ts/state/selectors/selectedConversation.ts index f6a118272..d064c582c 100644 --- a/ts/state/selectors/selectedConversation.ts +++ b/ts/state/selectors/selectedConversation.ts @@ -26,14 +26,13 @@ const getCurrentNotificationSettingText = (state: StateType): string | undefined } const currentNotificationSetting = getSelectedConversation(state)?.currentNotificationSetting; switch (currentNotificationSetting) { - case 'all': - return window.i18n('notificationForConvo_all'); case 'mentions_only': - return window.i18n('notificationForConvo_mentions_only'); - case 'disabled': - return window.i18n('notificationForConvo_disabled'); - default: - return window.i18n('notificationForConvo_all'); + return window.i18n('notificationsMentionsOnly'); + case 'disabled': + return window.i18n('notificationsMute'); + case 'all': + default: + return window.i18n('notificationsAllMessages'); } }; @@ -347,6 +346,7 @@ export function useSelectedShortenedPubkeyOrFallback() { if (isPrivate) { return window.i18n('anonymous'); } + // TODO: String localization - remove return window.i18n('unknown'); }