Unified general phrases for duration.

This commit is contained in:
23rd 2022-03-31 19:45:11 +03:00 committed by John Preston
parent fb750b69e3
commit d9541b6a6e
17 changed files with 61 additions and 153 deletions

View file

@ -84,6 +84,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_calendar_days#one" = "{count} day";
"lng_calendar_days#other" = "{count} days";
"lng_seconds#one" = "{count} second";
"lng_seconds#other" = "{count} seconds";
"lng_minutes#one" = "{count} minute";
"lng_minutes#other" = "{count} minutes";
"lng_hours#one" = "{count} hour";
"lng_hours#other" = "{count} hours";
"lng_days#one" = "{count} day";
"lng_days#other" = "{count} days";
"lng_weeks#one" = "{count} week";
"lng_weeks#other" = "{count} weeks";
"lng_months#one" = "{count} month";
"lng_months#other" = "{count} months";
"lng_years#one" = "{count} year";
"lng_years#other" = "{count} years";
"lng_seconds_tiny#one" = "{count}s";
"lng_seconds_tiny#other" = "{count}s";
"lng_minutes_tiny#one" = "{count}m";
@ -272,12 +287,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_signin_sure_reset" = "Warning!\n\nYou will lose all your chats and messages, along with any media and files you shared!\n\nDo you want to reset your account?";
"lng_signin_reset" = "Reset";
"lng_signin_reset_wait" = "Since the account {phone_number} is active and protected by a password, we will delete it in 1 week for security purposes. You can cancel this process at any time.\n\nYoull be able to reset your account in:\n{when}";
"lng_signin_reset_days#one" = "{count} day";
"lng_signin_reset_days#other" = "{count} days";
"lng_signin_reset_hours#one" = "{count} hour";
"lng_signin_reset_hours#other" = "{count} hours";
"lng_signin_reset_minutes#one" = "{count} minute";
"lng_signin_reset_minutes#other" = "{count} minutes";
"lng_signin_reset_in_days" = "{days_count} {hours_count} {minutes_count}";
"lng_signin_reset_in_hours" = "{hours_count} {minutes_count}";
"lng_signin_reset_cancelled" = "Your recent attempts to reset this account have been cancelled by its active user. Please try again in 7 days.";
@ -603,10 +612,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_local_storage_size_limit" = "Total size limit: {size}";
"lng_local_storage_media_limit" = "Media cache limit: {size}";
"lng_local_storage_time_limit" = "Clear files older than: {limit}";
"lng_local_storage_limit_weeks#one" = "{count} week";
"lng_local_storage_limit_weeks#other" = "{count} weeks";
"lng_local_storage_limit_months#one" = "{count} month";
"lng_local_storage_limit_months#other" = "{count} months";
"lng_local_storage_limit_never" = "Never";
"lng_local_storage_summary" = "Summary";
"lng_local_storage_clear_some" = "Clear";
@ -627,10 +632,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_passcode_autolock" = "Auto-Lock";
"lng_passcode_autolock_away" = "Auto-Lock if away for...";
"lng_passcode_autolock_inactive" = "Auto-Lock if inactive for...";
"lng_passcode_autolock_minutes#one" = "{count} minute";
"lng_passcode_autolock_minutes#other" = "{count} minutes";
"lng_passcode_autolock_hours#one" = "{count} hour";
"lng_passcode_autolock_hours#other" = "{count} hours";
"lng_passcode_autolock_hours_minutes" = "{hours_count}h {minutes_count}m";
"lng_passcode_enter_old" = "Enter current passcode";
"lng_passcode_enter_first" = "Enter a passcode";
@ -873,12 +874,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_self_destruct_description" = "If you don't come online at least once within this period, your account will be deleted along with all groups, messages and contacts.";
"lng_self_destruct_sessions_title" = "Session termination";
"lng_self_destruct_sessions_description" = "If you don't come online from a specific session at least once within this period, it will be terminated.";
"lng_self_destruct_weeks#one" = "{count} week";
"lng_self_destruct_weeks#other" = "{count} weeks";
"lng_self_destruct_months#one" = "{count} month";
"lng_self_destruct_months#other" = "{count} months";
"lng_self_destruct_years#one" = "{count} year";
"lng_self_destruct_years#other" = "{count} years";
"lng_change_phone_title" = "Change phone number";
"lng_change_phone_about" = "You can change your Telegram number\nhere. Your account and all your cloud data\n— messages, media, contacts, etc. will be\nmoved to the new number.\n\n**Important**: all your Telegram contacts will\nget your **new number** added to their address\nbook, provided they had your old number and\nyou haven't blocked them in Telegram.";
@ -902,12 +897,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_mute_menu_sound_on" = "Enable sound";
"lng_mute_menu_sound_off" = "Disable sound";
"lng_mute_box_title" = "Mute notifications for...";
"lng_mute_box_days#one" = "{count} day";
"lng_mute_box_days#other" = "{count} days";
"lng_mute_box_hours#one" = "{count} hour";
"lng_mute_box_hours#other" = "{count} hours";
"lng_mute_box_minutes#one" = "{count} minute";
"lng_mute_box_minutes#other" = "{count} minutes";
"lng_mute_duration_hours#one" = "For {count} hour";
"lng_mute_duration_hours#other" = "For {count} hours";
@ -1136,9 +1125,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_ttl_about_tooltip" = "New messages in this chat will be automatically deleted in {duration}.";
"lng_ttl_about_tooltip_channel" = "New messages in this chat will be automatically deleted in {duration}.";
"lng_ttl_about_tooltip_off" = "Auto-delete is now disabled.";
"lng_ttl_about_duration1" = "1 day";
"lng_ttl_about_duration2" = "1 week";
"lng_ttl_about_duration3" = "1 month";
"lng_report_title" = "Report channel";
"lng_report_group_title" = "Report group";
@ -1242,8 +1228,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_message_unsupported" = "This message is not supported by your version of Telegram Desktop. Please update to the latest version in Settings, or install it from {link}";
"lng_message_not_found" = "Message doesn't exist.";
"lng_duration_seconds#one" = "{count} second";
"lng_duration_seconds#other" = "{count} seconds";
"lng_duration_minsec_minutes#one" = "{count} min";
"lng_duration_minsec_minutes#other" = "{count} min";
"lng_duration_minsec_seconds#one" = "{count} sec";
@ -2368,14 +2352,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_call_context_remove" = "Remove";
"lng_group_call_remove_channel" = "Remove {channel} from the voice chat?";
"lng_group_call_remove_channel_from_channel" = "Remove {channel} from the live stream?";
"lng_group_call_duration_days#one" = "{count} day";
"lng_group_call_duration_days#other" = "{count} days";
"lng_group_call_duration_hours#one" = "{count} hour";
"lng_group_call_duration_hours#other" = "{count} hours";
"lng_group_call_duration_minutes#one" = "{count} minute";
"lng_group_call_duration_minutes#other" = "{count} minutes";
"lng_group_call_duration_seconds#one" = "{count} second";
"lng_group_call_duration_seconds#other" = "{count} seconds";
"lng_group_call_mac_access" = "Telegram Desktop does not have access to system wide keyboard input required for Push to Talk.";
"lng_group_call_mac_input" = "Please allow **Input Monitoring** for Telegram in Privacy Settings.";
"lng_group_call_mac_accessibility" = "Please allow **Accessibility** for Telegram in Privacy Settings.\n\nApp restart may be required.";
@ -2608,11 +2584,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_exceptions_list_title" = "Exceptions";
"lng_removed_list_title" = "Removed users";
"lng_admin_log_slow_mode_seconds#one" = "{count} second";
"lng_admin_log_slow_mode_seconds#other" = "{count} seconds";
"lng_admin_log_slow_mode_minutes#one" = "{count} minute";
"lng_admin_log_slow_mode_minutes#other" = "{count} minutes";
"lng_admin_log_title_all" = "All actions";
"lng_admin_log_title_selected" = "Selected actions";
"lng_admin_log_filter" = "Filter";
@ -2974,8 +2945,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_export_invalid" = "Sorry, you have started a new data export, so this data export is now cancelled.";
"lng_export_delay" = "Sorry, for security reasons, you will be able to begin downloading your data in {hours}. We have notified all your devices about the export request to make sure it's authorized and to give you time to react if it's not.\n\nPlease come back on {date} and repeat the request using the same device.";
"lng_export_delay_less_than_hour" = "less than an hour";
"lng_export_delay_hours#one" = "{count} hour";
"lng_export_delay_hours#other" = "{count} hours";
"lng_export_suggest_title" = "Data export ready";
"lng_export_suggest_text" = "You can now download the data you requested. Start exporting data?";
"lng_export_suggest_cancel" = "Not now";

