From e69a589432e5147e8f20b04f3d4a8d426e33c280 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:58:56 +0200 Subject: [PATCH] Localization: Update star related strings (#5800) --- src/assets/localization/fallback.strings | 23 ++++++----- .../common/PaymentMessageConfirmDialog.tsx | 18 ++++----- src/components/middle/MessageListContent.tsx | 5 ++- .../stars/chatRefund/ChatRefundModal.tsx | 3 +- src/global/actions/api/bots.ts | 8 +++- src/global/actions/api/messages.ts | 17 ++++++--- src/types/language.d.ts | 38 +++++++------------ 7 files changed, 55 insertions(+), 57 deletions(-) diff --git a/src/assets/localization/fallback.strings b/src/assets/localization/fallback.strings index e81711e03..d20f1bdbf 100644 --- a/src/assets/localization/fallback.strings +++ b/src/assets/localization/fallback.strings @@ -1866,27 +1866,26 @@ "SectionTitleStarsForForMessages" = "Set your price per message"; "SectionDescriptionStarsForForMessages" = "You will receive {percent}% of the selected fee (~{amount}) for each incoming message."; "SubtitlePrivacyAddUsers" = "Add Users"; -"SubtitlePrivacyUsersCount" = "{count} users"; "PrivacyPaidMessagesValue" = "Paid"; "FirstMessageInPaidMessagesChat" = "**{user}** charges {amount} for each message."; "ButtonBuyStars" = "Buy Stars"; "ComposerPlaceholderPaidMessage" = "Message for {amount}"; "ComposerPlaceholderPaidReply" = "Reply for {amount}"; "TitleConfirmPayment" = "Confirm Payment"; -"ConfirmationModalPaymentForOneMessage" = "{user} charges **{amount} Stars** per incoming message. Would you like to pay **{amount} Stars** to send one message?"; -"ConfirmationModalPaymentForMessages" = "{user} charges **{price} Stars** per incoming message. Would you like to pay **{amount} Stars** to send **{count} messages?**"; -"ButtonPayForMessage" = "Pay for {count} message"; -"ToastTitleMessageSent" = "Message sent!"; -"ToastTitleMessagesSent" = "{count} Messages sent!"; -"ToastMessageSent" = "You paid {amount} stars."; +"ConfirmationModalPaymentForMessage_one" = "{user} charges **{amount}** per incoming message. Would you like to pay **{totalAmount}** to send one message?"; +"ConfirmationModalPaymentForMessage_other" = "{user} charges **{amount}** per incoming message. Would you like to pay **{totalAmount}** to send **{count} messages?**"; +"PayForMessage_one" = "Pay for {count} message"; +"PayForMessage_other" = "Pay for {count} messages"; +"MessageSentPaidToastTitle_one" = "Message sent!"; +"MessageSentPaidToastTitle_other" = "{count} messages sent!"; +"MessageSentPaidToastText" = "You paid {amount}"; "ButtonUndo" = "Undo"; -"ActionPaidOneMessageOutgoing" = "You paid {amount} Stars to send a message"; -"ActionPaidOneMessageIncoming" = "You received {amount} Stars from {user}"; +"ActionPaidOneMessageOutgoing" = "You paid {amount} to send a message"; +"ActionPaidOneMessageIncoming" = "You received {amount} from {user}"; "PaneMessagePaidMessageCharge" = "{peer} must pay {amount} for each message to you."; "ConfirmRemoveMessageFee" = "Yes"; "ConfirmDialogMessageRemoveFee" = "Are you sure you want to allow **{peer}** to message you for free?"; -"ConfirmDialogRemoveFeeRefundStars" = "Refund already paid **{amount} Stars**"; -"DescriptionGiftPaidMessage" = "{user} charges **{amount}** Stars for each message. That price has been added to the cost of the gift."; +"ConfirmDialogRemoveFeeRefundStars" = "Refund already paid **{amount}**"; "StoryTooltipGifSent" = "Gif Sent!"; "StoryTooltipStickerSent" = "Sticker Sent!"; "StoryTooltipReactionSent" = "Reaction Sent!"; @@ -1897,4 +1896,4 @@ "PaidMessageTransactionTotal" = "Total"; "DescriptionRestrictedMedia" = "Posting media content is not allowed in this group."; "DescriptionScheduledPaidMediaNotAllowed" = "Posting scheduled paid media content is not allowed"; -"DescriptionScheduledPaidMessagesNotAllowed" = "Scheduled paid messages is not allowed"; \ No newline at end of file +"DescriptionScheduledPaidMessagesNotAllowed" = "Scheduled paid messages is not allowed"; diff --git a/src/components/common/PaymentMessageConfirmDialog.tsx b/src/components/common/PaymentMessageConfirmDialog.tsx index e6230e5cc..10a92fc7c 100644 --- a/src/components/common/PaymentMessageConfirmDialog.tsx +++ b/src/components/common/PaymentMessageConfirmDialog.tsx @@ -1,6 +1,8 @@ import type { FC, StateHookSetter } from '../../lib/teact/teact'; import React, { memo } from '../../lib/teact/teact'; +import { formatStarsAsText } from '../../util/localization/format'; + import useLang from '../../hooks/useLang'; import Checkbox from '../ui/Checkbox'; @@ -31,24 +33,20 @@ const PaymentMessageConfirmDialog: FC = ({ }) => { const lang = useLang(); - const confirmPaymentMessage = messagesCount === 1 ? lang('ConfirmationModalPaymentForOneMessage', { + const confirmPaymentMessage = lang('ConfirmationModalPaymentForMessage', { user: userName, - amount: messagePriceInStars, - }, { - withMarkdown: true, - withNodes: true, - }) : lang('ConfirmationModalPaymentForMessages', { - user: userName, - price: messagePriceInStars, - amount: messagePriceInStars * messagesCount, + amount: formatStarsAsText(lang, messagePriceInStars), + totalAmount: formatStarsAsText(lang, messagePriceInStars * messagesCount), count: messagesCount, }, { withMarkdown: true, withNodes: true, + pluralValue: messagesCount, }); - const confirmLabel = lang('ButtonPayForMessage', { count: messagesCount }, { + const confirmLabel = lang('PayForMessage', { count: messagesCount }, { withNodes: true, + pluralValue: messagesCount, }); return ( diff --git a/src/components/middle/MessageListContent.tsx b/src/components/middle/MessageListContent.tsx index 57beeb49f..b6fee041f 100644 --- a/src/components/middle/MessageListContent.tsx +++ b/src/components/middle/MessageListContent.tsx @@ -23,6 +23,7 @@ import { selectSender } from '../../global/selectors'; import buildClassName from '../../util/buildClassName'; import { formatHumanDate } from '../../util/dates/dateFormat'; import { compact } from '../../util/iteratees'; +import { formatStarsAsText } from '../../util/localization/format'; import { isAlbum } from './helpers/groupMessages'; import { preventMessageInputBlur } from './helpers/preventMessageInputBlur'; @@ -154,14 +155,14 @@ const MessageListContent: FC = ({ { message.isOutgoing ? lang('ActionPaidOneMessageOutgoing', { - amount, + amount: formatStarsAsText(lang, amount), }) : (() => { const sender = selectSender(getGlobal(), message); const userTitle = sender ? getPeerTitle(lang, sender) : ''; return lang('ActionPaidOneMessageIncoming', { user: userTitle, - amount, + amount: formatStarsAsText(lang, amount), }); })() } diff --git a/src/components/modals/stars/chatRefund/ChatRefundModal.tsx b/src/components/modals/stars/chatRefund/ChatRefundModal.tsx index 0293a1deb..b7e870122 100644 --- a/src/components/modals/stars/chatRefund/ChatRefundModal.tsx +++ b/src/components/modals/stars/chatRefund/ChatRefundModal.tsx @@ -6,6 +6,7 @@ import type { TabState } from '../../../../global/types'; import { getPeerTitle } from '../../../../global/helpers/peers'; import { selectUser } from '../../../../global/selectors'; +import { formatStarsAsText } from '../../../../util/localization/format'; import useCurrentOrPrev from '../../../../hooks/useCurrentOrPrev'; import useLang from '../../../../hooks/useLang'; @@ -61,7 +62,7 @@ const ChatRefundModal = ({ modal, user }: OwnProps & StateProps) => { ( const { gif, sticker, isReaction } = firstSendParam; if (gif) { - storySendMessage = { key: 'ToastTitleMessageSent' }; + storySendMessage = { key: 'MessageSentPaidToastTitle', variables: { count: 1 }, options: { pluralValue: 1 } }; } else if (sticker) { storySendMessage = { key: 'StoryTooltipStickerSent' }; } else if (isReaction) { @@ -1702,14 +1703,20 @@ async function sendMessagesWithNotification( } } - const titleKey: RegularLangFnParameters = storySendMessage || (messagesCount === 1 ? { key: 'ToastTitleMessageSent' } - : { key: 'ToastTitleMessagesSent', variables: { count: messagesCount } }); + const titleKey: RegularLangFnParameters = storySendMessage || { + key: 'MessageSentPaidToastTitle', + variables: { count: messagesCount }, + options: { pluralValue: messagesCount }, + }; // eslint-disable-next-line eslint-multitab-tt/no-getactions-in-actions getActions().showNotification({ localId: getMessageKey(firstMessage), title: titleKey, - message: { key: 'ToastMessageSent', variables: { amount: starsForOneMessage * messagesCount } }, + message: { + key: 'MessageSentPaidToastText', + variables: { amount: formatStarsAsText(getTranslationFn(), starsForOneMessage * messagesCount) }, + }, actionText: { key: 'ButtonUndo' }, action: { action: 'deleteMessages', diff --git a/src/types/language.d.ts b/src/types/language.d.ts index 847896ba6..ac401679a 100644 --- a/src/types/language.d.ts +++ b/src/types/language.d.ts @@ -1443,7 +1443,6 @@ export interface LangPair { 'PrivacyPaidMessagesValue': undefined; 'ButtonBuyStars': undefined; 'TitleConfirmPayment': undefined; - 'ToastTitleMessageSent': undefined; 'ButtonUndo': undefined; 'ConfirmRemoveMessageFee': undefined; 'StoryTooltipGifSent': undefined; @@ -2303,9 +2302,6 @@ export interface LangPairWithVariables { 'percent': V; 'amount': V; }; - 'SubtitlePrivacyUsersCount': { - 'count': V; - }; 'FirstMessageInPaidMessagesChat': { 'user': V; 'amount': V; @@ -2316,23 +2312,7 @@ export interface LangPairWithVariables { 'ComposerPlaceholderPaidReply': { 'amount': V; }; - 'ConfirmationModalPaymentForOneMessage': { - 'user': V; - 'amount': V; - }; - 'ConfirmationModalPaymentForMessages': { - 'user': V; - 'price': V; - 'amount': V; - 'count': V; - }; - 'ButtonPayForMessage': { - 'count': V; - }; - 'ToastTitleMessagesSent': { - 'count': V; - }; - 'ToastMessageSent': { + 'MessageSentPaidToastText': { 'amount': V; }; 'ActionPaidOneMessageOutgoing': { @@ -2352,10 +2332,6 @@ export interface LangPairWithVariables { 'ConfirmDialogRemoveFeeRefundStars': { 'amount': V; }; - 'DescriptionGiftPaidMessage': { - 'user': V; - 'amount': V; - }; 'PaidMessageTransactionDescription': { 'percent': V; }; @@ -2635,6 +2611,18 @@ export interface LangPairPluralWithVariables { 'from': V; 'count': V; }; + 'ConfirmationModalPaymentForMessage': { + 'user': V; + 'amount': V; + 'totalAmount': V; + 'count': V; + }; + 'PayForMessage': { + 'count': V; + }; + 'MessageSentPaidToastTitle': { + 'count': V; + }; 'PaidMessageTransaction': { 'count': V; };