Use more separate phrases.

This commit is contained in:
John Preston 2025-07-01 23:00:40 +04:00
parent fcba6bc7d7
commit ddd3d38dac
9 changed files with 137 additions and 97 deletions

View file

@ -2274,7 +2274,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_action_todo_tasks_fallback#other" = "{count} tasks"; "lng_action_todo_tasks_fallback#other" = "{count} tasks";
"lng_action_todo_tasks_and_one" = "{tasks}, {task}"; "lng_action_todo_tasks_and_one" = "{tasks}, {task}";
"lng_action_todo_tasks_and_last" = "{tasks} and {task}"; "lng_action_todo_tasks_and_last" = "{tasks} and {task}";
"lng_action_suggest_success" = "{from} has received {amount} for publishing post."; "lng_action_suggest_success_stars#one" = "{from} has received {count} Star for publishing post.";
"lng_action_suggest_success_stars#other" = "{from} has received {count} Stars for publishing post.";
"lng_action_suggest_success_ton#one" = "{from} has received {count} TON for publishing post.";
"lng_action_suggest_success_ton#other" = "{from} has received {count} TON for publishing post.";
"lng_action_suggest_refund_user" = "User refunded the Stars so that post was deleted."; "lng_action_suggest_refund_user" = "User refunded the Stars so that post was deleted.";
"lng_action_suggest_refund_admin" = "Admin deleted the post early so that the price was refunded to the user."; "lng_action_suggest_refund_admin" = "Admin deleted the post early so that the price was refunded to the user.";
"lng_you_paid_stars#one" = "You paid {count} Star."; "lng_you_paid_stars#one" = "You paid {count} Star.";
@ -3496,6 +3499,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_gift_stars_incoming" = "Use Stars to unlock content and services on Telegram."; "lng_gift_stars_incoming" = "Use Stars to unlock content and services on Telegram.";
"lng_gift_until" = "Until"; "lng_gift_until" = "Until";
"lng_gift_ton_amount#one" = "{count} TON";
"lng_gift_ton_amount#other" = "{count} TON";
"lng_gift_premium_or_stars" = "Gift Premium or Stars"; "lng_gift_premium_or_stars" = "Gift Premium or Stars";
"lng_gift_premium_subtitle" = "Gift Premium"; "lng_gift_premium_subtitle" = "Gift Premium";
"lng_gift_premium_about" = "Give {name} access to exclusive features with Telegram Premium. {features}"; "lng_gift_premium_about" = "Give {name} access to exclusive features with Telegram Premium. {features}";
@ -4455,7 +4461,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_suggest_options_date_publish" = "Publish"; "lng_suggest_options_date_publish" = "Publish";
"lng_suggest_options_date_now" = "Publish Now"; "lng_suggest_options_date_now" = "Publish Now";
"lng_suggest_options_date_about" = "Select the date and time you want the message to be published. The post will remain available for at least 24 hours from this date."; "lng_suggest_options_date_about" = "Select the date and time you want the message to be published. The post will remain available for at least 24 hours from this date.";
"lng_suggest_options_you_get" = "You will receive {amount} ({percent}) for publishing this post."; "lng_suggest_options_you_get_stars#one" = "You will receive {count} Star ({percent}) for publishing this post.";
"lng_suggest_options_you_get_stars#other" = "You will receive {count} Stars ({percent}) for publishing this post.";
"lng_suggest_options_you_get_ton#one" = "You will receive {count} TON ({percent}) for publishing this post.";
"lng_suggest_options_you_get_ton#other" = "You will receive {count} TON ({percent}) for publishing this post.";
"lng_suggest_options_stars_warning" = "Transactions in **Stars** may be reversed by the payment provider within **21** days. Only accept Stars from people you trust."; "lng_suggest_options_stars_warning" = "Transactions in **Stars** may be reversed by the payment provider within **21** days. Only accept Stars from people you trust.";
"lng_suggest_options_offer" = "Offer {amount}"; "lng_suggest_options_offer" = "Offer {amount}";
"lng_suggest_options_offer_free" = "Offer for Free"; "lng_suggest_options_offer_free" = "Offer for Free";
@ -4472,8 +4481,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_suggest_action_time_any" = "Anytime"; "lng_suggest_action_time_any" = "Anytime";
"lng_suggest_action_agreement" = "Agreement reached!"; "lng_suggest_action_agreement" = "Agreement reached!";
"lng_suggest_action_agree_date" = "The post will be automatically published on {channel} {date}."; "lng_suggest_action_agree_date" = "The post will be automatically published on {channel} {date}.";
"lng_suggest_action_your_charged" = "You have been charged {amount}."; "lng_suggest_action_your_charged_stars#one" = "You have been charged **{count} Star**.";
"lng_suggest_action_his_charged" = "{from} have been charged {amount}."; "lng_suggest_action_your_charged_stars#other" = "You have been charged **{count} Stars**.";
"lng_suggest_action_your_charged_ton#one" = "You have been charged **{count} TON**.";
"lng_suggest_action_your_charged_ton#other" = "You have been charged **{count} TON**.";
"lng_suggest_action_his_charged_stars#one" = "{from} has been charged **{count} Star**.";
"lng_suggest_action_his_charged_stars#other" = "{from} has been charged **{count} Stars**.";
"lng_suggest_action_his_charged_ton#one" = "{from} has been charged **{count} TON**.";
"lng_suggest_action_his_charged_ton#other" = "{from} has been charged **{count} TON**.";
"lng_suggest_action_agree_receive_stars" = "{channel} will receive the Stars once the post has been live for 24 hours."; "lng_suggest_action_agree_receive_stars" = "{channel} will receive the Stars once the post has been live for 24 hours.";
"lng_suggest_action_agree_receive_ton" = "{channel} will receive TON once the post has been live for 24 hours."; "lng_suggest_action_agree_receive_ton" = "{channel} will receive TON once the post has been live for 24 hours.";
"lng_suggest_action_agree_removed_stars" = "If {channel} removes the post before it has been live for 24 hours, the Stars will be refunded."; "lng_suggest_action_agree_removed_stars" = "If {channel} removes the post before it has been live for 24 hours, the Stars will be refunded.";
@ -4501,12 +4516,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_suggest_accept_title" = "Accept Terms"; "lng_suggest_accept_title" = "Accept Terms";
"lng_suggest_accept_text" = "Do you want to publish this post from {from}?"; "lng_suggest_accept_text" = "Do you want to publish this post from {from}?";
"lng_suggest_accept_text_to" = "Do you want to publish this post to {channel}?"; "lng_suggest_accept_text_to" = "Do you want to publish this post to {channel}?";
"lng_suggest_accept_receive" = "{channel} will receive {amount} ({percent}) for publishing {date}."; "lng_suggest_accept_receive_stars#one" = "{channel} will receive **{count} Star** ({percent}) for publishing {date}.";
"lng_suggest_accept_receive_now" = "{channel} will receive {amount} ({percent}) for publishing right now."; "lng_suggest_accept_receive_stars#other" = "{channel} will receive **{count} Stars** ({percent}) for publishing {date}.";
"lng_suggest_accept_receive_ton#one" = "{channel} will receive **{count} TON** ({percent}) for publishing {date}.";
"lng_suggest_accept_receive_ton#other" = "{channel} will receive **{count} TON** ({percent}) for publishing {date}.";
"lng_suggest_accept_receive_now_stars#one" = "{channel} will receive **{count} Star** ({percent}) for publishing right now.";
"lng_suggest_accept_receive_now_stars#other" = "{channel} will receive **{count} Stars** ({percent}) for publishing right now.";
"lng_suggest_accept_receive_now_ton#one" = "{channel} will receive **{count} TON** ({percent}) for publishing right now.";
"lng_suggest_accept_receive_now_ton#other" = "{channel} will receive **{count} TON** ({percent}) for publishing right now.";
"lng_suggest_accept_receive_if" = "It must remain visible for at least **24** hours after publication."; "lng_suggest_accept_receive_if" = "It must remain visible for at least **24** hours after publication.";
"lng_suggest_accept_pay" = "You will pay {amount} for publishing {date}."; "lng_suggest_accept_pay_stars#one" = "You will pay **{count} Star** for publishing {date}.";
"lng_suggest_accept_pay_now" = "You will pay {amount} for publishing right now."; "lng_suggest_accept_pay_stars#other" = "You will pay **{count} Stars** for publishing {date}.";
"lng_suggest_accept_pay_ton#one" = "You will pay **{count} TON** for publishing {date}.";
"lng_suggest_accept_pay_ton#other" = "You will pay **{count} TON** for publishing {date}.";
"lng_suggest_accept_pay_now_stars#one" = "You will pay **{count} Star** for publishing right now.";
"lng_suggest_accept_pay_now_stars#other" = "You will pay **{count} Stars** for publishing right now.";
"lng_suggest_accept_pay_now_ton#one" = "You will pay **{count} TON** for publishing right now.";
"lng_suggest_accept_pay_now_ton#other" = "You will pay **{count} TON** for publishing right now.";
"lng_suggest_accept_send" = "Publish"; "lng_suggest_accept_send" = "Publish";
"lng_suggest_stars_amount#one" = "{count} Star";
"lng_suggest_stars_amount#other" = "{count} Stars";
"lng_suggest_ton_amount#one" = "{count} TON"; "lng_suggest_ton_amount#one" = "{count} TON";
"lng_suggest_ton_amount#other" = "{count} TON"; "lng_suggest_ton_amount#other" = "{count} TON";
"lng_suggest_warn_title_stars" = "Stars will be lost"; "lng_suggest_warn_title_stars" = "Stars will be lost";

