diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7fc305a6ac11..cb1ba6eaea0e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -3093,7 +3093,7 @@ }, "Reactions--remove": { "message": "Remove reaction", - "describe": "Shown when you want to remove a reaction you've made" + "description": "Shown when you want to remove a reaction you've made" }, "Reactions--error": { "message": "Failed to send reaction. Please try again.", @@ -3152,7 +3152,7 @@ "description": "Shown in a toast when you successfully block a user and report them as spam" }, "MessageRequests--block-direct-confirm-title": { - "message": "Block $name$?", + "message": "Block $title$?", "description": "Shown as the title in the confirmation modal for blocking a private message request" }, "MessageRequests--block-direct-confirm-body": { @@ -3160,7 +3160,7 @@ "description": "Shown as the body in the confirmation modal for blocking a private message request" }, "MessageRequests--block-group-confirm-title": { - "message": "Block and Leave $group$?", + "message": "Block and Leave $title$?", "description": "Shown as the title in the confirmation modal for blocking a group message request" }, "MessageRequests--block-group-confirm-body": { @@ -3180,7 +3180,7 @@ "description": "Shown as the body in the confirmation modal for deleting a private message request" }, "MessageRequests--delete-group-confirm-title": { - "message": "Delete and Leave $group$?", + "message": "Delete and Leave $title$?", "description": "Shown as the title in the confirmation modal for deleting a group message request" }, "MessageRequests--delete-direct": { @@ -6021,11 +6021,11 @@ }, "icu:GroupStorySettingsModal__remove_group": { "messageformat": "Remove group story", - "descirption": "Stories settings > Group Story > button to remove group story" + "description": "Stories settings > Group Story > button to remove group story" }, "icu:StoriesSettings__remove_group--confirm": { "messageformat": "Are you sure you want to remove “{groupTitle}”?", - "descirption": "Stories settings > Group Story > confirm to remove group story" + "description": "Stories settings > Group Story > confirm to remove group story" }, "SendStoryModal__choose-who-can-view": { "message": "Choose who can view your story", @@ -6279,10 +6279,6 @@ "message": "Can’t download story. You will need to share it again.", "description": "Description for image errors but when it is your own image" }, - "StoryCreator__error--video-too-long": { - "message": "Cannot post video to story because it is too long", - "description": "(deleted 02/22/2023) Error string for when a video post to story fails" - }, "StoryCreator__error--video-unsupported": { "message": "Cannot post video to story as it is an unsupported file format", "description": "Error string for when a video post to story fails" diff --git a/ts/components/AddCaptionModal.tsx b/ts/components/AddCaptionModal.tsx index 71bd4614dea7..4994cde2167f 100644 --- a/ts/components/AddCaptionModal.tsx +++ b/ts/components/AddCaptionModal.tsx @@ -63,7 +63,7 @@ export function AddCaptionModal({ hasFooterDivider={!isScrolledBottom} moduleClassName="AddCaptionModal" padded={false} - title="Add a message" + title={i18n('AddCaptionModal__title')} onClose={onClose} modalFooter={ , - ]} + components={{ + admins: ( + + ), + }} /> diff --git a/ts/components/Avatar.tsx b/ts/components/Avatar.tsx index 4b22c55583f7..4325ee892f31 100644 --- a/ts/components/Avatar.tsx +++ b/ts/components/Avatar.tsx @@ -283,7 +283,9 @@ export function Avatar({ return (
]} + components={{ + title: , + }} />

diff --git a/ts/components/CallScreen.tsx b/ts/components/CallScreen.tsx index c6b3f5e4ace8..4363af204b34 100644 --- a/ts/components/CallScreen.tsx +++ b/ts/components/CallScreen.tsx @@ -118,7 +118,13 @@ function DirectCallHeaderMessage({ return <>{i18n('callReconnecting')}; } if (callState === CallState.Accepted && acceptedDuration) { - return <>{i18n('callDuration', [renderDuration(acceptedDuration)])}; + return ( + <> + {i18n('callDuration', { + duration: renderDuration(acceptedDuration), + })} + + ); } return null; } @@ -312,9 +318,9 @@ export function CallScreen({ if (isRinging) { headerTitle = undefined; } else if (currentPresenter) { - headerTitle = i18n('calling__presenting--person-ongoing', [ - currentPresenter.title, - ]); + headerTitle = i18n('calling__presenting--person-ongoing', { + name: currentPresenter.title, + }); } else if (!activeCall.remoteParticipants.length) { headerTitle = i18n('calling__in-this-call--zero'); } diff --git a/ts/components/CallingHeader.tsx b/ts/components/CallingHeader.tsx index 39bbe964902a..833f9b3360df 100644 --- a/ts/components/CallingHeader.tsx +++ b/ts/components/CallingHeader.tsx @@ -49,15 +49,15 @@ export function CallingHeader({ {isGroupCall && participantCount ? (
} diff --git a/ts/components/GroupV2JoinDialog.tsx b/ts/components/GroupV2JoinDialog.tsx index 90e5a9655a2e..85ad9fc57d89 100644 --- a/ts/components/GroupV2JoinDialog.tsx +++ b/ts/components/GroupV2JoinDialog.tsx @@ -93,7 +93,9 @@ export const GroupV2JoinDialog = React.memo(function GroupV2JoinDialogInner(
{title}
- {i18n('GroupV2--join--group-metadata', [memberString])} + {i18n('GroupV2--join--group-metadata', { + memberCount: memberString, + })}
{groupDescription && (
diff --git a/ts/components/Inbox.tsx b/ts/components/Inbox.tsx index 53b160dc0ba0..6a40bd398f3a 100644 --- a/ts/components/Inbox.tsx +++ b/ts/components/Inbox.tsx @@ -188,7 +188,9 @@ export function Inbox({
{loadingMessageCount - ? i18n('loadingMessages', [String(loadingMessageCount)]) + ? i18n('loadingMessages', { + count: String(loadingMessageCount), + }) : i18n('loading')}
diff --git a/ts/components/Intl.stories.tsx b/ts/components/Intl.stories.tsx index e7a79249a9f0..738460d541da 100644 --- a/ts/components/Intl.stories.tsx +++ b/ts/components/Intl.stories.tsx @@ -35,17 +35,19 @@ NoReplacements.args = createProps({ export const SingleStringReplacement = Template.bind({}); SingleStringReplacement.args = createProps({ id: 'leftTheGroup', - components: ['Theodora'], + components: { name: 'Theodora' }, }); export const SingleTagReplacement = Template.bind({}); SingleTagReplacement.args = createProps({ id: 'leftTheGroup', - components: [ - , - ], + components: { + name: ( + + ), + }, }); export const MultipleStringReplacement = Template.bind({}); diff --git a/ts/components/Intl.tsx b/ts/components/Intl.tsx index 53ccf7ada863..2604c653fde7 100644 --- a/ts/components/Intl.tsx +++ b/ts/components/Intl.tsx @@ -16,10 +16,7 @@ export type FullJSXType = | ReactNode | JSX.Element | string; -export type IntlComponentsType = - | undefined - | Array - | ReplacementValuesType; +export type IntlComponentsType = undefined | ReplacementValuesType; export type Props = { /** The translation string id */ diff --git a/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx b/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx index e2e902d3b08a..dddebc91b5e9 100644 --- a/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx +++ b/ts/components/NewlyCreatedGroupInvitedContactsDialog.tsx @@ -39,7 +39,7 @@ export function NewlyCreatedGroupInvitedContactsDialog({ ]} + components={{ name: }} /> @@ -48,9 +48,9 @@ export function NewlyCreatedGroupInvitedContactsDialog({ ); } else { - title = i18n('NewlyCreatedGroupInvitedContactsDialog--title--many', [ - contacts.length.toString(), - ]); + title = i18n('NewlyCreatedGroupInvitedContactsDialog--title--many', { + count: contacts.length.toString(), + }); body = ( <> diff --git a/ts/components/Preferences.tsx b/ts/components/Preferences.tsx index 05d2af128aea..bfee4d2c3943 100644 --- a/ts/components/Preferences.tsx +++ b/ts/components/Preferences.tsx @@ -874,12 +874,12 @@ export function Preferences({ left={i18n('Preferences--blocked')} right={ blockedCount === 1 - ? i18n('Preferences--blocked-count-singular', [ - String(blockedCount), - ]) - : i18n('Preferences--blocked-count-plural', [ - String(blockedCount || 0), - ]) + ? i18n('Preferences--blocked-count-singular', { + num: String(blockedCount), + }) + : i18n('Preferences--blocked-count-plural', { + num: String(blockedCount || 0), + }) } /> diff --git a/ts/components/SafetyNumberViewer.tsx b/ts/components/SafetyNumberViewer.tsx index d6b9fe59c56d..be2bd4cb38d2 100644 --- a/ts/components/SafetyNumberViewer.tsx +++ b/ts/components/SafetyNumberViewer.tsx @@ -73,7 +73,7 @@ export function SafetyNumberViewer({
{safetyNumber || getPlaceholder()}
- +
{isVerified ? ( @@ -81,9 +81,13 @@ export function SafetyNumberViewer({ )} {isVerified ? ( - + ) : ( - + )}
diff --git a/ts/components/SendStoryModal.tsx b/ts/components/SendStoryModal.tsx index 18db37a357a6..5288973ff28e 100644 --- a/ts/components/SendStoryModal.tsx +++ b/ts/components/SendStoryModal.tsx @@ -996,9 +996,9 @@ export function SendStoryModal({ }} theme={Theme.Dark} > - {i18n('StoriesSettings__delete-list--confirm', [ - confirmDeleteList.name, - ])} + {i18n('StoriesSettings__delete-list--confirm', { + name: confirmDeleteList.name, + })} )} {confirmDiscardModal} diff --git a/ts/components/StoriesSettingsModal.tsx b/ts/components/StoriesSettingsModal.tsx index 72badd5d9096..7ca3a4ac5050 100644 --- a/ts/components/StoriesSettingsModal.tsx +++ b/ts/components/StoriesSettingsModal.tsx @@ -507,9 +507,9 @@ export function StoriesSettingsModal({ }} theme={Theme.Dark} > - {i18n('StoriesSettings__delete-list--confirm', [ - confirmDeleteList.name, - ])} + {i18n('StoriesSettings__delete-list--confirm', { + name: confirmDeleteList.name, + })} )} {confirmRemoveGroup != null && ( @@ -687,9 +687,9 @@ export function DistributionListSettingsModal({
{attachment && ( @@ -259,11 +261,13 @@ export function StoryDetailsModal({ - {formatFileSize(attachment.size)} - , - ]} + components={{ + size: ( + + {formatFileSize(attachment.size)} + + ), + }} />
)} @@ -272,13 +276,15 @@ export function StoryDetailsModal({ - {formatRelativeTime(i18n, timeRemaining, { - largest: 2, - })} - , - ]} + components={{ + countdown: ( + + {formatRelativeTime(i18n, timeRemaining, { + largest: 2, + })} + + ), + }} /> )} diff --git a/ts/components/StoryImage.tsx b/ts/components/StoryImage.tsx index d81d20182ca3..a3879b5c2c38 100644 --- a/ts/components/StoryImage.tsx +++ b/ts/components/StoryImage.tsx @@ -158,7 +158,13 @@ export function StoryImage({ if (isMe) { content = <>{i18n('StoryImage__error--you')}; } else { - content = <>{i18n('StoryImage__error2', [firstName])}; + content = ( + <> + {i18n('StoryImage__error2', { + name: firstName, + })} + + ); } } diff --git a/ts/components/StoryLinkPreview.tsx b/ts/components/StoryLinkPreview.tsx index 9f58b907ed99..f66b888e869c 100644 --- a/ts/components/StoryLinkPreview.tsx +++ b/ts/components/StoryLinkPreview.tsx @@ -73,7 +73,9 @@ export function StoryLinkPreview({ {isImage && image ? (
{i18n('stagedPreviewThumbnail', - {i18n('StoryListItem__hide-modal--body', [String(firstName)])} + {i18n('StoryListItem__hide-modal--body', { + name: String(firstName), + })} )} diff --git a/ts/components/StoryViewer.tsx b/ts/components/StoryViewer.tsx index 18b6b26cd17e..05ed79314496 100644 --- a/ts/components/StoryViewer.tsx +++ b/ts/components/StoryViewer.tsx @@ -857,13 +857,13 @@ export function StoryViewer({ {viewCount}]} + components={{ num: {viewCount} }} /> ) : ( {viewCount}]} + components={{ num: {viewCount} }} /> ))} {(isSent || viewCount > 0) && replyCount > 0 && ' '} @@ -872,13 +872,13 @@ export function StoryViewer({ {replyCount}]} + components={{ num: {replyCount} }} /> ) : ( {replyCount}]} + components={{ num: {replyCount} }} /> ))} @@ -978,7 +978,9 @@ export function StoryViewer({ setHasConfirmHideStory(false); }} > - {i18n('StoryListItem__hide-modal--body', [String(firstName)])} + {i18n('StoryListItem__hide-modal--body', { + name: String(firstName), + })} )} {confirmDeleteStory && ( diff --git a/ts/components/WhatsNewLink.tsx b/ts/components/WhatsNewLink.tsx index 30eba5688533..86f1b7664ffb 100644 --- a/ts/components/WhatsNewLink.tsx +++ b/ts/components/WhatsNewLink.tsx @@ -19,11 +19,17 @@ export function WhatsNewLink(props: PropsType): JSX.Element { - {i18n('viewReleaseNotes')} - , - ]} + components={{ + whatsNew: ( + + ), + }} /> ); } diff --git a/ts/components/conversation/AttachmentList.tsx b/ts/components/conversation/AttachmentList.tsx index 946e673f0b46..77dfe92befc1 100644 --- a/ts/components/conversation/AttachmentList.tsx +++ b/ts/components/conversation/AttachmentList.tsx @@ -102,9 +102,9 @@ export function AttachmentList({ const imgElement = ( {i18n('stagedImageAttachment', { onSendMessage, }: { hasSignalAccount: boolean; - i18n: (key: string, values?: Array) => string; + i18n: LocalizerType; onSendMessage: () => void; }): JSX.Element | null { if (!hasSignalAccount) { diff --git a/ts/components/conversation/ContactModal.tsx b/ts/components/conversation/ContactModal.tsx index 3fc8b5415c63..2fb16266582c 100644 --- a/ts/components/conversation/ContactModal.tsx +++ b/ts/components/conversation/ContactModal.tsx @@ -125,8 +125,12 @@ export function ContactModal({ onClose={() => setSubModalState(SubModalState.None)} > {isAdmin - ? i18n('ContactModal--rm-admin-info', [contact.title]) - : i18n('ContactModal--make-admin-info', [contact.title])} + ? i18n('ContactModal--rm-admin-info', { + contact: contact.title, + }) + : i18n('ContactModal--make-admin-info', { + contact: contact.title, + })} ); break; diff --git a/ts/components/conversation/ContactSpoofingReviewDialog.tsx b/ts/components/conversation/ContactSpoofingReviewDialog.tsx index c78bbf1dd71f..584e964f1aea 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialog.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialog.tsx @@ -250,9 +250,9 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element { contents = ( <>

- {i18n('ContactSpoofingReviewDialog__group__description', [ - conversationInfos.length.toString(), - ])} + {i18n('ContactSpoofingReviewDialog__group__description', { + count: conversationInfos.length.toString(), + })}

{i18n('ContactSpoofingReviewDialog__group__members-header')}

{conversationInfos.map((conversationInfo, index) => { diff --git a/ts/components/conversation/GroupNotification.tsx b/ts/components/conversation/GroupNotification.tsx index 0dd6ac07544b..110ee71ff20e 100644 --- a/ts/components/conversation/GroupNotification.tsx +++ b/ts/components/conversation/GroupNotification.tsx @@ -66,7 +66,11 @@ export class GroupNotification extends React.Component { switch (type) { case 'name': return ( - + ); case 'avatar': return ; @@ -83,13 +87,13 @@ export class GroupNotification extends React.Component { ) : ( )} @@ -114,13 +118,13 @@ export class GroupNotification extends React.Component { ) : ( ); case 'general': @@ -147,7 +151,7 @@ export class GroupNotification extends React.Component { ]} + components={{ name: }} /> ); diff --git a/ts/components/conversation/GroupV1Migration.tsx b/ts/components/conversation/GroupV1Migration.tsx index e40cefb1fdc9..0e447820130e 100644 --- a/ts/components/conversation/GroupV1Migration.tsx +++ b/ts/components/conversation/GroupV1Migration.tsx @@ -118,11 +118,19 @@ function renderUsers( ]} + components={{ + contact: , + }} />

); } - return

{i18n(`${keyPrefix}--many`, [members.length.toString()])}

; + return ( +

+ {i18n(`${keyPrefix}--many`, { + count: members.length.toString(), + })} +

+ ); } diff --git a/ts/components/conversation/GroupV2Change.tsx b/ts/components/conversation/GroupV2Change.tsx index 7f37be0ffd7e..b81e9b8f9f3d 100644 --- a/ts/components/conversation/GroupV2Change.tsx +++ b/ts/components/conversation/GroupV2Change.tsx @@ -55,7 +55,7 @@ export type PropsType = PropsDataType & function renderStringToIntl( id: string, i18n: LocalizerType, - components?: Array | ReplacementValuesType + components?: ReplacementValuesType ): FullJSXType { // eslint-disable-next-line local-rules/valid-i18n-keys return ; diff --git a/ts/components/conversation/LastSeenIndicator.tsx b/ts/components/conversation/LastSeenIndicator.tsx index 82958cac6e6b..bb7dfcaa7cad 100644 --- a/ts/components/conversation/LastSeenIndicator.tsx +++ b/ts/components/conversation/LastSeenIndicator.tsx @@ -15,7 +15,9 @@ export const LastSeenIndicator = forwardRef( const message = count === 1 ? i18n('unreadMessage') - : i18n('unreadMessages', [String(count)]); + : i18n('unreadMessages', { + count: String(count), + }); return (
diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index daed46acef64..56e76913fdb1 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -1162,7 +1162,9 @@ export class Message extends React.PureComponent { curveBottomRight={CurveType.Tiny} curveTopRight={CurveType.Tiny} curveTopLeft={CurveType.Tiny} - alt={i18n('previewThumbnail', [first.domain])} + alt={i18n('previewThumbnail', { + domain: first.domain, + })} height={72} width={72} url={first.image.url} @@ -1536,7 +1538,9 @@ export class Message extends React.PureComponent { <> {storyReplyContext.emoji && (
- {i18n('Quote__story-reaction', [storyReplyContext.authorTitle])} + {i18n('Quote__story-reaction', { + name: storyReplyContext.authorTitle, + })}
)} - - , - ]} + components={{ + name: ( + + + + ), + }} />

diff --git a/ts/components/conversation/MessageRequestActionsConfirmation.tsx b/ts/components/conversation/MessageRequestActionsConfirmation.tsx index 3dbfb291a7da..5d50af521ab9 100644 --- a/ts/components/conversation/MessageRequestActionsConfirmation.tsx +++ b/ts/components/conversation/MessageRequestActionsConfirmation.tsx @@ -52,7 +52,9 @@ export function MessageRequestActionsConfirmation({ ]} + components={{ + title: , + }} /> } actions={[ @@ -119,7 +121,9 @@ export function MessageRequestActionsConfirmation({ ]} + components={{ + title: , + }} /> } actions={[ diff --git a/ts/components/conversation/SafetyNumberNotification.tsx b/ts/components/conversation/SafetyNumberNotification.tsx index 52658c824d32..c72281bac280 100644 --- a/ts/components/conversation/SafetyNumberNotification.tsx +++ b/ts/components/conversation/SafetyNumberNotification.tsx @@ -46,17 +46,19 @@ export function SafetyNumberNotification({ // eslint-disable-next-line local-rules/valid-i18n-keys - - , - ]} + components={{ + name: ( + + + + ), + }} i18n={i18n} /> } diff --git a/ts/components/conversation/StagedLinkPreview.tsx b/ts/components/conversation/StagedLinkPreview.tsx index 50f8bcea653a..cf73676c5431 100644 --- a/ts/components/conversation/StagedLinkPreview.tsx +++ b/ts/components/conversation/StagedLinkPreview.tsx @@ -86,7 +86,9 @@ export function StagedLinkPreview({ {isLoaded && image && isImage && domain ? (
{i18n('stagedPreviewThumbnail', - - , - ]} + components={{ + contact: ( + + + + ), + }} i18n={i18n} /> } diff --git a/ts/components/conversation/VerificationNotification.tsx b/ts/components/conversation/VerificationNotification.tsx index 4f3d2cbc129a..99ceb531484f 100644 --- a/ts/components/conversation/VerificationNotification.tsx +++ b/ts/components/conversation/VerificationNotification.tsx @@ -50,13 +50,15 @@ export class VerificationNotification extends React.Component { // eslint-disable-next-line local-rules/valid-i18n-keys , - ]} + components={{ + name: ( + + ), + }} i18n={i18n} /> ); diff --git a/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx b/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx index d4f6d3bf52ae..5491dbfea47f 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx @@ -201,9 +201,9 @@ export function ConversationDetailsActions({ ]} i18n={i18n} onClose={() => gGroupBlock(false)} - title={i18n('ConversationDetailsActions--block-group-modal-title', [ - conversationTitle, - ])} + title={i18n('ConversationDetailsActions--block-group-modal-title', { + groupName: conversationTitle, + })} > {i18n('ConversationDetailsActions--block-group-modal-content')} @@ -222,9 +222,9 @@ export function ConversationDetailsActions({ ]} i18n={i18n} onClose={() => gGroupUnblock(false)} - title={i18n('ConversationDetailsActions--unblock-group-modal-title', [ - conversationTitle, - ])} + title={i18n('ConversationDetailsActions--unblock-group-modal-title', { + groupName: conversationTitle, + })} > {i18n('ConversationDetailsActions--unblock-group-modal-content')} @@ -242,9 +242,9 @@ export function ConversationDetailsActions({ ]} i18n={i18n} onClose={() => gDirectBlock(false)} - title={i18n('MessageRequests--block-direct-confirm-title', [ - conversationTitle, - ])} + title={i18n('MessageRequests--block-direct-confirm-title', { + name: conversationTitle, + })} > {i18n('MessageRequests--block-direct-confirm-body')} @@ -261,9 +261,9 @@ export function ConversationDetailsActions({ ]} i18n={i18n} onClose={() => gDirectUnblock(false)} - title={i18n('MessageRequests--unblock-direct-confirm-title', [ - conversationTitle, - ])} + title={i18n('MessageRequests--unblock-direct-confirm-title', { + name: conversationTitle, + })} > {i18n('MessageRequests--unblock-direct-confirm-body')} diff --git a/ts/components/conversation/conversation-details/ConversationDetailsHeader.tsx b/ts/components/conversation/conversation-details/ConversationDetailsHeader.tsx index 3ddaa65a6ced..ea8daf18056f 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsHeader.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsHeader.tsx @@ -66,9 +66,9 @@ export function ConversationDetailsHeader({ } else if (canEdit) { subtitle = i18n('ConversationDetailsHeader--add-group-description'); } else { - subtitle = i18n('ConversationDetailsHeader--members', [ - memberships.length.toString(), - ]); + subtitle = i18n('ConversationDetailsHeader--members', { + number: memberships.length.toString(), + }); } } else if (!isMe) { subtitle = ( diff --git a/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.tsx b/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.tsx index 55f022e92d03..197caa3814a8 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.tsx @@ -93,9 +93,9 @@ export function ConversationDetailsMembershipList({ return ( {canAddNewMembers && ( ))}
- {i18n('PendingRequests--info', [conversation.title])} + {i18n('PendingRequests--info', { + name: conversation.title, + })}
); @@ -501,9 +503,9 @@ function MembersPendingProfileKey({ /> } label={member.title} - right={i18n('PendingInvites--invited-count', [ - pendingMemberships.length.toString(), - ])} + right={i18n('PendingInvites--invited-count', { + number: pendingMemberships.length.toString(), + })} actions={ conversation.areWeAdmin ? ( = } else if (isCheckbox) { let ariaLabel: string; if (disabled) { - ariaLabel = i18n('cannotSelectContact', [title]); + ariaLabel = i18n('cannotSelectContact', { + name: title, + }); } else if (checked) { - ariaLabel = i18n('deselectContact', [title]); + ariaLabel = i18n('deselectContact', { + name: title, + }); } else { - ariaLabel = i18n('selectContact', [title]); + ariaLabel = i18n('selectContact', { + name: title, + }); } actionNode = (
diff --git a/ts/components/emoji/EmojiPicker.tsx b/ts/components/emoji/EmojiPicker.tsx index 610b3a575524..17189eae481d 100644 --- a/ts/components/emoji/EmojiPicker.tsx +++ b/ts/components/emoji/EmojiPicker.tsx @@ -480,7 +480,9 @@ export const EmojiPicker = React.memo( handlePickTone(event); } }} - title={i18n('EmojiPicker--skin-tone', [`${tone}`])} + title={i18n('EmojiPicker--skin-tone', { + tone: `${tone}`, + })} className={classNames( 'module-emoji-picker__button', 'module-emoji-picker__button--footer', diff --git a/ts/components/leftPane/LeftPaneSearchHelper.tsx b/ts/components/leftPane/LeftPaneSearchHelper.tsx index e16aa937dcfb..309825ab5620 100644 --- a/ts/components/leftPane/LeftPaneSearchHelper.tsx +++ b/ts/components/leftPane/LeftPaneSearchHelper.tsx @@ -161,7 +161,11 @@ export class LeftPaneSearchHelper extends LeftPaneHelper -
{i18n('noSearchResults', [searchTerm])}
+
+ {i18n('noSearchResults', { + searchTerm, + })} +
{primarySendsSms && (
{i18n('noSearchResults--sms-only')} diff --git a/ts/groupChange.ts b/ts/groupChange.ts index f3a0b6fc6d18..73d25c0b41c7 100644 --- a/ts/groupChange.ts +++ b/ts/groupChange.ts @@ -14,7 +14,7 @@ export type SmartContactRendererType = (uuid: UUIDStringType) => T | string; export type StringRendererType = ( id: string, i18n: LocalizerType, - components?: Array | ReplacementValuesType + components?: ReplacementValuesType ) => T | string; export type RenderOptionsType = { @@ -93,7 +93,7 @@ export function renderChangeDetail( if (newTitle) { if (fromYou) { - return renderString('GroupV2--title--change--you', i18n, [newTitle]); + return renderString('GroupV2--title--change--you', i18n, { newTitle }); } if (from) { return renderString('GroupV2--title--change--other', i18n, { @@ -101,15 +101,17 @@ export function renderChangeDetail( newTitle, }); } - return renderString('GroupV2--title--change--unknown', i18n, [newTitle]); + return renderString('GroupV2--title--change--unknown', i18n, { + newTitle, + }); } if (fromYou) { return renderString('GroupV2--title--remove--you', i18n); } if (from) { - return renderString('GroupV2--title--remove--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--title--remove--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--title--remove--unknown', i18n); } @@ -119,9 +121,9 @@ export function renderChangeDetail( return renderString('GroupV2--avatar--remove--you', i18n); } if (from) { - return renderString('GroupV2--avatar--remove--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--avatar--remove--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--avatar--remove--unknown', i18n); } @@ -129,9 +131,9 @@ export function renderChangeDetail( return renderString('GroupV2--avatar--change--you', i18n); } if (from) { - return renderString('GroupV2--avatar--change--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--avatar--change--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--avatar--change--unknown', i18n); } @@ -143,9 +145,9 @@ export function renderChangeDetail( return renderString('GroupV2--access-attributes--admins--you', i18n); } if (from) { - return renderString('GroupV2--access-attributes--admins--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--access-attributes--admins--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--access-attributes--admins--unknown', i18n); } @@ -154,9 +156,9 @@ export function renderChangeDetail( return renderString('GroupV2--access-attributes--all--you', i18n); } if (from) { - return renderString('GroupV2--access-attributes--all--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--access-attributes--all--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--access-attributes--all--unknown', i18n); } @@ -173,9 +175,9 @@ export function renderChangeDetail( return renderString('GroupV2--access-members--admins--you', i18n); } if (from) { - return renderString('GroupV2--access-members--admins--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--access-members--admins--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--access-members--admins--unknown', i18n); } @@ -184,9 +186,9 @@ export function renderChangeDetail( return renderString('GroupV2--access-members--all--you', i18n); } if (from) { - return renderString('GroupV2--access-members--all--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--access-members--all--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--access-members--all--unknown', i18n); } @@ -206,7 +208,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--access-invite-link--enabled--other', i18n, - [renderContact(from)] + { adminName: renderContact(from) } ); } return renderString( @@ -222,7 +224,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--access-invite-link--disabled--other', i18n, - [renderContact(from)] + { adminName: renderContact(from) } ); } return renderString( @@ -244,16 +246,16 @@ export function renderChangeDetail( return renderString('GroupV2--member-add--you--you', i18n); } if (from) { - return renderString('GroupV2--member-add--you--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--member-add--you--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--member-add--you--unknown', i18n); } if (fromYou) { - return renderString('GroupV2--member-add--other--you', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--member-add--other--you', i18n, { + memberName: renderContact(uuid), + }); } if (from) { return renderString('GroupV2--member-add--other--other', i18n, { @@ -261,9 +263,9 @@ export function renderChangeDetail( addeeName: renderContact(uuid), }); } - return renderString('GroupV2--member-add--other--unknown', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--member-add--other--unknown', i18n, { + memberName: renderContact(uuid), + }); } if (detail.type === 'member-add-from-invite') { const { uuid, inviter } = detail; @@ -274,9 +276,9 @@ export function renderChangeDetail( if (weAreJoiner) { // They can't be the same, no fromYou check here if (from) { - return renderString('GroupV2--member-add--you--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--member-add--you--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--member-add--you--unknown', i18n); } @@ -299,9 +301,9 @@ export function renderChangeDetail( if (weAreJoiner) { if (inviter) { - return renderString('GroupV2--member-add--from-invite--you', i18n, [ - renderContact(inviter), - ]); + return renderString('GroupV2--member-add--from-invite--you', i18n, { + inviterName: renderContact(inviter), + }); } return renderString( 'GroupV2--member-add--from-invite--you-no-from', @@ -309,9 +311,9 @@ export function renderChangeDetail( ); } if (weAreInviter) { - return renderString('GroupV2--member-add--from-invite--from-you', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--member-add--from-invite--from-you', i18n, { + inviteeName: renderContact(uuid), + }); } if (inviter) { return renderString('GroupV2--member-add--from-invite--other', i18n, { @@ -334,17 +336,17 @@ export function renderChangeDetail( return renderString('GroupV2--member-add-from-link--you--you', i18n); } if (from && uuid === from) { - return renderString('GroupV2--member-add-from-link--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--member-add-from-link--other', i18n, { + memberName: renderContact(from), + }); } // Note: this shouldn't happen, because we only capture 'add-from-link' status // from group change events, which always have a sender. log.warn('member-add-from-link change type; we have no from!'); - return renderString('GroupV2--member-add--other--unknown', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--member-add--other--unknown', i18n, { + memberName: renderContact(uuid), + }); } if (detail.type === 'member-add-from-admin-approval') { const { uuid } = detail; @@ -355,7 +357,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-add-from-admin-approval--you--other', i18n, - [renderContact(from)] + { adminName: renderContact(from) } ); } @@ -374,7 +376,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-add-from-admin-approval--other--you', i18n, - [renderContact(uuid)] + { joinerName: renderContact(uuid) } ); } if (from) { @@ -394,7 +396,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-add-from-admin-approval--other--unknown', i18n, - [renderContact(uuid)] + { joinerName: renderContact(uuid) } ); } if (detail.type === 'member-remove') { @@ -406,22 +408,22 @@ export function renderChangeDetail( return renderString('GroupV2--member-remove--you--you', i18n); } if (from) { - return renderString('GroupV2--member-remove--you--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--member-remove--you--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--member-remove--you--unknown', i18n); } if (fromYou) { - return renderString('GroupV2--member-remove--other--you', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--member-remove--other--you', i18n, { + memberName: renderContact(uuid), + }); } if (from && from === uuid) { - return renderString('GroupV2--member-remove--other--self', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--member-remove--other--self', i18n, { + memberName: renderContact(from), + }); } if (from) { return renderString('GroupV2--member-remove--other--other', i18n, { @@ -429,9 +431,9 @@ export function renderChangeDetail( memberName: renderContact(uuid), }); } - return renderString('GroupV2--member-remove--other--unknown', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--member-remove--other--unknown', i18n, { + memberName: renderContact(uuid), + }); } if (detail.type === 'member-privilege') { const { uuid, newPrivilege } = detail; @@ -443,7 +445,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-privilege--promote--you--other', i18n, - [renderContact(from)] + { adminName: renderContact(from) } ); } @@ -457,7 +459,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-privilege--promote--other--you', i18n, - [renderContact(uuid)] + { memberName: renderContact(uuid) } ); } if (from) { @@ -473,7 +475,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-privilege--promote--other--unknown', i18n, - [renderContact(uuid)] + { memberName: renderContact(uuid) } ); } if (newPrivilege === RoleEnum.DEFAULT) { @@ -482,7 +484,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-privilege--demote--you--other', i18n, - [renderContact(from)] + { adminName: renderContact(from) } ); } return renderString( @@ -495,7 +497,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-privilege--demote--other--you', i18n, - [renderContact(uuid)] + { memberName: renderContact(uuid) } ); } if (from) { @@ -511,7 +513,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--member-privilege--demote--other--unknown', i18n, - [renderContact(uuid)] + { memberName: renderContact(uuid) } ); } log.warn( @@ -524,21 +526,21 @@ export function renderChangeDetail( const weAreInvited = isOurUuid(uuid); if (weAreInvited) { if (from) { - return renderString('GroupV2--pending-add--one--you--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--pending-add--one--you--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--pending-add--one--you--unknown', i18n); } if (fromYou) { - return renderString('GroupV2--pending-add--one--other--you', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--pending-add--one--other--you', i18n, { + inviteeName: renderContact(uuid), + }); } if (from) { - return renderString('GroupV2--pending-add--one--other--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--pending-add--one--other--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--pending-add--one--other--unknown', i18n); } @@ -546,9 +548,9 @@ export function renderChangeDetail( const { count } = detail; if (fromYou) { - return renderString('GroupV2--pending-add--many--you', i18n, [ - count.toString(), - ]); + return renderString('GroupV2--pending-add--many--you', i18n, { + count: count.toString(), + }); } if (from) { return renderString('GroupV2--pending-add--many--other', i18n, { @@ -556,9 +558,9 @@ export function renderChangeDetail( count: count.toString(), }); } - return renderString('GroupV2--pending-add--many--unknown', i18n, [ - count.toString(), - ]); + return renderString('GroupV2--pending-add--many--unknown', i18n, { + count: count.toString(), + }); } if (detail.type === 'pending-remove-one') { const { inviter, uuid } = detail; @@ -569,15 +571,15 @@ export function renderChangeDetail( if (weAreInviter) { if (sentByInvited) { - return renderString('GroupV2--pending-remove--decline--you', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--pending-remove--decline--you', i18n, { + inviteeName: renderContact(uuid), + }); } if (fromYou) { return renderString( 'GroupV2--pending-remove--revoke-invite-from-you--one--you', i18n, - [renderContact(uuid)] + { inviteeName: renderContact(uuid) } ); } if (from) { @@ -593,7 +595,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke-invite-from-you--one--unknown', i18n, - [renderContact(uuid)] + { inviteeName: renderContact(uuid) } ); } if (sentByInvited) { @@ -601,9 +603,9 @@ export function renderChangeDetail( return renderString('GroupV2--pending-remove--decline--from-you', i18n); } if (inviter) { - return renderString('GroupV2--pending-remove--decline--other', i18n, [ - renderContact(inviter), - ]); + return renderString('GroupV2--pending-remove--decline--other', i18n, { + memberName: renderContact(inviter), + }); } return renderString('GroupV2--pending-remove--decline--unknown', i18n); } @@ -612,13 +614,13 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke-own--to-you', i18n, - [renderContact(inviter)] + { inviterName: renderContact(inviter) } ); } return renderString( 'GroupV2--pending-remove--revoke-own--unknown', i18n, - [renderContact(inviter)] + { inviterName: renderContact(inviter) } ); } if (inviter) { @@ -626,7 +628,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke-invite-from--one--you', i18n, - [renderContact(inviter)] + { memberName: renderContact(inviter) } ); } if (from) { @@ -642,16 +644,16 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke-invite-from--one--unknown', i18n, - [renderContact(inviter)] + { memberName: renderContact(inviter) } ); } if (fromYou) { return renderString('GroupV2--pending-remove--revoke--one--you', i18n); } if (from) { - return renderString('GroupV2--pending-remove--revoke--one--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--pending-remove--revoke--one--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--pending-remove--revoke--one--unknown', i18n); } @@ -664,7 +666,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke-invite-from-you--many--you', i18n, - [count.toString()] + { count: count.toString() } ); } if (from) { @@ -680,7 +682,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke-invite-from-you--many--unknown', i18n, - [count.toString()] + { count: count.toString() } ); } if (inviter) { @@ -715,9 +717,9 @@ export function renderChangeDetail( ); } if (fromYou) { - return renderString('GroupV2--pending-remove--revoke--many--you', i18n, [ - count.toString(), - ]); + return renderString('GroupV2--pending-remove--revoke--many--you', i18n, { + count: count.toString(), + }); } if (from) { return renderString( @@ -732,7 +734,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--pending-remove--revoke--many--unknown', i18n, - [count.toString()] + { count: count.toString() } ); } if (detail.type === 'admin-approval-add-one') { @@ -742,9 +744,9 @@ export function renderChangeDetail( if (weAreJoiner) { return renderString('GroupV2--admin-approval-add-one--you', i18n); } - return renderString('GroupV2--admin-approval-add-one--other', i18n, [ - renderContact(uuid), - ]); + return renderString('GroupV2--admin-approval-add-one--other', i18n, { + joinerName: renderContact(uuid), + }); } if (detail.type === 'admin-approval-remove-one') { const { uuid } = detail; @@ -767,14 +769,14 @@ export function renderChangeDetail( return renderString( 'GroupV2--admin-approval-remove-one--other--you', i18n, - [renderContact(uuid)] + { joinerName: renderContact(uuid) } ); } if (from && from === uuid) { return renderString( 'GroupV2--admin-approval-remove-one--other--own', i18n, - [renderContact(uuid)] + { joinerName: renderContact(uuid) } ); } if (from) { @@ -793,7 +795,7 @@ export function renderChangeDetail( return renderString( 'GroupV2--admin-approval-remove-one--other--own', i18n, - [renderContact(uuid)] + { joinerName: renderContact(uuid) } ); } if (detail.type === 'admin-approval-bounce') { @@ -836,9 +838,9 @@ export function renderChangeDetail( return renderString('GroupV2--group-link-add--enabled--you', i18n); } if (from) { - return renderString('GroupV2--group-link-add--enabled--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--group-link-add--enabled--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--group-link-add--enabled--unknown', i18n); } @@ -847,9 +849,9 @@ export function renderChangeDetail( return renderString('GroupV2--group-link-add--disabled--you', i18n); } if (from) { - return renderString('GroupV2--group-link-add--disabled--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--group-link-add--disabled--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--group-link-add--disabled--unknown', i18n); } @@ -861,9 +863,9 @@ export function renderChangeDetail( return renderString('GroupV2--group-link-reset--you', i18n); } if (from) { - return renderString('GroupV2--group-link-reset--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--group-link-reset--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--group-link-reset--unknown', i18n); } @@ -872,9 +874,9 @@ export function renderChangeDetail( return renderString('GroupV2--group-link-remove--you', i18n); } if (from) { - return renderString('GroupV2--group-link-remove--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--group-link-remove--other', i18n, { + adminName: renderContact(from), + }); } return renderString('GroupV2--group-link-remove--unknown', i18n); } @@ -884,9 +886,9 @@ export function renderChangeDetail( return renderString('GroupV2--description--remove--you', i18n); } if (from) { - return renderString('GroupV2--description--remove--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--description--remove--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--description--remove--unknown', i18n); } @@ -895,9 +897,9 @@ export function renderChangeDetail( return renderString('GroupV2--description--change--you', i18n); } if (from) { - return renderString('GroupV2--description--change--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--description--change--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--description--change--unknown', i18n); } @@ -907,9 +909,9 @@ export function renderChangeDetail( return renderString('GroupV2--announcements--admin--you', i18n); } if (from) { - return renderString('GroupV2--announcements--admin--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--announcements--admin--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--announcements--admin--unknown', i18n); } @@ -918,9 +920,9 @@ export function renderChangeDetail( return renderString('GroupV2--announcements--member--you', i18n); } if (from) { - return renderString('GroupV2--announcements--member--other', i18n, [ - renderContact(from), - ]); + return renderString('GroupV2--announcements--member--other', i18n, { + memberName: renderContact(from), + }); } return renderString('GroupV2--announcements--member--unknown', i18n); } diff --git a/ts/models/messages.ts b/ts/models/messages.ts index a44c1f97bc29..7c1edb9e5a48 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -579,7 +579,7 @@ export class MessageModel extends window.Backbone.Model { renderString: ( key: string, _i18n: unknown, - components: Array | ReplacementValuesType | undefined + components: ReplacementValuesType | undefined ) => window.i18n(key, components), }); @@ -640,9 +640,9 @@ export class MessageModel extends window.Backbone.Model { } if (groupUpdate.left) { return { - text: window.i18n('leftTheGroup', [ - this.getNameForNumber(groupUpdate.left), - ]), + text: window.i18n('leftTheGroup', { + name: this.getNameForNumber(groupUpdate.left), + }), }; } @@ -653,7 +653,11 @@ export class MessageModel extends window.Backbone.Model { if (isMe(fromContact.attributes)) { messages.push(window.i18n('youUpdatedTheGroup')); } else { - messages.push(window.i18n('updatedTheGroup', [fromContact.getTitle()])); + messages.push( + window.i18n('updatedTheGroup', { + name: fromContact.getTitle(), + }) + ); } if (groupUpdate.joined && groupUpdate.joined.length) { @@ -666,9 +670,11 @@ export class MessageModel extends window.Backbone.Model { if (joinedContacts.length > 1) { messages.push( - window.i18n('multipleJoinedTheGroup', [ - joinedWithoutMe.map(contact => contact.getTitle()).join(', '), - ]) + window.i18n('multipleJoinedTheGroup', { + names: joinedWithoutMe + .map(contact => contact.getTitle()) + .join(', '), + }) ); if (joinedWithoutMe.length < joinedContacts.length) { @@ -683,14 +689,20 @@ export class MessageModel extends window.Backbone.Model { messages.push(window.i18n('youJoinedTheGroup')); } else { messages.push( - window.i18n('joinedTheGroup', [joinedContacts[0].getTitle()]) + window.i18n('joinedTheGroup', { + name: joinedContacts[0].getTitle(), + }) ); } } } if (groupUpdate.name) { - messages.push(window.i18n('titleIsNow', [groupUpdate.name])); + messages.push( + window.i18n('titleIsNow', { + name: groupUpdate.name, + }) + ); } if (groupUpdate.avatarUpdated) { messages.push(window.i18n('updatedGroupAvatar')); @@ -788,9 +800,9 @@ export class MessageModel extends window.Backbone.Model { } return { - text: window.i18n('timerSetTo', [ - expirationTimer.format(window.i18n, expireTimer), - ]), + text: window.i18n('timerSetTo', { + time: expirationTimer.format(window.i18n, expireTimer), + }), }; } @@ -798,9 +810,9 @@ export class MessageModel extends window.Backbone.Model { const identifier = this.get('key_changed'); const conversation = window.ConversationController.get(identifier); return { - text: window.i18n('safetyNumberChangedGroup', [ - conversation ? conversation.getTitle() : '', - ]), + text: window.i18n('safetyNumberChangedGroup', { + name: conversation ? conversation.getTitle() : '', + }), }; } const contacts = this.get('contact'); diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 04dc6b9ea0d9..592657b6f1c0 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -2266,9 +2266,9 @@ export class CallingClass { notificationTitle = conversation?.getTitle() || FALLBACK_NOTIFICATION_TITLE; notificationMessage = creatorConversation - ? window.i18n('calling__call-notification__started', [ - creatorConversation.getTitle(), - ]) + ? window.i18n('calling__call-notification__started', { + name: creatorConversation.getTitle(), + }) : window.i18n('calling__call-notification__started-by-someone'); break; } diff --git a/ts/test-both/types/setupI18n_test.ts b/ts/test-both/types/setupI18n_test.ts index 7360450ae918..40326ad0d631 100644 --- a/ts/test-both/types/setupI18n_test.ts +++ b/ts/test-both/types/setupI18n_test.ts @@ -22,7 +22,9 @@ describe('setupI18n', () => { assert.strictEqual(i18n('reportIssue'), 'Contact Support'); }); it('returns message with single substitution', () => { - const actual = i18n('migratingToSQLCipher', ['45/200']); + const actual = i18n('migratingToSQLCipher', { + status: '45/200', + }); assert.equal(actual, 'Optimizing messages... 45/200 complete.'); }); it('returns message with multiple substitutions', () => { diff --git a/ts/types/Util.ts b/ts/types/Util.ts index 6ac78aa2dcb7..a93772ab3578 100644 --- a/ts/types/Util.ts +++ b/ts/types/Util.ts @@ -40,11 +40,9 @@ export type RenderTextCallbackType = (options: { key: number; }) => JSX.Element | string; -export type ReplacementValuesType = - | Array - | { - [key: string]: string | number | undefined; - }; +export type ReplacementValuesType = { + [key: string]: string | number | undefined; +}; export type LocalizerType = { (key: string, values?: ReplacementValuesType): string; diff --git a/ts/util/callingNotification.ts b/ts/util/callingNotification.ts index 66537ea4db64..eba153d272e6 100644 --- a/ts/util/callingNotification.ts +++ b/ts/util/callingNotification.ts @@ -86,9 +86,9 @@ function getGroupCallNotificationText( if (notification.creator.isMe) { return i18n('calling__call-notification__started-by-you'); } - return i18n('calling__call-notification__started', [ - notification.creator.systemGivenName ?? notification.creator.title, - ]); + return i18n('calling__call-notification__started', { + name: notification.creator.systemGivenName ?? notification.creator.title, + }); } export function getCallingNotificationText( diff --git a/ts/util/getMutedUntilText.ts b/ts/util/getMutedUntilText.ts index c2e00f529841..a8af1cf5a920 100644 --- a/ts/util/getMutedUntilText.ts +++ b/ts/util/getMutedUntilText.ts @@ -23,5 +23,7 @@ export function getMutedUntilText( ? expires.format('LT') : expires.format('L, LT'); - return i18n('muteExpirationLabel', [muteExpirationUntil]); + return i18n('muteExpirationLabel', { + duration: muteExpirationUntil, + }); } diff --git a/ts/util/timestamp.ts b/ts/util/timestamp.ts index b7e2ccb43dea..39eaaab598a1 100644 --- a/ts/util/timestamp.ts +++ b/ts/util/timestamp.ts @@ -125,21 +125,21 @@ export function formatDateTimeLong( const timestamp = rawTimestamp.valueOf(); if (isToday(rawTimestamp)) { - return i18n('timestampFormat__long--today', [ - new Intl.DateTimeFormat(locale, { + return i18n('timestampFormat__long--today', { + time: new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: 'numeric', }).format(timestamp), - ]); + }); } if (isYesterday(rawTimestamp)) { - return i18n('timestampFormat__long--yesterday', [ - new Intl.DateTimeFormat(locale, { + return i18n('timestampFormat__long--yesterday', { + time: new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: 'numeric', }).format(timestamp), - ]); + }); } return new Intl.DateTimeFormat(locale, { @@ -165,11 +165,15 @@ export function formatTime( } if (diff < HOUR) { - return i18n('minutesAgo', [Math.floor(diff / MINUTE).toString()]); + return i18n('minutesAgo', { + minutes: Math.floor(diff / MINUTE).toString(), + }); } if (isRelativeTime) { - return i18n('hoursAgo', [Math.floor(diff / HOUR).toString()]); + return i18n('hoursAgo', { + hours: Math.floor(diff / HOUR).toString(), + }); } return new Date(timestamp).toLocaleTimeString([], {