From ec8d9c75232a8e08233bfd6a9607611e609ddd4e Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Wed, 25 Aug 2021 21:30:11 +0300 Subject: [PATCH] Use proper localization in new notification mute time selector --- Telegram/Resources/langs/rewrites/en.json | 32 +++++++++++++++++++ Telegram/Resources/langs/rewrites/ru.json | 32 +++++++++++++++++++ .../SourceFiles/boxes/mute_settings_box.cpp | 20 +++--------- 3 files changed, 68 insertions(+), 16 deletions(-) diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index f72ede861..befc59600 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -228,5 +228,37 @@ "ktg_reminder_preview": "Remind with preview", "ktg_schedule_preview": "Send preview scheduled", "ktg_language_reloaded": "Kotatogram-specific language strings were reloaded.", + "ktg_notifications_mute_seconds": { + "zero": "seconds", + "one": "second", + "two": "seconds", + "few": "seconds", + "many": "seconds", + "other": "seconds" + }, + "ktg_notifications_mute_minutes": { + "zero": "minutes", + "one": "minute", + "two": "minutes", + "few": "minutes", + "many": "minutes", + "other": "minutes" + }, + "ktg_notifications_mute_hours": { + "zero": "hours", + "one": "hour", + "two": "hours", + "few": "hours", + "many": "hours", + "other": "hours" + }, + "ktg_notifications_mute_days": { + "zero": "days", + "one": "day", + "two": "days", + "few": "days", + "many": "days", + "other": "days" + }, "dummy_last_string": "" } diff --git a/Telegram/Resources/langs/rewrites/ru.json b/Telegram/Resources/langs/rewrites/ru.json index 080856de9..b8395a509 100644 --- a/Telegram/Resources/langs/rewrites/ru.json +++ b/Telegram/Resources/langs/rewrites/ru.json @@ -228,5 +228,37 @@ "ktg_reminder_preview": "Напомнить с помощью превью", "ktg_schedule_preview": "Отправить превью позже", "ktg_language_reloaded": "Языковые строки Kotatogram были перезагружены.", + "ktg_notifications_mute_seconds": { + "zero": "секунд", + "one": "секунда", + "two": "секунды", + "few": "секунды", + "many": "секунд", + "other": "секунды" + }, + "ktg_notifications_mute_minutes": { + "zero": "минут", + "one": "минута", + "two": "минуты", + "few": "минуты", + "many": "минут", + "other": "минуты" + }, + "ktg_notifications_mute_hours": { + "zero": "часов", + "one": "час", + "two": "часа", + "few": "часа", + "many": "часов", + "other": "часа" + }, + "ktg_notifications_mute_days": { + "zero": "дней", + "one": "день", + "two": "дня", + "few": "дня", + "many": "дней", + "other": "дня" + }, "dummy_last_string": "" } diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index f02ea044a..02ce65c35 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -65,25 +65,13 @@ void MuteSettingsBox::prepare() { const auto group = std::make_shared(kForeverHours); y += st::boxOptionListPadding.top(); - const auto trimLangStr = [] (const QString &numberStr, const QString &langStr) { - return langStr.mid(numberStr.length()).trimmed(); - }; - const auto makePeriodText = [=, this] (Period period) { const auto currentValue = _forNumberInput->getLastText().toInt(); - const auto currentStrValue = QString::number(currentValue); // re-converting to get rid of the invalid symbols switch (period) { - case Period::Second: - return trimLangStr(currentStrValue, tr::lng_group_call_duration_seconds(tr::now, lt_count, currentValue)); - - case Period::Minute: - return trimLangStr(currentStrValue, tr::lng_group_call_duration_minutes(tr::now, lt_count, currentValue)); - - case Period::Hour: - return trimLangStr(currentStrValue, tr::lng_group_call_duration_hours(tr::now, lt_count, currentValue)); - - case Period::Day: - return trimLangStr(currentStrValue, tr::lng_group_call_duration_days(tr::now, lt_count, currentValue)); + case Period::Second: return ktr("ktg_notifications_mute_seconds", currentValue); + case Period::Minute: return ktr("ktg_notifications_mute_minutes", currentValue); + case Period::Hour: return ktr("ktg_notifications_mute_hours", currentValue); + case Period::Day: return ktr("ktg_notifications_mute_days", currentValue); default: return QString();