Add a distinct "N seconds" key for the slowmode phrase.

This commit is contained in:
John Preston 2022-09-10 08:19:26 +04:00
parent 2b6b1d7611
commit 3129d9f0df
6 changed files with 19 additions and 5 deletions

View file

@ -2822,6 +2822,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_slowmode_enabled"= "Slow mode is enabled. You can send your next message in {left}.";
"lng_slowmode_no_many" = "Slow mode is enabled. You can't send more than one message at a time.";
"lng_slowmode_too_long" = "Sorry, this text is too long to send as one message.\n\nSlow mode is enabled. You can't send more than one message at a time.";
"lng_slowmode_seconds#one" = "{count} second";
"lng_slowmode_seconds#other" = "{count} seconds";
"lng_rights_gigagroup_title" = "Broadcast group";
"lng_rights_gigagroup_convert" = "Convert to Broadcast Group";

View file

@ -166,7 +166,7 @@ QString GetErrorTextForSending(
return tr::lng_slowmode_enabled(
tr::now,
lt_left,
Ui::FormatDurationWords(left));
Ui::FormatDurationWordsSlowmode(left));
}
}

View file

@ -4951,7 +4951,7 @@ bool HistoryWidget::showSendingFilesError(
return tr::lng_slowmode_enabled(
tr::now,
lt_left,
Ui::FormatDurationWords(left));
Ui::FormatDurationWordsSlowmode(left));
}
using Error = Ui::PreparedList::Error;
switch (list.error) {
@ -6236,7 +6236,7 @@ bool HistoryWidget::showSlowmodeError() {
return tr::lng_slowmode_enabled(
tr::now,
lt_left,
Ui::FormatDurationWords(left));
Ui::FormatDurationWordsSlowmode(left));
} else if (_peer->slowmodeApplied()) {
if (const auto item = _history->latestSendingMessage()) {
if (const auto view = item->mainView()) {

View file

@ -841,7 +841,7 @@ bool RepliesWidget::showSlowmodeError() {
return tr::lng_slowmode_enabled(
tr::now,
lt_left,
Ui::FormatDurationWords(left));
Ui::FormatDurationWordsSlowmode(left));
} else if (_history->peer->slowmodeApplied()) {
if (const auto item = _history->latestSendingMessage()) {
showAtPositionNow(item->position(), nullptr);
@ -938,7 +938,7 @@ bool RepliesWidget::showSendingFilesError(
return tr::lng_slowmode_enabled(
tr::now,
lt_left,
Ui::FormatDurationWords(left));
Ui::FormatDurationWordsSlowmode(left));
}
using Error = Ui::PreparedList::Error;
switch (list.error) {

View file

@ -120,6 +120,17 @@ QString FormatDurationWords(qint64 duration) {
return tr::lng_seconds(tr::now, lt_count, duration);
}
QString FormatDurationWordsSlowmode(qint64 duration) {
if (duration > 59) {
auto minutes = (duration / 60);
auto minutesCount = tr::lng_duration_minsec_minutes(tr::now, lt_count, minutes);
auto seconds = (duration % 60);
auto secondsCount = tr::lng_duration_minsec_seconds(tr::now, lt_count, seconds);
return tr::lng_duration_minutes_seconds(tr::now, lt_minutes_count, minutesCount, lt_seconds_count, secondsCount);
}
return tr::lng_slowmode_seconds(tr::now, lt_count, duration);
}
QString FormatDurationAndSizeText(qint64 duration, qint64 size) {
return tr::lng_duration_and_size(tr::now, lt_duration, FormatDurationText(duration), lt_size, FormatSizeText(size));
}

View file

@ -22,6 +22,7 @@ inline constexpr auto FileStatusSizeFailed = 0xFFFFFFF2LL;
QString timeFormat);
[[nodiscard]] QString FormatDurationText(qint64 duration);
[[nodiscard]] QString FormatDurationWords(qint64 duration);
[[nodiscard]] QString FormatDurationWordsSlowmode(qint64 duration);
[[nodiscard]] QString FormatDurationAndSizeText(qint64 duration, qint64 size);
[[nodiscard]] QString FormatGifAndSizeText(qint64 size);
[[nodiscard]] QString FormatPlayedText(qint64 played, qint64 duration);