View file

@ -53,8 +53,8 @@ void AutoLockBox::prepare() {
}
const auto minutes = (seconds % 3600);
return (minutes
? tr::lng_passcode_autolock_minutes
: tr::lng_passcode_autolock_hours)(
? tr::lng_minutes
: tr::lng_hours)(
tr::now,
lt_count,
minutes ? (seconds / 60) : (seconds / 3600));

View file

@ -104,9 +104,9 @@ QString TimeLimitText(size_type limit) {
const auto weeks = (days / 7);
const auto months = (days / 29);
return (months > 0)
? tr::lng_local_storage_limit_months(tr::now, lt_count, months)
? tr::lng_months(tr::now, lt_count, months)
: (limit > 0)
? tr::lng_local_storage_limit_weeks(tr::now, lt_count, weeks)
? tr::lng_weeks(tr::now, lt_count, weeks)
: tr::lng_local_storage_limit_never(tr::now);
}

View file

@ -131,13 +131,10 @@ void StartPendingReset(
const auto hours = (left / kHour);
const auto minutes = (left / kMinute);
const auto duration = days
? tr::lng_group_call_duration_days(tr::now, lt_count, days)
? tr::lng_days(tr::now, lt_count, days)
: hours
? tr::lng_group_call_duration_hours(tr::now, lt_count, hours)
: tr::lng_group_call_duration_minutes(
tr::now,
lt_count,
minutes);
? tr::lng_hours(tr::now, lt_count, hours)
: tr::lng_minutes(tr::now, lt_count, minutes);
if (const auto strong = weak.data()) {
strong->getDelegate()->show(Ui::MakeInformBox(
tr::lng_cloud_password_reset_later(

View file

@ -113,16 +113,10 @@ QString SelfDestructionBox::DaysLabel(int days) {
return !days
? QString()
: (days > 364)
? tr::lng_self_destruct_years(tr::now, lt_count, days / 365)
? tr::lng_years(tr::now, lt_count, days / 365)
: (days > 25)
? tr::lng_self_destruct_months(
tr::now,
lt_count,
qMax(days / 30, 1))
: tr::lng_self_destruct_weeks(
tr::now,
lt_count,
qMax(days / 7, 1));
? tr::lng_months(tr::now, lt_count, std::max(days / 30, 1))
: tr::lng_weeks(tr::now, lt_count, std::max(days / 7, 1));
}
void SelfDestructionBox::prepare() {

View file

@ -174,20 +174,11 @@ void ScheduleGroupCallBox(
const auto now = base::unixtime::now();
const auto duration = (date - now);
if (duration >= 24 * 60 * 60) {
return tr::lng_group_call_duration_days(
tr::now,
lt_count,
duration / (24 * 60 * 60));
return tr::lng_days(tr::now, lt_count, duration / (24 * 60 * 60));
} else if (duration >= 60 * 60) {
return tr::lng_group_call_duration_hours(
tr::now,
lt_count,
duration / (60 * 60));
return tr::lng_hours(tr::now, lt_count, duration / (60 * 60));
}
return tr::lng_group_call_duration_minutes(
tr::now,
lt_count,
std::max(duration / 60, 1));
return tr::lng_minutes(tr::now, lt_count, std::max(duration / 60, 1));
});
}

View file

@ -231,7 +231,7 @@ void PanelController::showError(const ApiErrorState &error) {
if (hours <= 0) {
return tr::lng_export_delay_less_than_hour(tr::now);
}
return tr::lng_export_delay_hours(tr::now, lt_count, hours);
return tr::lng_hours(tr::now, lt_count, hours);
}();
showError(tr::lng_export_delay(
tr::now,

View file

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "data/data_session.h"
#include "lang/lang_keys.h"
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h"
#include "ui/basic_click_handlers.h"
#include "boxes/sticker_set_box.h"
@ -1124,14 +1125,8 @@ void GenerateItems(
const auto createToggleSlowMode = [&](const LogSlowMode &action) {
if (const auto seconds = action.vnew_value().v) {
const auto duration = (seconds >= 60)
? tr::lng_admin_log_slow_mode_minutes(
tr::now,
lt_count,
seconds / 60)
: tr::lng_admin_log_slow_mode_seconds(
tr::now,
lt_count,
seconds);
? tr::lng_minutes(tr::now, lt_count, seconds / 60)
: tr::lng_seconds(tr::now, lt_count, seconds);
const auto text = tr::lng_admin_log_changed_slow_mode(
tr::now,
lt_from,
@ -1348,11 +1343,7 @@ void GenerateItems(
const auto wrap = [](int duration) -> TextWithEntities {
const auto text = (duration == 5)
? u"5 seconds"_q
: (duration < 2 * 86400)
? tr::lng_manage_messages_ttl_after1(tr::now)
: (duration < 8 * 86400)
? tr::lng_manage_messages_ttl_after2(tr::now)
: tr::lng_manage_messages_ttl_after3(tr::now);
: Ui::FormatTTL(duration);
return { .text = text };
};
const auto text = !was

View file

@ -448,12 +448,12 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
const auto hours = seconds / 3600;
const auto minutes = seconds / 60;
auto text = (days > 1)
? tr::lng_group_call_duration_days(tr::now, lt_count, days)
? tr::lng_days(tr::now, lt_count, days)
: (hours > 1)
? tr::lng_group_call_duration_hours(tr::now, lt_count, hours)
? tr::lng_hours(tr::now, lt_count, hours)
: (minutes > 1)
? tr::lng_group_call_duration_minutes(tr::now, lt_count, minutes)
: tr::lng_group_call_duration_seconds(tr::now, lt_count, seconds);
? tr::lng_minutes(tr::now, lt_count, minutes)
: tr::lng_seconds(tr::now, lt_count, seconds);
if (history()->peer->isBroadcast()) {
result.text = tr::lng_action_group_call_finished(
tr::now,
@ -508,11 +508,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
const auto period = action.vperiod().v;
const auto duration = (period == 5)
? u"5 seconds"_q
: (period < 2 * 86400)
? tr::lng_ttl_about_duration1(tr::now)
: (period < 8 * 86400)
? tr::lng_ttl_about_duration2(tr::now)
: tr::lng_ttl_about_duration3(tr::now);
: Ui::FormatTTL(period);
if (isPost()) {
if (!period) {
result.text = tr::lng_action_ttl_removed_channel(

View file

@ -518,16 +518,13 @@ void Widget::resetAccount() {
const auto days = (seconds + 59) / 86400;
const auto hours = ((seconds + 59) % 86400) / 3600;
const auto minutes = ((seconds + 59) % 3600) / 60;
auto when = tr::lng_signin_reset_minutes(
tr::now,
lt_count,
minutes);
auto when = tr::lng_minutes(tr::now, lt_count, minutes);
if (days > 0) {
const auto daysCount = tr::lng_signin_reset_days(
const auto daysCount = tr::lng_days(
tr::now,
lt_count,
days);
const auto hoursCount = tr::lng_signin_reset_hours(
const auto hoursCount = tr::lng_hours(
tr::now,
lt_count,
hours);
@ -540,7 +537,7 @@ void Widget::resetAccount() {
lt_minutes_count,
when);
} else if (hours > 0) {
const auto hoursCount = tr::lng_signin_reset_hours(
const auto hoursCount = tr::lng_hours(
tr::now,
lt_count,
hours);

View file

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/text/format_values.h"
#include "styles/style_chat.h"
#include "styles/style_menu_icons.h"
@ -37,11 +38,7 @@ void ShowAutoDeleteToast(
const auto duration = (period == 5)
? u"5 seconds"_q
: (period < 2 * 86400)
? tr::lng_ttl_about_duration1(tr::now)
: (period < 8 * 86400)
? tr::lng_ttl_about_duration2(tr::now)
: tr::lng_ttl_about_duration3(tr::now);
: Ui::FormatTTL(period);
const auto text = peer->isBroadcast()
? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration)
: tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration);

View file

@ -284,14 +284,8 @@ void SetupLocalPasscode(
lt_minutes_count,
QString::number(minutes))
: minutes
? tr::lng_passcode_autolock_minutes(
tr::now,
lt_count,
minutes)
: tr::lng_passcode_autolock_hours(
tr::now,
lt_count,
hours);
? tr::lng_minutes(tr::now, lt_count, minutes)
: tr::lng_hours(tr::now, lt_count, hours);
});
AddButtonWithLabel(
@ -511,13 +505,13 @@ void SetupCloudPassword(
const auto hours = left / kHour;
const auto minutes = left / kMinute;
return days
? tr::lng_group_call_duration_days(tr::now, lt_count, days)
? tr::lng_days(tr::now, lt_count, days)
: hours
? tr::lng_group_call_duration_hours(tr::now, lt_count, hours)
? tr::lng_hours(tr::now, lt_count, hours)
: minutes
? tr::lng_group_call_duration_minutes(tr::now, lt_count, minutes)
? tr::lng_minutes(tr::now, lt_count, minutes)
: left
? tr::lng_group_call_duration_seconds(tr::now, lt_count, left)
? tr::lng_seconds(tr::now, lt_count, left)
: QString();
});

View file

@ -79,14 +79,14 @@ ChooseTimeResult ChooseTimeWidget(
const auto hour = Ui::MakeWeak(state->hour);
const auto minute = Ui::MakeWeak(state->minute);
day->setPhrase(tr::lng_mute_box_days);
day->setPhrase(tr::lng_days);
day->setMaxValue(31);
day->setWheelStep(1);
day->putNext() | rpl::start_with_next([=](QChar ch) {
putNext(hour, ch);
}, content->lifetime());
hour->setPhrase(tr::lng_mute_box_hours);
hour->setPhrase(tr::lng_hours);
hour->setMaxValue(23);
hour->setWheelStep(1);
hour->putNext() | rpl::start_with_next([=](QChar ch) {
@ -96,7 +96,7 @@ ChooseTimeResult ChooseTimeWidget(
erasePrevious(day);
}, content->lifetime());
minute->setPhrase(tr::lng_mute_box_minutes);
minute->setPhrase(tr::lng_minutes);
minute->setMaxValue(59);
minute->setWheelStep(10);
minute->erasePrevious() | rpl::start_with_next([=] {

View file

@ -30,20 +30,11 @@ constexpr auto kMaxLabelLength = 32;
if (date > 0) {
return langDateTime(base::unixtime::parse(date));
} else if (-date < kDay) {
return tr::lng_group_call_duration_hours(
tr::now,
lt_count,
(-date / kHour));
return tr::lng_hours(tr::now, lt_count, (-date / kHour));
} else if (-date < 7 * kDay) {
return tr::lng_group_call_duration_days(
tr::now,
lt_count,
(-date / kDay));
return tr::lng_days(tr::now, lt_count, (-date / kDay));
} else {
return tr::lng_local_storage_limit_weeks(
tr::now,
lt_count,
(-date / (7 * kDay)));
return tr::lng_weeks(tr::now, lt_count, (-date / (7 * kDay)));
}
}

View file

@ -69,12 +69,9 @@ void GroupCallScheduledLeft::update() {
constexpr auto kDay = 24 * 60 * 60;
if (left >= kDay) {
const auto days = (left / kDay);
_textNonNegative = tr::lng_group_call_duration_days(
tr::now,
lt_count,
days);
_textNonNegative = tr::lng_days(tr::now, lt_count, days);
_text = late
? tr::lng_group_call_duration_days(tr::now, lt_count, -days)
? tr::lng_days(tr::now, lt_count, -days)
: _textNonNegative.current();
} else {
const auto hours = left / (60 * 60);

View file

@ -137,10 +137,7 @@ void ActionWithTimer::refreshAutoDeleteText() {
const auto left = (_destroyAt > now) ? (_destroyAt - now) : 0;
const auto text = [&] {
const auto duration = (left >= 86400)
? tr::lng_group_call_duration_days(
tr::now,
lt_count,
((left + 43200) / 86400))
? tr::lng_days(tr::now, lt_count, ((left + 43200) / 86400))
: (left >= 3600)
? QString("%1:%2:%3"
).arg(left / 3600
@ -191,10 +188,7 @@ void ActionWithTimer::prepare() {
+ padding.right();
};
const auto maxWidth1 = ttlMaxWidth("23:59:59");
const auto maxWidth2 = ttlMaxWidth(tr::lng_group_call_duration_days(
tr::now,
lt_count,
7));
const auto maxWidth2 = ttlMaxWidth(tr::lng_days(tr::now, lt_count, 7));
const auto w = std::clamp(
std::max({ goodWidth, maxWidth1, maxWidth2 }),

View file

@ -117,7 +117,7 @@ QString FormatDurationWords(qint64 duration) {
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_duration_seconds(tr::now, lt_count, duration);
return tr::lng_seconds(tr::now, lt_count, duration);
}
QString FormatDurationAndSizeText(qint64 duration, qint64 size) {