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_and_one" = "{tasks}, {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_admin" = "Admin deleted the post early so that the price was refunded to the user.";
"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_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_subtitle" = "Gift Premium";
"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_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_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_offer" = "Offer {amount}";
"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_agreement" = "Agreement reached!";
"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_his_charged" = "{from} have been charged {amount}.";
"lng_suggest_action_your_charged_stars#one" = "You have been charged **{count} Star**.";
"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_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.";
@ -4501,12 +4516,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_suggest_accept_title" = "Accept Terms";
"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_receive" = "{channel} will receive {amount} ({percent}) for publishing {date}.";
"lng_suggest_accept_receive_now" = "{channel} will receive {amount} ({percent}) for publishing right now.";
"lng_suggest_accept_receive_stars#one" = "{channel} will receive **{count} Star** ({percent}) for publishing {date}.";
"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_pay" = "You will pay {amount} for publishing {date}.";
"lng_suggest_accept_pay_now" = "You will pay {amount} for publishing right now.";
"lng_suggest_accept_pay_stars#one" = "You will pay **{count} Star** for publishing {date}.";
"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_stars_amount#one" = "{count} Star";
"lng_suggest_stars_amount#other" = "{count} Stars";
"lng_suggest_ton_amount#one" = "{count} TON";
"lng_suggest_ton_amount#other" = "{count} TON";
"lng_suggest_warn_title_stars" = "Stars will be lost";

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -968,15 +968,6 @@ QString FormatCreditsAmountRounded(CreditsAmount amount) {
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(
ushort keyBase,
float64 value,

View file

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