View file

@ -141,8 +141,8 @@ void ConfirmApproval(
const auto broadcast = peer->monoforumBroadcast(); const auto broadcast = peer->monoforumBroadcast();
const auto channelName = (broadcast ? broadcast : peer)->name(); const auto channelName = (broadcast ? broadcast : peer)->name();
const auto amount = admin const auto amount = admin
? HistoryView::FormatPriceAfterCommission(session, price) ? HistoryView::PriceAfterCommission(session, price)
: Lang::FormatCreditsAmountWithCurrency(price); : price;
const auto commission = HistoryView::FormatAfterCommissionPercent( const auto commission = HistoryView::FormatAfterCommissionPercent(
session, session,
price); price);
@ -163,39 +163,47 @@ void ConfirmApproval(
if (price) { if (price) {
text.append("\n\n").append(admin text.append("\n\n").append(admin
? (scheduleDate ? (scheduleDate
? tr::lng_suggest_accept_receive( ? (amount.stars()
tr::now, ? tr::lng_suggest_accept_receive_stars
lt_channel, : tr::lng_suggest_accept_receive_ton)(
Ui::Text::Bold(channelName), tr::now,
lt_amount, lt_count_decimal,
Ui::Text::Bold(amount), amount.value(),
lt_percent, lt_channel,
TextWithEntities{ commission }, Ui::Text::Bold(channelName),
lt_date, lt_percent,
Ui::Text::Bold(date), TextWithEntities{ commission },
Ui::Text::RichLangValue) lt_date,
: tr::lng_suggest_accept_receive_now( Ui::Text::Bold(date),
tr::now, Ui::Text::RichLangValue)
lt_channel, : (amount.stars()
Ui::Text::Bold(channelName), ? tr::lng_suggest_accept_receive_now_stars
lt_amount, : tr::lng_suggest_accept_receive_now_ton)(
Ui::Text::Bold(amount), tr::now,
lt_percent, lt_count_decimal,
TextWithEntities{ commission }, amount.value(),
Ui::Text::RichLangValue)) lt_channel,
Ui::Text::Bold(channelName),
lt_percent,
TextWithEntities{ commission },
Ui::Text::RichLangValue))
: (scheduleDate : (scheduleDate
? tr::lng_suggest_accept_pay( ? (amount.stars()
tr::now, ? tr::lng_suggest_accept_pay_stars
lt_amount, : tr::lng_suggest_accept_pay_ton)(
Ui::Text::Bold(amount), tr::now,
lt_date, lt_count_decimal,
Ui::Text::Bold(date), amount.value(),
Ui::Text::RichLangValue) lt_date,
: tr::lng_suggest_accept_pay_now( Ui::Text::Bold(date),
tr::now, Ui::Text::RichLangValue)
lt_amount, : (amount.stars()
Ui::Text::Bold(amount), ? tr::lng_suggest_accept_pay_now_stars
Ui::Text::RichLangValue))); : tr::lng_suggest_accept_pay_now_ton)(
tr::now,
lt_count_decimal,
amount.value(),
Ui::Text::RichLangValue)));
if (admin) { if (admin) {
text.append(' ').append( text.append(' ').append(
tr::lng_suggest_accept_receive_if( tr::lng_suggest_accept_receive_if(

View file

@ -6092,16 +6092,17 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
auto prepareSuggestedPostSuccess = [&](const MTPDmessageActionSuggestedPostSuccess &data) { auto prepareSuggestedPostSuccess = [&](const MTPDmessageActionSuggestedPostSuccess &data) {
const auto price = CreditsAmountFromTL(&data.vprice()); const auto price = CreditsAmountFromTL(&data.vprice());
const auto amount = Lang::FormatCreditsAmountWithCurrency(price);
auto result = PreparedServiceText(); auto result = PreparedServiceText();
result.links.push_back(_from->createOpenLink()); result.links.push_back(_from->createOpenLink());
result.text = tr::lng_action_suggest_success( result.text = (price.stars()
tr::now, ? tr::lng_action_suggest_success_stars
lt_from, : tr::lng_action_suggest_success_ton)(
Ui::Text::Link(_from->shortName(), 1), tr::now,
lt_amount, lt_count_decimal,
TextWithEntities{ amount }, price.value(),
Ui::Text::WithEntities); lt_from,
Ui::Text::Link(_from->shortName(), 1),
Ui::Text::WithEntities);
return result; return result;
}; };

View file

@ -352,19 +352,24 @@ void ChooseSuggestPriceBox(
Ui::AddSkip(starsInner); Ui::AddSkip(starsInner);
Ui::AddSkip(starsInner); Ui::AddSkip(starsInner);
const auto formatPrice = [peer = args.peer](CreditsAmount amount) { const auto computePrice = [peer = args.peer](CreditsAmount amount) {
return FormatPriceAfterCommission(&peer->session(), amount); return PriceAfterCommission(&peer->session(), amount).value();
}; };
const auto formatCommission = [peer = args.peer](CreditsAmount amount) { const auto formatCommission = [peer = args.peer](CreditsAmount amount) {
return FormatAfterCommissionPercent(&peer->session(), amount); return FormatAfterCommissionPercent(&peer->session(), amount);
}; };
const auto youGet = [=](rpl::producer<CreditsAmount> price, bool stars) {
return (stars
? tr::lng_suggest_options_you_get_stars
: tr::lng_suggest_options_you_get_ton)(
lt_count_decimal,
rpl::duplicate(price) | rpl::map(computePrice),
lt_percent,
rpl::duplicate(price) | rpl::map(formatCommission));
};
Ui::AddDividerText(starsInner, admin Ui::AddDividerText(starsInner, admin
? rpl::combine( ? rpl::combine(
tr::lng_suggest_options_you_get( youGet(starsPrice(), true),
lt_amount,
starsPrice() | rpl::map(formatPrice),
lt_percent,
starsPrice() | rpl::map(formatCommission)),
tr::lng_suggest_options_stars_warning(Ui::Text::RichLangValue) tr::lng_suggest_options_stars_warning(Ui::Text::RichLangValue)
) | rpl::map([=](const QString &t1, const TextWithEntities &t2) { ) | rpl::map([=](const QString &t1, const TextWithEntities &t2) {
return TextWithEntities{ t1 }.append("\n\n").append(t2); return TextWithEntities{ t1 }.append("\n\n").append(t2);
@ -421,11 +426,7 @@ void ChooseSuggestPriceBox(
Ui::AddDividerText( Ui::AddDividerText(
tonInner, tonInner,
(admin (admin
? tr::lng_suggest_options_you_get( ? youGet(tonPrice(), false)
lt_amount,
tonPrice() | rpl::map(formatPrice),
lt_percent,
tonPrice() | rpl::map(formatCommission))
: tr::lng_suggest_options_ton_price_about())); : tr::lng_suggest_options_ton_price_about()));
tonWrap->toggleOn(state->ton.value(), anim::type::instant); tonWrap->toggleOn(state->ton.value(), anim::type::instant);
@ -669,7 +670,7 @@ bool CanAddOfferToMessage(not_null<HistoryItem*> item) {
history->owner().history(broadcast)).has_value(); history->owner().history(broadcast)).has_value();
} }
QString FormatPriceAfterCommission( CreditsAmount PriceAfterCommission(
not_null<Main::Session*> session, not_null<Main::Session*> session,
CreditsAmount price) { CreditsAmount price) {
const auto appConfig = &session->appConfig(); const auto appConfig = &session->appConfig();
@ -679,11 +680,10 @@ QString FormatPriceAfterCommission(
const auto value = (price.value() * mul / 1000.); const auto value = (price.value() * mul / 1000.);
const auto whole = int(std::floor(value)); const auto whole = int(std::floor(value));
//const auto nano = int(base::SafeRound( const auto nano = price.stars()
// (value - whole) * Ui::kNanosInOne)); ? 0
const auto nano = 0; : int(base::SafeRound((value - whole) * Ui::kNanosInOne));
return Lang::FormatCreditsAmountWithCurrency( return CreditsAmount(whole, nano, price.type());
CreditsAmount(whole, nano, price.type()));
} }
QString FormatAfterCommissionPercent( QString FormatAfterCommissionPercent(

View file

@ -58,7 +58,7 @@ void ChooseSuggestPriceBox(
[[nodiscard]] bool CanAddOfferToMessage(not_null<HistoryItem*> item); [[nodiscard]] bool CanAddOfferToMessage(not_null<HistoryItem*> item);
[[nodiscard]] QString FormatPriceAfterCommission( [[nodiscard]] CreditsAmount PriceAfterCommission(
not_null<Main::Session*> session, not_null<Main::Session*> session,
CreditsAmount price); CreditsAmount price);
[[nodiscard]] QString FormatAfterCommissionPercent( [[nodiscard]] QString FormatAfterCommissionPercent(

View file

@ -70,8 +70,11 @@ QSize PremiumGift::size() {
TextWithEntities PremiumGift::title() { TextWithEntities PremiumGift::title() {
using namespace Ui::Text; using namespace Ui::Text;
if (tonGift()) { if (tonGift()) {
return { Lang::FormatCreditsAmountWithCurrency( return tr::lng_gift_ton_amount(
CreditsAmount(0, _data.count, CreditsType::Ton)) }; tr::now,
lt_count_decimal,
CreditsAmount(0, _data.count, CreditsType::Ton).value(),
Ui::Text::WithEntities);
} else if (starGift()) { } else if (starGift()) {
const auto peer = _parent->history()->peer; const auto peer = _parent->history()->peer;
return peer->isSelf() return peer->isSelf()

View file

@ -214,24 +214,26 @@ auto GenerateSuggestDecisionMedia(
? st::chatSuggestInfoMiddleMargin ? st::chatSuggestInfoMiddleMargin
: st::chatSuggestInfoLastMargin)); : st::chatSuggestInfoLastMargin));
if (price) { if (price) {
const auto amount = Ui::Text::Bold(
Lang::FormatCreditsAmountWithCurrency(price));
pushText( pushText(
TextWithEntities( TextWithEntities(
).append(Emoji(kMoney)).append(' ').append( ).append(Emoji(kMoney)).append(' ').append(
(sublistPeer->isSelf() (sublistPeer->isSelf()
? tr::lng_suggest_action_your_charged( ? (price.stars()
tr::now, ? tr::lng_suggest_action_your_charged_stars
lt_amount, : tr::lng_suggest_action_your_charged_ton)(
amount, tr::now,
Ui::Text::WithEntities) lt_count_decimal,
: tr::lng_suggest_action_his_charged( price.value(),
tr::now, Ui::Text::RichLangValue)
lt_from, : (price.stars()
Ui::Text::Bold(sublistPeer->shortName()), ? tr::lng_suggest_action_his_charged_stars
lt_amount, : tr::lng_suggest_action_his_charged_ton)(
amount, tr::now,
Ui::Text::WithEntities))), lt_count_decimal,
price.value(),
lt_from,
Ui::Text::Bold(sublistPeer->shortName()),
Ui::Text::RichLangValue))),
st::chatSuggestInfoMiddleMargin); st::chatSuggestInfoMiddleMargin);
pushText( pushText(
@ -330,7 +332,15 @@ auto GenerateSuggestRequestMedia(
: tr::lng_suggest_action_price_label)(tr::now), : tr::lng_suggest_action_price_label)(tr::now),
Ui::Text::Bold(!suggest->price Ui::Text::Bold(!suggest->price
? tr::lng_suggest_action_price_free(tr::now) ? tr::lng_suggest_action_price_free(tr::now)
: Lang::FormatCreditsAmountWithCurrency(suggest->price)), : suggest->price.stars()
? tr::lng_suggest_stars_amount(
tr::now,
lt_count_decimal,
suggest->price.value())
: tr::lng_suggest_ton_amount(
tr::now,
lt_count_decimal,
suggest->price.value())),
}); });
entries.push_back({ entries.push_back({
((changes && changes->date) ((changes && changes->date)

View file

@ -968,15 +968,6 @@ QString FormatCreditsAmountRounded(CreditsAmount amount) {
return FormatExactCountDecimal(base::SafeRound(value * 100.) / 100.); return FormatExactCountDecimal(base::SafeRound(value * 100.) / 100.);
} }
QString FormatCreditsAmountWithCurrency(CreditsAmount amount) {
return (amount.ton()
? tr::lng_suggest_ton_amount
: tr::lng_prize_credits_amount)(
tr::now,
lt_count_decimal,
amount.value());
}
PluralResult Plural( PluralResult Plural(
ushort keyBase, ushort keyBase,
float64 value, float64 value,

View file

@ -34,8 +34,6 @@ struct ShortenedCount {
[[nodiscard]] QString FormatCreditsAmountDecimal(CreditsAmount amount); [[nodiscard]] QString FormatCreditsAmountDecimal(CreditsAmount amount);
[[nodiscard]] QString FormatCreditsAmountRounded(CreditsAmount amount); [[nodiscard]] QString FormatCreditsAmountRounded(CreditsAmount amount);
[[nodiscard]] QString FormatCreditsAmountWithCurrency(CreditsAmount amount);
struct PluralResult { struct PluralResult {
int keyShift = 0; int keyShift = 0;
QString replacement; QString replacement;