From 4917ca7b32edceb6e94028b3bded2c8754a32b37 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 19 Jun 2019 18:39:25 +0200 Subject: [PATCH] Remove all legacy global namespace langs. --- Telegram/SourceFiles/apiwrap.cpp | 3 +- Telegram/SourceFiles/boxes/about_box.cpp | 2 +- .../SourceFiles/boxes/add_contact_box.cpp | 17 ++- .../SourceFiles/boxes/auto_download_box.cpp | 3 +- Telegram/SourceFiles/boxes/auto_lock_box.cpp | 2 +- .../SourceFiles/boxes/change_phone_box.cpp | 3 +- Telegram/SourceFiles/boxes/confirm_box.cpp | 20 +-- .../SourceFiles/boxes/confirm_phone_box.cpp | 8 +- Telegram/SourceFiles/boxes/connection_box.cpp | 6 +- .../SourceFiles/boxes/create_poll_box.cpp | 2 +- .../SourceFiles/boxes/edit_privacy_box.cpp | 4 +- .../SourceFiles/boxes/local_storage_box.cpp | 22 ++-- .../SourceFiles/boxes/mute_settings_box.cpp | 4 +- Telegram/SourceFiles/boxes/passcode_box.cpp | 4 +- Telegram/SourceFiles/boxes/peer_list_box.cpp | 2 +- .../boxes/peer_list_controllers.cpp | 6 +- .../boxes/peers/add_participants_box.cpp | 7 +- .../boxes/peers/edit_contact_box.cpp | 6 +- .../boxes/peers/edit_participant_box.cpp | 14 +- .../boxes/peers/edit_participants_box.cpp | 22 ++-- .../boxes/self_destruction_box.cpp | 4 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 8 +- Telegram/SourceFiles/boxes/stickers_box.cpp | 2 +- Telegram/SourceFiles/boxes/url_auth_box.cpp | 8 +- .../calls/calls_box_controller.cpp | 6 +- Telegram/SourceFiles/calls/calls_call.cpp | 4 +- Telegram/SourceFiles/calls/calls_instance.cpp | 2 +- Telegram/SourceFiles/calls/calls_panel.cpp | 2 +- .../chat_helpers/emoji_sets_manager.cpp | 5 +- .../chat_helpers/stickers_list_widget.cpp | 4 +- .../SourceFiles/codegen/lang/generator.cpp | 34 ++--- Telegram/SourceFiles/codegen/lang/generator.h | 1 - Telegram/SourceFiles/core/changelogs.cpp | 3 +- .../SourceFiles/core/click_handler_types.cpp | 2 +- .../SourceFiles/data/data_media_types.cpp | 39 +++--- .../SourceFiles/data/data_peer_values.cpp | 16 +-- Telegram/SourceFiles/data/data_user.cpp | 2 +- .../dialogs/dialogs_inner_widget.cpp | 6 +- .../SourceFiles/dialogs/dialogs_layout.cpp | 4 +- Telegram/SourceFiles/dialogs/dialogs_row.cpp | 5 +- .../view/export_view_panel_controller.cpp | 5 +- .../export/view/export_view_settings.cpp | 2 +- .../admin_log/history_admin_log_item.cpp | 123 ++++++++++++------ Telegram/SourceFiles/history/history.cpp | 35 ++--- .../history/history_inner_widget.cpp | 11 +- Telegram/SourceFiles/history/history_item.cpp | 6 +- .../history/history_item_components.cpp | 19 ++- .../SourceFiles/history/history_service.cpp | 78 ++++++----- .../SourceFiles/history/history_widget.cpp | 12 +- .../history/media/history_media_call.cpp | 3 +- .../history/media/history_media_contact.cpp | 2 +- .../history/media/history_media_poll.cpp | 2 +- .../view/history_view_contact_status.cpp | 4 +- .../history/view/history_view_element.cpp | 2 +- .../view/history_view_top_bar_widget.cpp | 20 +-- .../info/media/info_media_buttons.h | 18 +-- .../info/profile/info_profile_actions.cpp | 10 +- .../info/profile/info_profile_cover.cpp | 4 +- .../info/profile/info_profile_members.cpp | 10 +- Telegram/SourceFiles/intro/introcode.cpp | 22 +++- Telegram/SourceFiles/intro/intropwdcheck.cpp | 15 ++- Telegram/SourceFiles/intro/introwidget.cpp | 54 ++++++-- Telegram/SourceFiles/lang/lang_keys.cpp | 73 +++++++++-- Telegram/SourceFiles/lang/lang_keys.h | 14 +- Telegram/SourceFiles/layout.cpp | 16 +-- Telegram/SourceFiles/mainwidget.cpp | 6 +- .../media/player/media_player_widget.cpp | 13 +- .../media/view/media_view_overlay_widget.cpp | 8 +- .../view/media_view_playback_controls.cpp | 3 +- .../SourceFiles/overview/overview_layout.cpp | 7 +- .../passport_form_view_controller.cpp | 3 +- .../passport/passport_panel_controller.cpp | 12 +- .../passport/passport_panel_edit_contact.cpp | 7 +- .../passport/passport_panel_edit_scans.cpp | 2 +- .../passport/passport_panel_form.cpp | 2 +- .../passport/passport_panel_password.cpp | 10 +- .../platform/mac/file_utilities_mac.mm | 4 +- .../platform/mac/main_window_mac.mm | 2 +- .../platform/win/main_window_win.cpp | 2 +- .../profile/profile_block_group_members.cpp | 2 +- .../settings/settings_advanced.cpp | 10 +- .../SourceFiles/settings/settings_calls.cpp | 4 +- .../settings/settings_privacy_controllers.cpp | 3 +- .../settings/settings_privacy_security.cpp | 6 +- .../SourceFiles/storage/localimageloader.cpp | 5 +- .../SourceFiles/support/support_helper.cpp | 9 +- Telegram/SourceFiles/ui/text/text_utilities.h | 19 ++- .../window/notifications_manager.cpp | 2 +- .../window/notifications_manager_default.cpp | 2 +- .../window/themes/window_theme_editor.cpp | 4 +- .../window/themes/window_theme_warning.cpp | 2 +- .../window/window_connecting_widget.cpp | 4 +- .../window/window_lock_widgets.cpp | 4 +- .../SourceFiles/window/window_main_menu.cpp | 2 +- .../window/window_outdated_bar.cpp | 2 +- .../SourceFiles/window/window_peer_menu.cpp | 10 +- 96 files changed, 638 insertions(+), 407 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index b90b3e91b..66a54f1b7 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -551,7 +551,8 @@ void ApiWrap::sendMessageFail(const RPCError &error) { const auto link = textcmdLink( Core::App().createInternalLinkFull(qsl("spambot")), tr::lng_cant_more_info(tr::now)); - Ui::show(Box(lng_error_public_groups_denied( + Ui::show(Box(tr::lng_error_public_groups_denied( + tr::now, lt_more_info, link))); } diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index 05a6ef1d8..d24d9f0f6 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -53,7 +53,7 @@ rpl::producer Text3() { } // namespace AboutBox::AboutBox(QWidget *parent) -: _version(this, lng_about_version(lt_version, currentVersionText()), st::aboutVersionLink) +: _version(this, tr::lng_about_version(tr::now, lt_version, currentVersionText()), st::aboutVersionLink) , _text1(this, Text1(), st::aboutLabel) , _text2(this, Text2(), st::aboutLabel) , _text3(this, Text3(), st::aboutLabel) { diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 9877d8b7f..71cc5b204 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -69,9 +69,9 @@ QString PeerFloodErrorText(PeerFloodType type) { Core::App().createInternalLinkFull(qsl("spambot")), tr::lng_cant_more_info(tr::now)); if (type == PeerFloodType::InviteGroup) { - return lng_cant_invite_not_contact(lt_more_info, link); + return tr::lng_cant_invite_not_contact(tr::now, lt_more_info, link); } - return lng_cant_send_to_not_contact(lt_more_info, link); + return tr::lng_cant_send_to_not_contact(tr::now, lt_more_info, link); } void ShowAddParticipantsError( @@ -245,7 +245,7 @@ void AddContactBox::paintEvent(QPaintEvent *e) { p.setPen(st::boxTextFg); p.setFont(st::boxTextFont); auto textHeight = height() - st::contactPadding.top() - st::contactPadding.bottom() - st::boxPadding.bottom(); - p.drawText(QRect(st::boxPadding.left(), st::contactPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), textHeight), lng_contact_not_joined(lt_name, _sentName), style::al_topleft); + p.drawText(QRect(st::boxPadding.left(), st::contactPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), textHeight), tr::lng_contact_not_joined(tr::now, lt_name, _sentName), style::al_topleft); } else { st::contactUserIcon.paint( p, @@ -1348,8 +1348,15 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) { auto pressed = base::take(_pressed); setCursor((_selected || _pressed) ? style::cur_pointer : style::cur_default); if (pressed && pressed == _selected) { - auto text_method = pressed->isMegagroup() ? lng_channels_too_much_public_revoke_confirm_group : lng_channels_too_much_public_revoke_confirm_channel; - auto text = text_method(lt_link, Core::App().createInternalLink(pressed->userName()), lt_group, pressed->name); + auto text_method = pressed->isMegagroup() + ? tr::lng_channels_too_much_public_revoke_confirm_group + : tr::lng_channels_too_much_public_revoke_confirm_channel; + auto text = text_method( + tr::now, + lt_link, + Core::App().createInternalLink(pressed->userName()), + lt_group, + pressed->name); auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now); _weakRevokeConfirmBox = Ui::show(Box(text, confirmText, crl::guard(this, [this, pressed]() { if (_revokeRequestId) return; diff --git a/Telegram/SourceFiles/boxes/auto_download_box.cpp b/Telegram/SourceFiles/boxes/auto_download_box.cpp index c47f85084..5e715a94e 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_download_box.cpp @@ -102,7 +102,8 @@ void AutoDownloadBox::setupContent() { limits->events_starting_with_copy( initialLimit ) | rpl::map([](int value) { - return lng_media_size_up_to( + return tr::lng_media_size_up_to( + tr::now, lt_size, QString::number(value / kMegabyte) + " MB"); }), diff --git a/Telegram/SourceFiles/boxes/auto_lock_box.cpp b/Telegram/SourceFiles/boxes/auto_lock_box.cpp index 0c1cf7978..ab4a1ccf2 100644 --- a/Telegram/SourceFiles/boxes/auto_lock_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_lock_box.cpp @@ -25,7 +25,7 @@ void AutoLockBox::prepare() { auto count = int(options.size()); _options.reserve(count); for (auto seconds : options) { - _options.emplace_back(this, group, seconds, (seconds % 3600) ? lng_passcode_autolock_minutes(lt_count, seconds / 60) : lng_passcode_autolock_hours(lt_count, seconds / 3600), st::autolockButton); + _options.emplace_back(this, group, seconds, (seconds % 3600) ? tr::lng_passcode_autolock_minutes(tr::now, lt_count, seconds / 60) : tr::lng_passcode_autolock_hours(tr::now, lt_count, seconds / 3600), st::autolockButton); _options.back()->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), y); y += _options.back()->heightNoMargins() + st::boxOptionListSkip; } diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 2180bc6b9..40ebc2c34 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -207,7 +207,8 @@ bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const return true; } else if (error.type() == qstr("PHONE_NUMBER_OCCUPIED")) { Ui::show(Box( - lng_change_phone_occupied( + tr::lng_change_phone_occupied( + tr::now, lt_phone, App::formatPhone(phoneNumber)), tr::lng_box_ok(tr::now))); diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 43d16cf8d..c80aea98b 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -315,7 +315,7 @@ InformBox::InformBox(QWidget*, const TextWithEntities &text, const QString &done MaxInviteBox::MaxInviteBox(QWidget*, not_null channel) : BoxContent() , _channel(channel) -, _text(st::boxLabelStyle, lng_participant_invite_sorry(lt_count, Global::ChatSizeMax()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) { +, _text(st::boxLabelStyle, tr::lng_participant_invite_sorry(tr::now, lt_count, Global::ChatSizeMax()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) { } void MaxInviteBox::prepare() { @@ -496,8 +496,8 @@ void DeleteMessagesBox::prepare() { details.text = peer->isSelf() ? tr::lng_sure_delete_saved_messages(tr::now) : peer->isUser() - ? lng_sure_delete_history(lt_contact, peer->name) - : lng_sure_delete_group_history(lt_group, peer->name); + ? tr::lng_sure_delete_history(tr::now, lt_contact, peer->name) + : tr::lng_sure_delete_group_history(tr::now, lt_group, peer->name); deleteStyle = &st::attentionBoxButton; } else { details.text = peer->isSelf() @@ -534,7 +534,7 @@ void DeleteMessagesBox::prepare() { } else { details.text = (_ids.size() == 1) ? tr::lng_selected_delete_sure_this(tr::now) - : lng_selected_delete_sure(lt_count, _ids.size()); + : tr::lng_selected_delete_sure(tr::now, lt_count, _ids.size()); if (const auto peer = checkFromSinglePeer()) { auto count = int(_ids.size()); if (auto revoke = revokeText(peer)) { @@ -542,12 +542,12 @@ void DeleteMessagesBox::prepare() { appendDetails(std::move(revoke->description)); } else if (peer && peer->isChannel()) { if (peer->isMegagroup()) { - appendDetails({ lng_delete_for_everyone_hint(lt_count, count) }); + appendDetails({ tr::lng_delete_for_everyone_hint(tr::now, lt_count, count) }); } } else if (peer->isChat()) { - appendDetails({ lng_delete_for_me_chat_hint(lt_count, count) }); + appendDetails({ tr::lng_delete_for_me_chat_hint(tr::now, lt_count, count) }); } else if (!peer->isSelf()) { - appendDetails({ lng_delete_for_me_hint(lt_count, count) }); + appendDetails({ tr::lng_delete_for_me_hint(tr::now, lt_count, count) }); } } } @@ -597,7 +597,8 @@ auto DeleteMessagesBox::revokeText(not_null peer) const if (!peer->canRevokeFullHistory()) { return std::nullopt; } else if (const auto user = peer->asUser()) { - result.checkbox = lng_delete_for_other_check( + result.checkbox = tr::lng_delete_for_other_check( + tr::now, lt_user, user->firstName); } else { @@ -637,7 +638,8 @@ auto DeleteMessagesBox::revokeText(not_null peer) const if (canRevokeAll) { if (const auto user = peer->asUser()) { - result.checkbox = lng_delete_for_other_check( + result.checkbox = tr::lng_delete_for_other_check( + tr::now, lt_user, user->firstName); } else { diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index 2f999fb60..d557fd81d 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -181,9 +181,9 @@ QString SentCodeCall::getText() const { switch (_status.state) { case State::Waiting: { if (_status.timeout >= 3600) { - return lng_code_call(lt_minutes, qsl("%1:%2").arg(_status.timeout / 3600).arg((_status.timeout / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(_status.timeout % 60, 2, 10, QChar('0'))); + return tr::lng_code_call(tr::now, lt_minutes, qsl("%1:%2").arg(_status.timeout / 3600).arg((_status.timeout / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(_status.timeout % 60, 2, 10, QChar('0'))); } - return lng_code_call(lt_minutes, QString::number(_status.timeout / 60), lt_seconds, qsl("%1").arg(_status.timeout % 60, 2, 10, QChar('0'))); + return tr::lng_code_call(tr::now, lt_minutes, QString::number(_status.timeout / 60), lt_seconds, qsl("%1").arg(_status.timeout % 60, 2, 10, QChar('0'))); } break; case State::Calling: return tr::lng_code_calling(tr::now); case State::Called: return tr::lng_code_called(tr::now); @@ -271,7 +271,7 @@ void ConfirmPhoneBox::prepare() { _about.create(this, st::confirmPhoneAboutLabel); TextWithEntities aboutText; auto formattedPhone = App::formatPhone(_phone); - aboutText.text = lng_confirm_phone_about(lt_phone, formattedPhone); + aboutText.text = tr::lng_confirm_phone_about(tr::now, lt_phone, formattedPhone); auto phonePosition = aboutText.text.indexOf(formattedPhone); if (phonePosition >= 0) { aboutText.entities.push_back({ EntityType::Bold, phonePosition, formattedPhone.size() }); @@ -321,7 +321,7 @@ void ConfirmPhoneBox::sendCode() { void ConfirmPhoneBox::confirmDone(const MTPBool &result) { _sendCodeRequestId = 0; - Ui::show(Box(lng_confirm_phone_success(lt_phone, App::formatPhone(_phone)))); + Ui::show(Box(tr::lng_confirm_phone_success(tr::now, lt_phone, App::formatPhone(_phone)))); } bool ConfirmPhoneBox::confirmFail(const RPCError &error) { diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index a48bc2d27..c3d264ef4 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -304,7 +304,8 @@ void ProxyRow::paintEvent(QPaintEvent *e) { const auto status = [&] { switch (_view.state) { case State::Available: - return lng_proxy_available( + return tr::lng_proxy_available( + tr::now, lt_ping, QString::number(_view.ping)); case State::Checking: @@ -952,7 +953,8 @@ void ProxiesBoxController::ShowApplyConfirmation( } if (proxy) { const auto box = std::make_shared>(); - const auto text = lng_sure_enable_socks( + const auto text = tr::lng_sure_enable_socks( + tr::now, lt_server, server, lt_port, diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 99fd36897..a152abc3a 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -654,7 +654,7 @@ object_ptr CreatePollBox::setupContent() { setCloseByOutsideClick(!count); }) | rpl::map([=](int count) { return (count < kMaxOptionsCount) - ? lng_polls_create_limit(lt_count, kMaxOptionsCount - count) + ? tr::lng_polls_create_limit(tr::now, lt_count, kMaxOptionsCount - count) : tr::lng_polls_create_maximum(tr::now); }) | rpl::after_next([=] { container->resizeToWidth(container->widthNoMargins()); diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 34e01263e..895bb43a9 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -95,7 +95,7 @@ std::unique_ptr PrivacyExceptionsBoxControl }(); if (count > 0) { result->setCustomStatus( - lng_chat_status_members(lt_count_decimal, count)); + tr::lng_chat_status_members(tr::now, lt_count_decimal, count)); } return result; } @@ -302,7 +302,7 @@ void EditPrivacyBox::setupContent() { return Settings::ExceptionUsersCount(exceptions(exception)); }) | rpl::map([](int count) { return count - ? lng_edit_privacy_exceptions_count(lt_count, count) + ? tr::lng_edit_privacy_exceptions_count(tr::now, lt_count, count) : tr::lng_edit_privacy_exceptions_add(tr::now); }); auto text = _controller->exceptionButtonTextKey(exception); diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index 747ed5293..fc50c9d4e 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -103,9 +103,9 @@ QString TimeLimitText(size_type limit) { const auto weeks = (days / 7); const auto months = (days / 29); return (months > 0) - ? lng_local_storage_limit_months(lt_count, months) + ? tr::lng_local_storage_limit_months(tr::now, lt_count, months) : (limit > 0) - ? lng_local_storage_limit_weeks(lt_count, weeks) + ? tr::lng_local_storage_limit_weeks(tr::now, lt_count, weeks) : tr::lng_local_storage_limit_never(tr::now); } @@ -390,7 +390,7 @@ void LocalStorageBox::setupControls() { const auto &data = (i != end(_stats.tagged)) ? i->second : empty; auto factory = std::forward(titleFactory); auto title = [factory = std::move(factory)](size_type count) { - return factory(lt_count, count); + return factory(tr::now, lt_count, count); }; tracker.track(createRow( tag, @@ -414,11 +414,11 @@ void LocalStorageBox::setupControls() { container, object_ptr(container), st::localStorageRowPadding)); - createTagRow(Data::kImageCacheTag, lng_local_storage_image); - createTagRow(Data::kStickerCacheTag, lng_local_storage_sticker); - createTagRow(Data::kVoiceMessageCacheTag, lng_local_storage_voice); - createTagRow(Data::kVideoMessageCacheTag, lng_local_storage_round); - createTagRow(Data::kAnimationCacheTag, lng_local_storage_animation); + createTagRow(Data::kImageCacheTag, tr::lng_local_storage_image); + createTagRow(Data::kStickerCacheTag, tr::lng_local_storage_sticker); + createTagRow(Data::kVoiceMessageCacheTag, tr::lng_local_storage_voice); + createTagRow(Data::kVideoMessageCacheTag, tr::lng_local_storage_round); + createTagRow(Data::kAnimationCacheTag, tr::lng_local_storage_animation); tracker.track(createRow( kFakeMediaCacheTag, std::move(mediaCacheTitle), @@ -506,14 +506,14 @@ void LocalStorageBox::updateTotalLabel() { Expects(_totalLabel != nullptr); const auto text = SizeLimitText(_totalSizeLimit); - _totalLabel->setText(lng_local_storage_size_limit(lt_size, text)); + _totalLabel->setText(tr::lng_local_storage_size_limit(tr::now, lt_size, text)); } void LocalStorageBox::updateMediaLabel() { Expects(_mediaLabel != nullptr); const auto text = SizeLimitText(_mediaSizeLimit); - _mediaLabel->setText(lng_local_storage_media_limit(lt_size, text)); + _mediaLabel->setText(tr::lng_local_storage_media_limit(tr::now, lt_size, text)); } void LocalStorageBox::setupLimits(not_null container) { @@ -555,7 +555,7 @@ void LocalStorageBox::setupLimits(not_null container) { [=](not_null label, size_type limit) { _timeLimit = ValueToLimit(limit); const auto text = TimeLimitText(_timeLimit); - label->setText(lng_local_storage_time_limit(lt_limit, text)); + label->setText(tr::lng_local_storage_time_limit(tr::now, lt_limit, text)); limitsChanged(); }); } diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index b17810897..55d1a4e4f 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -56,9 +56,9 @@ void MuteSettingsBox::prepare() { for (const auto hours : { 1, 4, 18, 72, kForeverHours }) { const auto text = [&] { if (hours < 24) { - return lng_mute_duration_hours(lt_count, hours); + return tr::lng_mute_duration_hours(tr::now, lt_count, hours); } else if (hours < kForeverHours) { - return lng_mute_duration_days(lt_count, hours / 24); + return tr::lng_mute_duration_days(tr::now, lt_count, hours / 24); } else { return tr::lng_mute_duration_forever(tr::now); } diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index f861d088a..684cb82b2 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -67,7 +67,7 @@ PasscodeBox::PasscodeBox(QWidget*, const CloudFields &fields) if (!_cloudFields.hint.isEmpty()) { _hintText.setText( st::passcodeTextStyle, - lng_signin_hint(lt_password_hint, _cloudFields.hint)); + tr::lng_signin_hint(tr::now, lt_password_hint, _cloudFields.hint)); } } @@ -912,7 +912,7 @@ RecoverBox::RecoverBox( QWidget*, const QString &pattern, bool notEmptyPassport) -: _pattern(st::normalFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() * 1.5)) +: _pattern(st::normalFont->elided(tr::lng_signin_recover_hint(tr::now, lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() * 1.5)) , _notEmptyPassport(notEmptyPassport) , _recoverCode(this, st::defaultInputField, tr::lng_signin_code()) { } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 46eac107c..0300b0987 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -389,7 +389,7 @@ void PeerListRow::refreshStatus() { if (!chat->amIn()) { setStatusText(tr::lng_chat_status_unaccessible(tr::now)); } else if (chat->count > 0) { - setStatusText(lng_chat_status_members(lt_count_decimal, chat->count)); + setStatusText(tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->count)); } else { setStatusText(tr::lng_group_status(tr::now)); } diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 9740882ae..17920ec5c 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -418,9 +418,9 @@ void AddBotToGroupBoxController::shareBotGame(not_null chat) { }); auto confirmText = [chat] { if (chat->isUser()) { - return lng_bot_sure_share_game(lt_user, App::peerName(chat)); + return tr::lng_bot_sure_share_game(tr::now, lt_user, App::peerName(chat)); } - return lng_bot_sure_share_game_group(lt_group, chat->name); + return tr::lng_bot_sure_share_game_group(tr::now, lt_group, chat->name); }(); Ui::show( Box(confirmText, std::move(send)), @@ -439,7 +439,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null chat) { auto send = crl::guard(this, [bot = _bot, chat] { AddBotToGroup(bot, chat); }); - auto confirmText = lng_bot_sure_invite(lt_group, chat->name); + auto confirmText = tr::lng_bot_sure_invite(tr::now, lt_group, chat->name); Ui::show( Box(confirmText, send), LayerOption::KeepOther); diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 6babe78bf..5120b0c0c 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -731,8 +731,11 @@ void AddSpecialBoxController::kickUser( // Finally kick him. if (!sure) { const auto text = ((_peer->isChat() || _peer->isMegagroup()) - ? lng_profile_sure_kick - : lng_profile_sure_kick_channel)(lt_user, App::peerName(user)); + ? tr::lng_profile_sure_kick + : tr::lng_profile_sure_kick_channel)( + tr::now, + lt_user, + App::peerName(user)); _editBox = Ui::show( Box(text, kickUserSure), LayerOption::KeepOther); diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index 2a57dc614..8f09dd7dd 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -203,7 +203,7 @@ void Controller::sendRequest(const QString &first, const QString &last) { weak->closeBox(); } if (!wasContact) { - Ui::Toast::Show(lng_new_contact_add_done(lt_user, first)); + Ui::Toast::Show(tr::lng_new_contact_add_done(tr::now, lt_user, first)); } }).fail([=](const RPCError &error) { }).send(); @@ -216,7 +216,7 @@ void Controller::setupWarning() { _box->addRow( object_ptr( _box, - lng_contact_phone_after(lt_user, _user->shortName()), + tr::lng_contact_phone_after(tr::now, lt_user, _user->shortName()), st::changePhoneLabel), st::addContactWarningMargin); } @@ -238,7 +238,7 @@ void Controller::setupSharePhoneNumber() { _box->addRow( object_ptr( _box, - lng_contact_phone_will_be_shared(lt_user, _user->shortName()), + tr::lng_contact_phone_will_be_shared(tr::now, lt_user, _user->shortName()), st::changePhoneLabel), st::addContactWarningMargin); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 0b414fdd8..63fd6732d 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -519,8 +519,11 @@ void EditAdminBox::sendTransferRequestFrom( )).done([=](const MTPUpdates &result) { api->applyUpdates(result); Ui::Toast::Show((channel->isBroadcast() - ? lng_rights_transfer_done_channel - : lng_rights_transfer_done_group)(lt_user, user->shortName())); + ? tr::lng_rights_transfer_done_channel + : tr::lng_rights_transfer_done_group)( + tr::now, + lt_user, + user->shortName())); Ui::hideLayer(); }).fail(crl::guard(this, [=](const RPCError &error) { if (weak) { @@ -744,7 +747,8 @@ void EditRestrictedBox::createUntilVariants() { && until <= to) { addVariant( until, - lng_rights_chat_banned_custom_date( + tr::lng_rights_chat_banned_custom_date( + tr::now, lt_date, langDayOfMonthFull(ParseDateTime(until).date()))); } @@ -765,9 +769,9 @@ void EditRestrictedBox::createUntilVariants() { auto nextDay = now + kSecondsInDay; auto nextWeek = now + kSecondsInWeek; addCurrentVariant(0, nextDay); - addVariant(kUntilOneDay, lng_rights_chat_banned_day(lt_count, 1)); + addVariant(kUntilOneDay, tr::lng_rights_chat_banned_day(tr::now, lt_count, 1)); addCurrentVariant(nextDay, nextWeek); - addVariant(kUntilOneWeek, lng_rights_chat_banned_week(lt_count, 1)); + addVariant(kUntilOneWeek, tr::lng_rights_chat_banned_week(tr::now, lt_count, 1)); addCurrentVariant(nextWeek, INT_MAX); addVariant(kUntilCustom, tr::lng_rights_chat_banned_custom(tr::now)); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 0744c4cb3..84f73ce51 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1554,8 +1554,11 @@ void ParticipantsBoxController::editRestrictedDone( void ParticipantsBoxController::kickMember(not_null user) { const auto text = ((_peer->isChat() || _peer->isMegagroup()) - ? lng_profile_sure_kick - : lng_profile_sure_kick_channel)(lt_user, user->firstName); + ? tr::lng_profile_sure_kick + : tr::lng_profile_sure_kick_channel)( + tr::now, + lt_user, + user->firstName); _editBox = Ui::show( Box( text, @@ -1598,7 +1601,8 @@ void ParticipantsBoxController::kickMemberSure(not_null user) { void ParticipantsBoxController::removeAdmin(not_null user) { _editBox = Ui::show( Box( - lng_profile_sure_remove_admin( + tr::lng_profile_sure_remove_admin( + tr::now, lt_user, user->firstName), tr::lng_box_remove(tr::now), @@ -1752,7 +1756,8 @@ void ParticipantsBoxController::refreshCustomStatus( const auto user = row->peer()->asUser(); if (_role == Role::Admins) { if (const auto by = _additional.adminPromotedBy(user)) { - row->setCustomStatus(lng_channel_admin_status_promoted_by( + row->setCustomStatus(tr::lng_channel_admin_status_promoted_by( + tr::now, lt_user, App::peerName(by))); } else { @@ -1767,10 +1772,11 @@ void ParticipantsBoxController::refreshCustomStatus( } else if (_role == Role::Kicked || _role == Role::Restricted) { const auto by = _additional.restrictedBy(user); row->setCustomStatus((_role == Role::Kicked - ? lng_channel_banned_status_removed_by - : lng_channel_banned_status_restricted_by)( - lt_user, - by ? App::peerName(by) : "Unknown")); + ? tr::lng_channel_banned_status_removed_by + : tr::lng_channel_banned_status_restricted_by)( + tr::now, + lt_user, + by ? App::peerName(by) : "Unknown")); } } diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index f3135ded6..adba8faa9 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -81,8 +81,8 @@ void SelfDestructionBox::showContent() { QString SelfDestructionBox::DaysLabel(int days) { return (days > 364) - ? lng_self_destruct_years(lt_count, days / 365) - : lng_self_destruct_months(lt_count, qMax(days / 30, 1)); + ? tr::lng_self_destruct_years(tr::now, lt_count, days / 365) + : tr::lng_self_destruct_months(tr::now, lt_count, qMax(days / 30, 1)); } void SelfDestructionBox::prepare() { diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 68d6f29a8..b0ea3da09 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1550,11 +1550,11 @@ void SendFilesBox::setupSendWayControls() { ? tr::lng_send_separate_photos_videos(tr::now) : (_list.albumIsPossible ? tr::lng_send_separate_photos(tr::now) - : lng_send_photos(lt_count, _list.files.size()))); + : tr::lng_send_photos(tr::now, lt_count, _list.files.size()))); } addRadio(_sendFiles, SendFilesWay::Files, (_list.files.size() == 1) ? tr::lng_send_file(tr::now) - : lng_send_files(lt_count, _list.files.size())); + : tr::lng_send_files(tr::now, lt_count, _list.files.size())); } void SendFilesBox::applyAlbumOrder() { @@ -1753,8 +1753,8 @@ void SendFilesBox::setupTitleText() { const auto onlyImages = (_compressConfirm != CompressConfirm::None) && (_albumVideosCount == 0); _titleText = onlyImages - ? lng_send_images_selected(lt_count, _list.files.size()) - : lng_send_files_selected(lt_count, _list.files.size()); + ? tr::lng_send_images_selected(tr::now, lt_count, _list.files.size()) + : tr::lng_send_files_selected(tr::now, lt_count, _list.files.size()); _titleHeight = st::boxTitleHeight; } else { _titleText = QString(); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 9c67d5281..868a242a5 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -886,7 +886,7 @@ void StickersBox::Inner::paintRow(Painter &p, Row *set, int index) { } } - auto statusText = (set->count > 0) ? lng_stickers_count(lt_count, set->count) : tr::lng_contacts_loading(tr::now); + auto statusText = (set->count > 0) ? tr::lng_stickers_count(tr::now, lt_count, set->count) : tr::lng_contacts_loading(tr::now); p.setFont(st::contactsStatusFont); p.setPen(st::contactsStatusFg); diff --git a/Telegram/SourceFiles/boxes/url_auth_box.cpp b/Telegram/SourceFiles/boxes/url_auth_box.cpp index ac82c2ba1..24efa3c25 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box.cpp @@ -148,7 +148,7 @@ not_null UrlAuthBox::setupContent( result->add( object_ptr( result, - lng_url_auth_open_confirm(lt_link, url), + tr::lng_url_auth_open_confirm(tr::now, lt_link, url), st::boxLabel), st::boxPadding); const auto addCheckbox = [&](const QString &text) { @@ -168,7 +168,8 @@ not_null UrlAuthBox::setupContent( return checkbox; }; const auto auth = addCheckbox( - lng_url_auth_login_option( + tr::lng_url_auth_login_option( + tr::now, lt_domain, textcmdStartSemibold() + domain + textcmdStopSemibold(), lt_user, @@ -176,7 +177,8 @@ not_null UrlAuthBox::setupContent( + App::peerName(Auth().user()) + textcmdStopSemibold()))); const auto allow = bot - ? addCheckbox(lng_url_auth_allow_messages( + ? addCheckbox(tr::lng_url_auth_allow_messages( + tr::now, lt_bot, textcmdStartSemibold() + bot->firstName + textcmdStopSemibold())) : nullptr; diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 7447c674b..9f93fb326 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -165,11 +165,11 @@ void BoxController::Row::refreshStatus() { auto time = ItemDateTime(_items.front()).time().toString(cTimeFormat()); auto today = QDateTime::currentDateTime().date(); if (_date == today) { - return lng_call_box_status_today(lt_time, time); + return tr::lng_call_box_status_today(tr::now, lt_time, time); } else if (_date.addDays(1) == today) { - return lng_call_box_status_yesterday(lt_time, time); + return tr::lng_call_box_status_yesterday(tr::now, lt_time, time); } - return lng_call_box_status_date(lt_date, langDayOfMonthFull(_date), lt_time, time); + return tr::lng_call_box_status_date(tr::now, lt_date, langDayOfMonthFull(_date), lt_time, time); }; setCustomStatus((_items.size() > 1) ? tr::lng_call_box_status_group( diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 57b932bed..12cfc94b5 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -872,9 +872,9 @@ void Call::setFailedQueued(int error) { void Call::handleRequestError(const RPCError &error) { if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) { - Ui::show(Box(lng_call_error_not_available(lt_user, App::peerName(_user)))); + Ui::show(Box(tr::lng_call_error_not_available(tr::now, lt_user, App::peerName(_user)))); } else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) { - Ui::show(Box(lng_call_error_outdated(lt_user, App::peerName(_user)))); + Ui::show(Box(tr::lng_call_error_outdated(tr::now, lt_user, App::peerName(_user)))); } else if (error.type() == qstr("CALL_PROTOCOL_LAYER_INVALID")) { Ui::show(Box(Lang::Hard::CallErrorIncompatible().replace("{user}", App::peerName(_user)))); } diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index 995ebc90b..0fade207c 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -39,7 +39,7 @@ void Instance::startOutgoingCall(not_null user) { if (user->callsStatus() == UserData::CallsStatus::Private) { // Request full user once more to refresh the setting in case it was changed. Auth().api().requestFullPeer(user); - Ui::show(Box(lng_call_error_not_available(lt_user, App::peerName(user)))); + Ui::show(Box(tr::lng_call_error_not_available(tr::now, lt_user, App::peerName(user)))); return; } requestMicrophonePermissionOrFail(crl::guard(this, [=] { diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index a061e91f6..11eb33091 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -811,7 +811,7 @@ void Panel::leaveToChildEvent(QEvent *e, QWidget *child) { } QString Panel::tooltipText() const { - return lng_call_fingerprint_tooltip(lt_user, App::peerName(_user)); + return tr::lng_call_fingerprint_tooltip(tr::now, lt_user, App::peerName(_user)); } QPoint Panel::tooltipPos() const { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 592bd2dcf..40e1ffb92 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -167,7 +167,7 @@ SetState ComputeState(int id) { QString StateDescription(const SetState &state) { return state.match([](const Available &data) { - return lng_emoji_set_download(lt_size, formatSizeText(data.size)); + return tr::lng_emoji_set_download(tr::now, lt_size, formatSizeText(data.size)); }, [](const Ready &data) -> QString { return tr::lng_emoji_set_ready(tr::now); }, [](const Active &data) -> QString { @@ -176,7 +176,8 @@ QString StateDescription(const SetState &state) { const auto percent = (data.size > 0) ? snap((data.already * 100) / float64(data.size), 0., 100.) : 0.; - return lng_emoji_set_loading( + return tr::lng_emoji_set_loading( + tr::now, lt_percent, QString::number(int(std::round(percent))) + '%', lt_progress, diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 88847338e..0bcbf6724 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1241,7 +1241,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) { } } - auto statusText = (size > 0) ? lng_stickers_count(lt_count, size) : tr::lng_contacts_loading(tr::now); + auto statusText = (size > 0) ? tr::lng_stickers_count(tr::now, lt_count, size) : tr::lng_contacts_loading(tr::now); p.setFont(st::stickersTrendingSubheaderFont); p.setPen(st::stickersTrendingSubheaderFg); p.drawTextLeft(st::emojiPanHeaderLeft - st::buttonRadius, info.top + st::stickersTrendingSubheaderTop, width(), statusText); @@ -2435,7 +2435,7 @@ void StickersListWidget::removeSet(uint64 setId) { auto it = sets.constFind(setId); if (it != sets.cend()) { _removingSetId = it->id; - auto text = lng_stickers_remove_pack(lt_sticker_pack, it->title); + auto text = tr::lng_stickers_remove_pack(tr::now, lt_sticker_pack, it->title); Ui::show(Box(text, tr::lng_stickers_remove_pack_confirm(tr::now), crl::guard(this, [=] { Ui::hideLayer(); auto &sets = Auth().data().stickerSetsRef(); diff --git a/Telegram/SourceFiles/codegen/lang/generator.cpp b/Telegram/SourceFiles/codegen/lang/generator.cpp index cdd8fef24..640056acf 100644 --- a/Telegram/SourceFiles/codegen/lang/generator.cpp +++ b/Telegram/SourceFiles/codegen/lang/generator.cpp @@ -108,7 +108,6 @@ bool Generator::writeHeader() { writeHeaderTagTypes(); writeHeaderInterface(); writeHeaderReactiveInterface(); - writeHeaderTaggedMethods(); return header_->finalize(); } @@ -116,8 +115,8 @@ bool Generator::writeHeader() { void Generator::writeHeaderForwardDeclarations() { header_->pushNamespace("Lang").stream() << "\ \n\ -inline constexpr ushort kTagsCount = " << langpack_.tags.size() << ";\n\ -inline constexpr ushort kKeysCount = " << langpack_.entries.size() << ";\n\ +inline constexpr auto kTagsCount = ushort(" << langpack_.tags.size() << ");\n\ +inline constexpr auto kKeysCount = ushort(" << langpack_.entries.size() << ");\n\ \n"; header_->popNamespace().newline(); } @@ -141,27 +140,6 @@ void Generator::writeHeaderTagTypes() { header_->newline(); } -void Generator::writeHeaderTaggedMethods() { - for (auto &entry : langpack_.entries) { - auto isPlural = !entry.keyBase.isEmpty(); - auto &key = entry.key; - auto params = QStringList(); - auto args = QStringList(); - for (auto &tagData : entry.tags) { - auto &tag = tagData.tag; - auto isPluralTag = isPlural && (tag == kPluralTags[0]); - params.push_back("lngtag_" + tag + (isPluralTag ? " type" : "") + ", " + (isPluralTag ? "float64 " : "const QString &") + tag + "__val"); - args.push_back((isPluralTag ? "type" : ("lt_" + tag)) + ", " + tag + "__val"); - } - if (!entry.tags.empty() && (!isPlural || key == ComputePluralKey(entry.keyBase, 0))) { - header_->stream() << "\ -inline QString " << (isPlural ? entry.keyBase : key) << "(" << params.join(QString(", ")) << ") {\n\ - return tr::" << (isPlural ? entry.keyBase : key) << "(tr::now, " << args.join(QString(", ")) << ");\n\ -}\n"; - } - } -} - void Generator::writeHeaderInterface() { header_->pushNamespace("Lang").stream() << "\ \n\ @@ -219,6 +197,12 @@ struct now_t {\n\ \n\ inline constexpr now_t now{};\n\ \n\ +inline auto to_count() {\n\ + return rpl::map([](auto value) {\n\ + return float64(value);\n\ + });\n\ +}\n\ +\n\ template \n\ struct phrase;\n\ \n"; @@ -297,6 +281,7 @@ inline constexpr phrase<" << tags.join(", ") << "> " << (isPlural ? entry.keyBas } void Generator::writeSourceLangKeyConstants() { + source_->newline(); auto index = 0; for (auto &entry : langpack_.entries) { source_->stream() << "constexpr auto " << getFullKey(entry) << " = ushort(" << (index++) << ");\n"; @@ -312,7 +297,6 @@ bool Generator::writeSource() { writeSourceLangKeyConstants(); source_->stream() << "\ -\n\ QChar DefaultData[] = {"; auto count = 0; auto fulllength = 0; diff --git a/Telegram/SourceFiles/codegen/lang/generator.h b/Telegram/SourceFiles/codegen/lang/generator.h index f7f6d0708..91ec94c73 100644 --- a/Telegram/SourceFiles/codegen/lang/generator.h +++ b/Telegram/SourceFiles/codegen/lang/generator.h @@ -31,7 +31,6 @@ public: private: void writeHeaderForwardDeclarations(); void writeHeaderTagTypes(); - void writeHeaderTaggedMethods(); void writeHeaderInterface(); void writeHeaderTagValueLookup(); void writeHeaderReactiveInterface(); diff --git a/Telegram/SourceFiles/core/changelogs.cpp b/Telegram/SourceFiles/core/changelogs.cpp index 9b3b81190..2e6f7f625 100644 --- a/Telegram/SourceFiles/core/changelogs.cpp +++ b/Telegram/SourceFiles/core/changelogs.cpp @@ -122,7 +122,8 @@ void Changelogs::addLocalLogs() { addBetaLogs(); } if (!_addedSomeLocal) { - const auto text = lng_new_version_wrap( + const auto text = tr::lng_new_version_wrap( + tr::now, lt_version, QString::fromLatin1(AppVersionStr), lt_changes, diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 651b9d386..15b4262a5 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -193,7 +193,7 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const { open(); }; Ui::show(Box( - lng_allow_bot_pass(lt_bot_name, _bot->name), + tr::lng_allow_bot_pass(tr::now, lt_bot_name, _bot->name), tr::lng_allow_bot(tr::now), callback)); } diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 8204944cd..bc271008d 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -90,15 +90,15 @@ QString WithCaptionDialogsText( return textcmdLink(1, TextUtilities::Clean(attachType)); } - auto captionText = TextUtilities::Clean(caption); - auto attachTypeWrapped = textcmdLink(1, lng_dialogs_text_media_wrapped( - lt_media, - TextUtilities::Clean(attachType))); - return lng_dialogs_text_media( + return tr::lng_dialogs_text_media( + tr::now, lt_media_part, - attachTypeWrapped, + textcmdLink(1, tr::lng_dialogs_text_media_wrapped( + tr::now, + lt_media, + TextUtilities::Clean(attachType))), lt_caption, - captionText); + TextUtilities::Clean(caption)); } QString WithCaptionNotificationText( @@ -108,12 +108,13 @@ QString WithCaptionNotificationText( return attachType; } - auto attachTypeWrapped = lng_dialogs_text_media_wrapped( - lt_media, - attachType); - return lng_dialogs_text_media( + return tr::lng_dialogs_text_media( + tr::now, lt_media_part, - attachTypeWrapped, + tr::lng_dialogs_text_media_wrapped( + tr::now, + lt_media, + attachType), lt_caption, caption); } @@ -586,7 +587,7 @@ QString MediaFile::notificationText() const { if (const auto sticker = _document->sticker()) { return _emoji.isEmpty() ? tr::lng_in_dlg_sticker(tr::now) - : lng_in_dlg_sticker_emoji(lt_emoji, _emoji); + : tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji); } const auto type = [&] { if (_document->isVideoMessage()) { @@ -610,7 +611,7 @@ QString MediaFile::notificationText() const { QString MediaFile::pinnedTextSubstring() const { if (const auto sticker = _document->sticker()) { if (!_emoji.isEmpty()) { - return lng_action_pinned_media_emoji_sticker(lt_emoji, _emoji); + return tr::lng_action_pinned_media_emoji_sticker(tr::now, lt_emoji, _emoji); } return tr::lng_action_pinned_media_sticker(tr::now); } else if (_document->isAnimation()) { @@ -636,7 +637,7 @@ TextForMimeData MediaFile::clipboardText() const { : QString(); if (const auto sticker = _document->sticker()) { if (!_emoji.isEmpty()) { - return lng_in_dlg_sticker_emoji(lt_emoji, _emoji); + return tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji); } return tr::lng_in_dlg_sticker(tr::now); } else if (_document->isAnimation()) { @@ -816,7 +817,8 @@ QString MediaContact::pinnedTextSubstring() const { TextForMimeData MediaContact::clipboardText() const { const auto text = qsl("[ ") + tr::lng_in_dlg_contact(tr::now) + qsl(" ]\n") - + lng_full_name( + + tr::lng_full_name( + tr::now, lt_first_name, _contact.firstName, lt_last_name, @@ -953,7 +955,8 @@ const Call *MediaCall::call() const { QString MediaCall::notificationText() const { auto result = Text(parent(), _call.finishReason); if (_call.duration > 0) { - result = lng_call_type_and_duration( + result = tr::lng_call_type_and_duration( + tr::now, lt_type, result, lt_duration, @@ -1133,7 +1136,7 @@ GameData *MediaGame::game() const { QString MediaGame::pinnedTextSubstring() const { const auto title = _game->title; - return lng_action_pinned_media_game(lt_game, title); + return tr::lng_action_pinned_media_game(tr::now, lt_game, title); } TextForMimeData MediaGame::clipboardText() const { diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index bbc6f3551..bd24cf948 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -299,23 +299,23 @@ QString OnlineText(TimeId online, TimeId now) { if (!minutes) { return tr::lng_status_lastseen_now(tr::now); } else if (minutes < 60) { - return lng_status_lastseen_minutes(lt_count, minutes); + return tr::lng_status_lastseen_minutes(tr::now, lt_count, minutes); } const auto hours = (now - online) / 3600; if (hours < 12) { - return lng_status_lastseen_hours(lt_count, hours); + return tr::lng_status_lastseen_hours(tr::now, lt_count, hours); } const auto onlineFull = ParseDateTime(online); const auto nowFull = ParseDateTime(now); if (onlineFull.date() == nowFull.date()) { const auto onlineTime = onlineFull.time().toString(cTimeFormat()); - return lng_status_lastseen_today(lt_time, onlineTime); + return tr::lng_status_lastseen_today(tr::now, lt_time, onlineTime); } else if (onlineFull.date().addDays(1) == nowFull.date()) { const auto onlineTime = onlineFull.time().toString(cTimeFormat()); - return lng_status_lastseen_yesterday(lt_time, onlineTime); + return tr::lng_status_lastseen_yesterday(tr::now, lt_time, onlineTime); } const auto date = onlineFull.date().toString(qsl("dd.MM.yy")); - return lng_status_lastseen_date(lt_date, date); + return tr::lng_status_lastseen_date(tr::now, lt_date, date); } QString OnlineText(not_null user, TimeId now) { @@ -335,14 +335,14 @@ QString OnlineTextFull(not_null user, TimeId now) { const auto nowFull = ParseDateTime(now); if (onlineFull.date() == nowFull.date()) { const auto onlineTime = onlineFull.time().toString(cTimeFormat()); - return lng_status_lastseen_today(lt_time, onlineTime); + return tr::lng_status_lastseen_today(tr::now, lt_time, onlineTime); } else if (onlineFull.date().addDays(1) == nowFull.date()) { const auto onlineTime = onlineFull.time().toString(cTimeFormat()); - return lng_status_lastseen_yesterday(lt_time, onlineTime); + return tr::lng_status_lastseen_yesterday(tr::now, lt_time, onlineTime); } const auto date = onlineFull.date().toString(qsl("dd.MM.yy")); const auto time = onlineFull.time().toString(cTimeFormat()); - return lng_status_lastseen_date_time(lt_date, date, lt_time, time); + return tr::lng_status_lastseen_date_time(tr::now, lt_date, date, lt_time, time); } bool OnlineTextActive(TimeId online, TimeId now) { diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index 94132c474..b1f798733 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -113,7 +113,7 @@ void UserData::setName(const QString &newFirstName, const QString &newLastName, firstName = newFirstName; lastName = newLastName; } - newFullName = lastName.isEmpty() ? firstName : lng_full_name(lt_first_name, firstName, lt_last_name, lastName); + newFullName = lastName.isEmpty() ? firstName : tr::lng_full_name(tr::now, lt_first_name, firstName, lt_last_name, lastName); } updateNameDelayed(newFullName, newPhoneName, newUsername); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index d8d5dcde7..30031cacb 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -614,7 +614,8 @@ void InnerWidget::paintEvent(QPaintEvent *e) { ? tr::lng_search_no_results(tr::now) : showUnreadInSearchResults ? qsl("Search results") - : lng_search_found_results( + : tr::lng_search_found_results( + tr::now, lt_count, _searchedMigratedCount + _searchedCount); p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg); @@ -2251,7 +2252,8 @@ void InnerWidget::refreshSearchInChatLabel() { return QString(); }(); if (!from.isEmpty()) { - const auto fromUserText = lng_dlg_search_from( + const auto fromUserText = tr::lng_dlg_search_from( + tr::now, lt_user, textcmdLink(1, from)); _searchFromUserText.setText( diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index b68fd1e03..07eeaef90 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -329,10 +329,10 @@ void paintRow( auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); if (history && !history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) { if (history->cloudDraftTextCache.isEmpty()) { - auto draftWrapped = textcmdLink(1, lng_dialogs_text_from_wrapped(lt_from, tr::lng_from_draft(tr::now))); + auto draftWrapped = textcmdLink(1, tr::lng_dialogs_text_from_wrapped(tr::now, lt_from, tr::lng_from_draft(tr::now))); auto draftText = supportMode ? textcmdLink(1, Support::ChatOccupiedString(history)) - : lng_dialogs_text_with_from(lt_from_part, draftWrapped, lt_message, TextUtilities::Clean(draft->textWithTags.text)); + : tr::lng_dialogs_text_with_from(tr::now, lt_from_part, draftWrapped, lt_message, TextUtilities::Clean(draft->textWithTags.text)); history->cloudDraftTextCache.setText(st::dialogsTextStyle, draftText, Ui::DialogTextOptions()); } p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg)); diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index ed280b55c..34da0bbca 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -52,7 +52,8 @@ QString ComposeFolderListEntryText(not_null folder) { auto i = peers.begin(); auto result = wrapName(*i); for (++i; i != peers.end(); ++i) { - result = lng_archived_last_list( + result = tr::lng_archived_last_list( + tr::now, lt_accumulated, result, lt_chat, @@ -61,7 +62,7 @@ QString ComposeFolderListEntryText(not_null folder) { return result; }(); return (shown < count) - ? lng_archived_last(lt_count, (count - shown), lt_chats, accumulated) + ? tr::lng_archived_last(tr::now, lt_count, (count - shown), lt_chats, accumulated) : accumulated; } diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index a333e29fb..3ba7b7856 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -199,9 +199,10 @@ void PanelController::showError(const ApiErrorState &error) { if (hours <= 0) { return tr::lng_export_delay_less_than_hour(tr::now); } - return lng_export_delay_hours(lt_count, hours); + return tr::lng_export_delay_hours(tr::now, lt_count, hours); }(); - showError(lng_export_delay( + showError(tr::lng_export_delay( + tr::now, lt_hours, hoursText, lt_date, diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index 6b6c78ad5..5a798f4dd 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -611,7 +611,7 @@ void SettingsWidget::addSizeSlider( }) | rpl::start_with_next([=](int sizeLimit) { const auto limit = sizeLimit / kMegabyte; const auto size = QString::number(limit) + " MB"; - const auto text = lng_export_option_size_limit(lt_size, size); + const auto text = tr::lng_export_option_size_limit(tr::now, lt_size, size); label->setText(text); }, slider->lifetime()); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index 76fd76baf..0cc775cb3 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -384,7 +384,14 @@ void GenerateItems( }; auto createChangeTitle = [&](const MTPDchannelAdminLogEventActionChangeTitle &action) { - auto text = (channel->isMegagroup() ? lng_action_changed_title : lng_admin_log_changed_title_channel)(lt_from, fromLinkText, lt_title, qs(action.vnew_value)); + auto text = (channel->isMegagroup() + ? tr::lng_action_changed_title + : tr::lng_admin_log_changed_title_channel)( + tr::now, + lt_from, + fromLinkText, + lt_title, + qs(action.vnew_value)); addSimpleServiceMessage(text); }; @@ -392,9 +399,13 @@ void GenerateItems( auto newValue = qs(action.vnew_value); auto oldValue = qs(action.vprev_value); auto text = (channel->isMegagroup() - ? (newValue.isEmpty() ? lng_admin_log_removed_description_group : lng_admin_log_changed_description_group) - : (newValue.isEmpty() ? lng_admin_log_removed_description_channel : lng_admin_log_changed_description_channel) - )(lt_from, fromLinkText); + ? (newValue.isEmpty() + ? tr::lng_admin_log_removed_description_group + : tr::lng_admin_log_changed_description_group) + : (newValue.isEmpty() + ? tr::lng_admin_log_removed_description_channel + : tr::lng_admin_log_changed_description_channel) + )(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); auto bodyFlags = Flag::f_entities | Flag::f_from_id; @@ -413,9 +424,13 @@ void GenerateItems( auto newValue = qs(action.vnew_value); auto oldValue = qs(action.vprev_value); auto text = (channel->isMegagroup() - ? (newValue.isEmpty() ? lng_admin_log_removed_link_group : lng_admin_log_changed_link_group) - : (newValue.isEmpty() ? lng_admin_log_removed_link_channel : lng_admin_log_changed_link_channel) - )(lt_from, fromLinkText); + ? (newValue.isEmpty() + ? tr::lng_admin_log_removed_link_group + : tr::lng_admin_log_changed_link_group) + : (newValue.isEmpty() + ? tr::lng_admin_log_removed_link_channel + : tr::lng_admin_log_changed_link_channel) + )(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); auto bodyFlags = Flag::f_entities | Flag::f_from_id; @@ -433,10 +448,20 @@ void GenerateItems( auto createChangePhoto = [&](const MTPDchannelAdminLogEventActionChangePhoto &action) { action.vnew_photo.match([&](const MTPDphoto &data) { auto photo = Auth().data().processPhoto(data); - auto text = (channel->isMegagroup() ? lng_admin_log_changed_photo_group : lng_admin_log_changed_photo_channel)(lt_from, fromLinkText); + auto text = (channel->isMegagroup() + ? tr::lng_admin_log_changed_photo_group + : tr::lng_admin_log_changed_photo_channel)( + tr::now, + lt_from, + fromLinkText); addSimpleServiceMessage(text, photo); }, [&](const MTPDphotoEmpty &data) { - auto text = (channel->isMegagroup() ? lng_admin_log_removed_photo_group : lng_admin_log_removed_photo_channel)(lt_from, fromLinkText); + auto text = (channel->isMegagroup() + ? tr::lng_admin_log_removed_photo_group + : tr::lng_admin_log_removed_photo_channel)( + tr::now, + lt_from, + fromLinkText); addSimpleServiceMessage(text); }); }; @@ -444,25 +469,25 @@ void GenerateItems( auto createToggleInvites = [&](const MTPDchannelAdminLogEventActionToggleInvites &action) { auto enabled = (action.vnew_value.type() == mtpc_boolTrue); auto text = (enabled - ? lng_admin_log_invites_enabled - : lng_admin_log_invites_disabled); - addSimpleServiceMessage(text(lt_from, fromLinkText)); + ? tr::lng_admin_log_invites_enabled + : tr::lng_admin_log_invites_disabled); + addSimpleServiceMessage(text(tr::now, lt_from, fromLinkText)); }; auto createToggleSignatures = [&](const MTPDchannelAdminLogEventActionToggleSignatures &action) { auto enabled = (action.vnew_value.type() == mtpc_boolTrue); auto text = (enabled - ? lng_admin_log_signatures_enabled - : lng_admin_log_signatures_disabled); - addSimpleServiceMessage(text(lt_from, fromLinkText)); + ? tr::lng_admin_log_signatures_enabled + : tr::lng_admin_log_signatures_disabled); + addSimpleServiceMessage(text(tr::now, lt_from, fromLinkText)); }; auto createUpdatePinned = [&](const MTPDchannelAdminLogEventActionUpdatePinned &action) { if (action.vmessage.type() == mtpc_messageEmpty) { - auto text = lng_admin_log_unpinned_message(lt_from, fromLinkText); + auto text = tr::lng_admin_log_unpinned_message(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); } else { - auto text = lng_admin_log_pinned_message(lt_from, fromLinkText); + auto text = tr::lng_admin_log_pinned_message(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); auto detachExistingItem = false; @@ -478,10 +503,14 @@ void GenerateItems( auto createEditMessage = [&](const MTPDchannelAdminLogEventActionEditMessage &action) { auto newValue = ExtractEditedText(action.vnew_message); auto canHaveCaption = MediaCanHaveCaption(action.vnew_message); - auto text = (canHaveCaption - ? (newValue.text.isEmpty() ? lng_admin_log_removed_caption : lng_admin_log_edited_caption) - : lng_admin_log_edited_message - )(lt_from, fromLinkText); + auto text = (!canHaveCaption + ? tr::lng_admin_log_edited_message + : newValue.text.isEmpty() + ? tr::lng_admin_log_removed_caption + : tr::lng_admin_log_edited_caption)( + tr::now, + lt_from, + fromLinkText); addSimpleServiceMessage(text); auto oldValue = ExtractEditedText(action.vprev_message); @@ -506,7 +535,7 @@ void GenerateItems( }; auto createDeleteMessage = [&](const MTPDchannelAdminLogEventActionDeleteMessage &action) { - auto text = lng_admin_log_deleted_message(lt_from, fromLinkText); + auto text = tr::lng_admin_log_deleted_message(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); auto detachExistingItem = false; @@ -517,16 +546,16 @@ void GenerateItems( auto createParticipantJoin = [&]() { auto text = (channel->isMegagroup() - ? lng_admin_log_participant_joined - : lng_admin_log_participant_joined_channel); - addSimpleServiceMessage(text(lt_from, fromLinkText)); + ? tr::lng_admin_log_participant_joined + : tr::lng_admin_log_participant_joined_channel); + addSimpleServiceMessage(text(tr::now, lt_from, fromLinkText)); }; auto createParticipantLeave = [&]() { auto text = (channel->isMegagroup() - ? lng_admin_log_participant_left - : lng_admin_log_participant_left_channel); - addSimpleServiceMessage(text(lt_from, fromLinkText)); + ? tr::lng_admin_log_participant_left + : tr::lng_admin_log_participant_left_channel); + addSimpleServiceMessage(text(tr::now, lt_from, fromLinkText)); }; auto createParticipantInvite = [&](const MTPDchannelAdminLogEventActionParticipantInvite &action) { @@ -557,10 +586,11 @@ void GenerateItems( auto set = action.vnew_stickerset; auto removed = (set.type() == mtpc_inputStickerSetEmpty); if (removed) { - auto text = lng_admin_log_removed_stickers_group(lt_from, fromLinkText); + auto text = tr::lng_admin_log_removed_stickers_group(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); } else { - auto text = lng_admin_log_changed_stickers_group( + auto text = tr::lng_admin_log_changed_stickers_group( + tr::now, lt_from, fromLinkText, lt_sticker_set, @@ -578,9 +608,9 @@ void GenerateItems( auto createTogglePreHistoryHidden = [&](const MTPDchannelAdminLogEventActionTogglePreHistoryHidden &action) { auto hidden = (action.vnew_value.type() == mtpc_boolTrue); auto text = (hidden - ? lng_admin_log_history_made_hidden - : lng_admin_log_history_made_visible); - addSimpleServiceMessage(text(lt_from, fromLinkText)); + ? tr::lng_admin_log_history_made_hidden + : tr::lng_admin_log_history_made_visible); + addSimpleServiceMessage(text(tr::now, lt_from, fromLinkText)); }; auto createDefaultBannedRights = [&](const MTPDchannelAdminLogEventActionDefaultBannedRights &action) { @@ -592,7 +622,7 @@ void GenerateItems( }; auto createStopPoll = [&](const MTPDchannelAdminLogEventActionStopPoll &action) { - auto text = lng_admin_log_stopped_poll(lt_from, fromLinkText); + auto text = tr::lng_admin_log_stopped_poll(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); auto detachExistingItem = false; @@ -606,14 +636,22 @@ void GenerateItems( const auto was = history->owner().channelLoaded(action.vprev_value.v); const auto now = history->owner().channelLoaded(action.vnew_value.v); if (!now) { - auto text = (broadcast ? lng_admin_log_removed_linked_chat : lng_admin_log_removed_linked_channel)(lt_from, fromLinkText); + auto text = (broadcast + ? tr::lng_admin_log_removed_linked_chat + : tr::lng_admin_log_removed_linked_channel)( + tr::now, + lt_from, + fromLinkText); addSimpleServiceMessage(text); } else { - auto text = (broadcast ? lng_admin_log_changed_linked_chat : lng_admin_log_changed_linked_channel)( - lt_from, - fromLinkText, - lt_chat, - textcmdLink(2, now->name)); + auto text = (broadcast + ? tr::lng_admin_log_changed_linked_chat + : tr::lng_admin_log_changed_linked_channel)( + tr::now, + lt_from, + fromLinkText, + lt_chat, + textcmdLink(2, now->name)); auto chatLink = std::make_shared([=] { Ui::showPeerHistory(now, ShowAtUnreadMsgId); }); @@ -634,14 +672,15 @@ void GenerateItems( }, [&](const MTPDgeoPointEmpty &) { return address; }); - const auto text = lng_admin_log_changed_location_chat( + const auto text = tr::lng_admin_log_changed_location_chat( + tr::now, lt_from, fromLinkText, lt_address, link); addSimpleServiceMessage(text); }, [&](const MTPDchannelLocationEmpty &) { - const auto text = lng_admin_log_removed_location_chat(lt_from, fromLinkText); + const auto text = tr::lng_admin_log_removed_location_chat(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); }); }; diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 21b050abd..75588506d 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -479,9 +479,10 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { QString newTypingString; auto typingCount = _typing.size(); if (typingCount > 2) { - newTypingString = lng_many_typing(lt_count, typingCount); + newTypingString = tr::lng_many_typing(tr::now, lt_count, typingCount); } else if (typingCount > 1) { - newTypingString = lng_users_typing( + newTypingString = tr::lng_users_typing( + tr::now, lt_user, begin(_typing)->first->firstName, lt_second_user, @@ -489,7 +490,8 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { } else if (typingCount) { newTypingString = peer->isUser() ? tr::lng_typing(tr::now) - : lng_user_typing( + : tr::lng_user_typing( + tr::now, lt_user, begin(_typing)->first->firstName); } else if (!_sendActions.empty()) { @@ -497,16 +499,16 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { using Type = SendAction::Type; auto sendActionString = [](Type type, const QString &name) -> QString { switch (type) { - case Type::RecordVideo: return name.isEmpty() ? tr::lng_send_action_record_video(tr::now) : lng_user_action_record_video(lt_user, name); - case Type::UploadVideo: return name.isEmpty() ? tr::lng_send_action_upload_video(tr::now) : lng_user_action_upload_video(lt_user, name); - case Type::RecordVoice: return name.isEmpty() ? tr::lng_send_action_record_audio(tr::now) : lng_user_action_record_audio(lt_user, name); - case Type::UploadVoice: return name.isEmpty() ? tr::lng_send_action_upload_audio(tr::now) : lng_user_action_upload_audio(lt_user, name); - case Type::RecordRound: return name.isEmpty() ? tr::lng_send_action_record_round(tr::now) : lng_user_action_record_round(lt_user, name); - case Type::UploadRound: return name.isEmpty() ? tr::lng_send_action_upload_round(tr::now) : lng_user_action_upload_round(lt_user, name); - case Type::UploadPhoto: return name.isEmpty() ? tr::lng_send_action_upload_photo(tr::now) : lng_user_action_upload_photo(lt_user, name); - case Type::UploadFile: return name.isEmpty() ? tr::lng_send_action_upload_file(tr::now) : lng_user_action_upload_file(lt_user, name); + case Type::RecordVideo: return name.isEmpty() ? tr::lng_send_action_record_video(tr::now) : tr::lng_user_action_record_video(tr::now, lt_user, name); + case Type::UploadVideo: return name.isEmpty() ? tr::lng_send_action_upload_video(tr::now) : tr::lng_user_action_upload_video(tr::now, lt_user, name); + case Type::RecordVoice: return name.isEmpty() ? tr::lng_send_action_record_audio(tr::now) : tr::lng_user_action_record_audio(tr::now, lt_user, name); + case Type::UploadVoice: return name.isEmpty() ? tr::lng_send_action_upload_audio(tr::now) : tr::lng_user_action_upload_audio(tr::now, lt_user, name); + case Type::RecordRound: return name.isEmpty() ? tr::lng_send_action_record_round(tr::now) : tr::lng_user_action_record_round(tr::now, lt_user, name); + case Type::UploadRound: return name.isEmpty() ? tr::lng_send_action_upload_round(tr::now) : tr::lng_user_action_upload_round(tr::now, lt_user, name); + case Type::UploadPhoto: return name.isEmpty() ? tr::lng_send_action_upload_photo(tr::now) : tr::lng_user_action_upload_photo(tr::now, lt_user, name); + case Type::UploadFile: return name.isEmpty() ? tr::lng_send_action_upload_file(tr::now) : tr::lng_user_action_upload_file(tr::now, lt_user, name); case Type::ChooseLocation: - case Type::ChooseContact: return name.isEmpty() ? tr::lng_typing(tr::now) : lng_user_typing(lt_user, name); + case Type::ChooseContact: return name.isEmpty() ? tr::lng_typing(tr::now) : tr::lng_user_typing(tr::now, lt_user, name); default: break; }; return QString(); @@ -525,11 +527,13 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { if (newTypingString.isEmpty()) { int playingCount = _sendActions.size(); if (playingCount > 2) { - newTypingString = lng_many_playing_game( + newTypingString = tr::lng_many_playing_game( + tr::now, lt_count, playingCount); } else if (playingCount > 1) { - newTypingString = lng_users_playing_game( + newTypingString = tr::lng_users_playing_game( + tr::now, lt_user, begin(_sendActions)->first->firstName, lt_second_user, @@ -537,7 +541,8 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { } else { newTypingString = peer->isUser() ? tr::lng_playing_game(tr::now) - : lng_user_playing_game( + : tr::lng_user_playing_game( + tr::now, lt_user, begin(_sendActions)->first->firstName); } diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index f09f4d7f1..177780794 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -3100,21 +3100,24 @@ QString HistoryInner::tooltipText() const { auto dateText = view->dateTime().toString( QLocale::system().dateTimeFormat(QLocale::LongFormat)); if (const auto editedDate = view->displayedEditDate()) { - dateText += '\n' + lng_edited_date( + dateText += '\n' + tr::lng_edited_date( + tr::now, lt_date, ParseDateTime(editedDate).toString( QLocale::system().dateTimeFormat( QLocale::LongFormat))); } if (const auto forwarded = view->data()->Get()) { - dateText += '\n' + lng_forwarded_date( + dateText += '\n' + tr::lng_forwarded_date( + tr::now, lt_date, ParseDateTime(forwarded->originalDate).toString( QLocale::system().dateTimeFormat( QLocale::LongFormat))); if (const auto media = view->media()) { if (media->hidesForwardedInfo()) { - dateText += "\n" + lng_forwarded( + dateText += "\n" + tr::lng_forwarded( + tr::now, lt_user, (forwarded->originalSender ? forwarded->originalSender->shortName() @@ -3124,7 +3127,7 @@ QString HistoryInner::tooltipText() const { } if (const auto msgsigned = view->data()->Get()) { if (msgsigned->isElided) { - dateText += '\n' + lng_signed_author(lt_user, msgsigned->author); + dateText += '\n' + tr::lng_signed_author(tr::now, lt_user, msgsigned->author); } } return dateText; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index cbe76d251..f40647836 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -62,7 +62,7 @@ not_null CreateUnsupportedMessage( UserId from) { const auto siteLink = qsl("https://desktop.telegram.org"); auto text = TextWithEntities{ - lng_message_unsupported(lt_link, siteLink) + tr::lng_message_unsupported(tr::now, lt_link, siteLink) }; TextUtilities::ParseEntities(text, Ui::ItemTextNoMonoOptions().flags); text.entities.push_front( @@ -748,8 +748,8 @@ QString HistoryItem::inDialogsText(DrawInDialog way) const { }(); if (sender) { auto fromText = sender->isSelf() ? tr::lng_from_you(tr::now) : sender->shortName(); - auto fromWrapped = textcmdLink(1, lng_dialogs_text_from_wrapped(lt_from, TextUtilities::Clean(fromText))); - return lng_dialogs_text_with_from(lt_from_part, fromWrapped, lt_message, plainText); + auto fromWrapped = textcmdLink(1, tr::lng_dialogs_text_from_wrapped(tr::now, lt_from, TextUtilities::Clean(fromText))); + return tr::lng_dialogs_text_with_from(tr::now, lt_from_part, fromWrapped, lt_message, plainText); } return plainText; } diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 3ef8eba6f..dc01a8d44 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL void HistoryMessageVia::create(UserId userId) { bot = Auth().data().user(userId); maxWidth = st::msgServiceNameFont->width( - lng_inline_bot_via(lt_inline_bot, '@' + bot->username)); + tr::lng_inline_bot_via(tr::now, lt_inline_bot, '@' + bot->username)); link = std::make_shared([bot = this->bot] { App::insertBotCommand('@' + bot->username); }); @@ -40,7 +40,7 @@ void HistoryMessageVia::resize(int32 availw) const { text = QString(); width = 0; } else { - text = lng_inline_bot_via(lt_inline_bot, '@' + bot->username); + text = tr::lng_inline_bot_via(tr::now, lt_inline_bot, '@' + bot->username); if (availw < maxWidth) { text = st::msgServiceNameFont->elided(text, availw); width = st::msgServiceNameFont->width(text); @@ -102,7 +102,8 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { ? App::peerName(originalSender) : hiddenSenderInfo->name; if (!originalAuthor.isEmpty()) { - phrase = lng_forwarded_signed( + phrase = tr::lng_forwarded_signed( + tr::now, lt_channel, name, lt_user, @@ -112,13 +113,15 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { } if (via) { if (fromChannel) { - phrase = lng_forwarded_channel_via( + phrase = tr::lng_forwarded_channel_via( + tr::now, lt_channel, textcmdLink(1, phrase), lt_inline_bot, textcmdLink(2, '@' + via->bot->username)); } else { - phrase = lng_forwarded_via( + phrase = tr::lng_forwarded_via( + tr::now, lt_user, textcmdLink(1, phrase), lt_inline_bot, @@ -126,11 +129,13 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { } } else { if (fromChannel) { - phrase = lng_forwarded_channel( + phrase = tr::lng_forwarded_channel( + tr::now, lt_channel, textcmdLink(1, phrase)); } else { - phrase = lng_forwarded( + phrase = tr::lng_forwarded( + tr::now, lt_user, textcmdLink(1, phrase)); } diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index e384ee24c..d46894849 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -42,15 +42,15 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto u = history()->owner().user(users[0].v); if (u == _from) { result.links.push_back(fromLink()); - result.text = lng_action_user_joined(lt_from, fromLinkText()); + result.text = tr::lng_action_user_joined(tr::now, lt_from, fromLinkText()); } else { result.links.push_back(fromLink()); result.links.push_back(u->createOpenLink()); - result.text = lng_action_add_user(lt_from, fromLinkText(), lt_user, textcmdLink(2, u->name)); + result.text = tr::lng_action_add_user(tr::now, lt_from, fromLinkText(), lt_user, textcmdLink(2, u->name)); } } else if (users.isEmpty()) { result.links.push_back(fromLink()); - result.text = lng_action_add_user(lt_from, fromLinkText(), lt_user, "somebody"); + result.text = tr::lng_action_add_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody")); } else { result.links.push_back(fromLink()); for (auto i = 0, l = users.size(); i != l; ++i) { @@ -61,12 +61,12 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { if (i == 0) { result.text = linkText; } else if (i + 1 == l) { - result.text = lng_action_add_users_and_last(lt_accumulated, result.text, lt_user, linkText); + result.text = tr::lng_action_add_users_and_last(tr::now, lt_accumulated, result.text, lt_user, linkText); } else { - result.text = lng_action_add_users_and_one(lt_accumulated, result.text, lt_user, linkText); + result.text = tr::lng_action_add_users_and_one(tr::now, lt_accumulated, result.text, lt_user, linkText); } } - result.text = lng_action_add_users_many(lt_from, fromLinkText(), lt_users, result.text); + result.text = tr::lng_action_add_users_many(tr::now, lt_from, fromLinkText(), lt_users, result.text); } return result; }; @@ -74,14 +74,14 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareChatJoinedByLink = [this](const MTPDmessageActionChatJoinedByLink &action) { auto result = PreparedText{}; result.links.push_back(fromLink()); - result.text = lng_action_user_joined_by_link(lt_from, fromLinkText()); + result.text = tr::lng_action_user_joined_by_link(tr::now, lt_from, fromLinkText()); return result; }; auto prepareChatCreate = [this](const MTPDmessageActionChatCreate &action) { auto result = PreparedText{}; result.links.push_back(fromLink()); - result.text = lng_action_created_chat(lt_from, fromLinkText(), lt_title, TextUtilities::Clean(qs(action.vtitle))); + result.text = tr::lng_action_created_chat(tr::now, lt_from, fromLinkText(), lt_title, TextUtilities::Clean(qs(action.vtitle))); return result; }; @@ -91,7 +91,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { result.text = tr::lng_action_created_channel(tr::now); } else { result.links.push_back(fromLink()); - result.text = lng_action_created_chat(lt_from, fromLinkText(), lt_title, TextUtilities::Clean(qs(action.vtitle))); + result.text = tr::lng_action_created_chat(tr::now, lt_from, fromLinkText(), lt_title, TextUtilities::Clean(qs(action.vtitle))); } return result; }; @@ -102,7 +102,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { result.text = tr::lng_action_removed_photo_channel(tr::now); } else { result.links.push_back(fromLink()); - result.text = lng_action_removed_photo(lt_from, fromLinkText()); + result.text = tr::lng_action_removed_photo(tr::now, lt_from, fromLinkText()); } return result; }; @@ -111,12 +111,12 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto result = PreparedText{}; if (peerFromUser(action.vuser_id) == _from->id) { result.links.push_back(fromLink()); - result.text = lng_action_user_left(lt_from, fromLinkText()); + result.text = tr::lng_action_user_left(tr::now, lt_from, fromLinkText()); } else { auto user = history()->owner().user(action.vuser_id.v); result.links.push_back(fromLink()); result.links.push_back(user->createOpenLink()); - result.text = lng_action_kick_user(lt_from, fromLinkText(), lt_user, textcmdLink(2, user->name)); + result.text = tr::lng_action_kick_user(tr::now, lt_from, fromLinkText(), lt_user, textcmdLink(2, user->name)); } return result; }; @@ -127,7 +127,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { result.text = tr::lng_action_changed_photo_channel(tr::now); } else { result.links.push_back(fromLink()); - result.text = lng_action_changed_photo(lt_from, fromLinkText()); + result.text = tr::lng_action_changed_photo(tr::now, lt_from, fromLinkText()); } return result; }; @@ -135,10 +135,10 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareChatEditTitle = [this](const MTPDmessageActionChatEditTitle &action) { auto result = PreparedText{}; if (isPost()) { - result.text = lng_action_changed_title_channel(lt_title, TextUtilities::Clean(qs(action.vtitle))); + result.text = tr::lng_action_changed_title_channel(tr::now, lt_title, TextUtilities::Clean(qs(action.vtitle))); } else { result.links.push_back(fromLink()); - result.text = lng_action_changed_title(lt_from, fromLinkText(), lt_title, TextUtilities::Clean(qs(action.vtitle))); + result.text = tr::lng_action_changed_title(tr::now, lt_from, fromLinkText(), lt_title, TextUtilities::Clean(qs(action.vtitle))); } return result; }; @@ -149,7 +149,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { result.text = tr::lng_action_you_took_screenshot(tr::now); } else { result.links.push_back(fromLink()); - result.text = lng_action_took_screenshot(lt_from, fromLinkText()); + result.text = tr::lng_action_took_screenshot(tr::now, lt_from, fromLinkText()); } return result; }; @@ -163,7 +163,8 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareBotAllowed = [&](const MTPDmessageActionBotAllowed &action) { auto result = PreparedText{}; const auto domain = qs(action.vdomain); - result.text = lng_action_bot_allowed_from_domain( + result.text = tr::lng_action_bot_allowed_from_domain( + tr::now, lt_domain, textcmdLink(qstr("http://") + domain, domain)); return result; @@ -199,7 +200,8 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { }()); }; result.links.push_back(history()->peer->createOpenLink()); - result.text = lng_action_secure_values_sent( + result.text = tr::lng_action_secure_values_sent( + tr::now, lt_user, textcmdLink(1, App::peerName(history()->peer)), lt_documents, @@ -210,7 +212,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareContactSignUp = [this] { auto result = PreparedText{}; result.links.push_back(fromLink()); - result.text = lng_action_user_registered(lt_from, fromLinkText()); + result.text = tr::lng_action_user_registered(tr::now, lt_from, fromLinkText()); return result; }; @@ -386,17 +388,17 @@ HistoryService::PreparedText HistoryService::preparePinnedText() { if (!limit && cutAt + 5 < size) { original = original.mid(0, cutAt) + qstr("..."); } - result.text = lng_action_pinned_message(lt_from, fromLinkText(), lt_text, textcmdLink(2, original)); + result.text = tr::lng_action_pinned_message(tr::now, lt_from, fromLinkText(), lt_text, textcmdLink(2, original)); } else { - result.text = lng_action_pinned_media(lt_from, fromLinkText(), lt_media, textcmdLink(2, mediaText)); + result.text = tr::lng_action_pinned_media(tr::now, lt_from, fromLinkText(), lt_media, textcmdLink(2, mediaText)); } } else if (pinned && pinned->msgId) { result.links.push_back(fromLink()); result.links.push_back(pinned->lnk); - result.text = lng_action_pinned_media(lt_from, fromLinkText(), lt_media, textcmdLink(2, tr::lng_contacts_loading(tr::now))); + result.text = tr::lng_action_pinned_media(tr::now, lt_from, fromLinkText(), lt_media, textcmdLink(2, tr::lng_contacts_loading(tr::now))); } else { result.links.push_back(fromLink()); - result.text = lng_action_pinned_media(lt_from, fromLinkText(), lt_media, tr::lng_deleted_message(tr::now)); + result.text = tr::lng_action_pinned_media(tr::now, lt_from, fromLinkText(), lt_media, tr::lng_deleted_message(tr::now)); } return result; } @@ -431,11 +433,13 @@ HistoryService::PreparedText HistoryService::prepareGameScoreText() { if (_from->isSelf()) { auto gameTitle = computeGameTitle(); if (gameTitle.isEmpty()) { - result.text = lng_action_game_you_scored_no_game( + result.text = tr::lng_action_game_you_scored_no_game( + tr::now, lt_count, scoreNumber); } else { - result.text = lng_action_game_you_scored( + result.text = tr::lng_action_game_you_scored( + tr::now, lt_count, scoreNumber, lt_game, @@ -445,13 +449,15 @@ HistoryService::PreparedText HistoryService::prepareGameScoreText() { result.links.push_back(fromLink()); auto gameTitle = computeGameTitle(); if (gameTitle.isEmpty()) { - result.text = lng_action_game_score_no_game( + result.text = tr::lng_action_game_score_no_game( + tr::now, lt_count, scoreNumber, lt_from, fromLinkText()); } else { - result.text = lng_action_game_score( + result.text = tr::lng_action_game_score( + tr::now, lt_count, scoreNumber, lt_from, @@ -482,9 +488,9 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() { }(); if (invoiceTitle.isEmpty()) { - result.text = lng_action_payment_done(lt_amount, payment->amount, lt_user, history()->peer->name); + result.text = tr::lng_action_payment_done(tr::now, lt_amount, payment->amount, lt_user, history()->peer->name); } else { - result.text = lng_action_payment_done_for(lt_amount, payment->amount, lt_user, history()->peer->name, lt_invoice, invoiceTitle); + result.text = tr::lng_action_payment_done_for(tr::now, lt_amount, payment->amount, lt_user, history()->peer->name, lt_invoice, invoiceTitle); } return result; } @@ -619,7 +625,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { } else { auto result = PreparedText(); result.links.push_back(fromLink()); - result.text = lng_ttl_photo_received(lt_from, fromLinkText()); + result.text = tr::lng_ttl_photo_received(tr::now, lt_from, fromLinkText()); setServiceText(std::move(result)); } } else { @@ -636,7 +642,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { } else { auto result = PreparedText(); result.links.push_back(fromLink()); - result.text = lng_ttl_video_received(lt_from, fromLinkText()); + result.text = tr::lng_ttl_video_received(tr::now, lt_from, fromLinkText()); setServiceText(std::move(result)); } } else { @@ -755,14 +761,18 @@ HistoryService::PreparedText GenerateJoinedText( auto result = HistoryService::PreparedText{}; result.links.push_back(inviter->createOpenLink()); result.text = (history->isMegagroup() - ? lng_action_add_you_group - : lng_action_add_you)(lt_from, textcmdLink(1, inviter->name)); + ? tr::lng_action_add_you_group + : tr::lng_action_add_you)( + tr::now, + lt_from, + textcmdLink(1, inviter->name)); return result; } else if (history->isMegagroup()) { auto self = history->session().user(); auto result = HistoryService::PreparedText{}; result.links.push_back(self->createOpenLink()); - result.text = lng_action_user_joined( + result.text = tr::lng_action_user_joined( + tr::now, lt_from, textcmdLink(1, self->name)); return result; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d348852ca..5aacf5352 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3936,10 +3936,12 @@ bool HistoryWidget::showSendingFilesError( case Error::None: return QString(); case Error::EmptyFile: case Error::Directory: - case Error::NonLocalUrl: return lng_send_image_empty( + case Error::NonLocalUrl: return tr::lng_send_image_empty( + tr::now, lt_name, list.errorData); - case Error::TooLargeFile: return lng_send_image_too_large( + case Error::TooLargeFile: return tr::lng_send_image_too_large( + tr::now, lt_name, list.errorData); } @@ -6252,17 +6254,17 @@ void HistoryWidget::updateForwardingTexts() { } } if (names.size() > 2) { - from = lng_forwarding_from(lt_count, names.size() - 1, lt_user, names[0]); + from = tr::lng_forwarding_from(tr::now, lt_count, names.size() - 1, lt_user, names[0]); } else if (names.size() < 2) { from = fullname; } else { - from = lng_forwarding_from_two(lt_user, names[0], lt_second_user, names[1]); + from = tr::lng_forwarding_from_two(tr::now, lt_user, names[0], lt_second_user, names[1]); } if (count < 2) { text = _toForward.front()->inReplyText(); } else { - text = textcmdLink(1, lng_forward_messages(lt_count, count)); + text = textcmdLink(1, tr::lng_forward_messages(tr::now, lt_count, count)); } } _toForwardFrom.setText(st::msgNameStyle, from, Ui::NameTextOptions()); diff --git a/Telegram/SourceFiles/history/media/history_media_call.cpp b/Telegram/SourceFiles/history/media/history_media_call.cpp index 38d297d60..ad7c68f82 100644 --- a/Telegram/SourceFiles/history/media/history_media_call.cpp +++ b/Telegram/SourceFiles/history/media/history_media_call.cpp @@ -36,7 +36,8 @@ HistoryCall::HistoryCall( if (_duration) { if (_reason != FinishReason::Missed && _reason != FinishReason::Busy) { - _status = lng_call_duration_info( + _status = tr::lng_call_duration_info( + tr::now, lt_time, _status, lt_duration, diff --git a/Telegram/SourceFiles/history/media/history_media_contact.cpp b/Telegram/SourceFiles/history/media/history_media_contact.cpp index b60c4b955..bdde268f6 100644 --- a/Telegram/SourceFiles/history/media/history_media_contact.cpp +++ b/Telegram/SourceFiles/history/media/history_media_contact.cpp @@ -73,7 +73,7 @@ HistoryContact::HistoryContact( _name.setText( st::semiboldTextStyle, - lng_full_name(lt_first_name, first, lt_last_name, last).trimmed(), + tr::lng_full_name(tr::now, lt_first_name, first, lt_last_name, last).trimmed(), Ui::NameTextOptions()); _phonew = st::normalFont->width(_phone); } diff --git a/Telegram/SourceFiles/history/media/history_media_poll.cpp b/Telegram/SourceFiles/history/media/history_media_poll.cpp index f4f3dca92..57678b81a 100644 --- a/Telegram/SourceFiles/history/media/history_media_poll.cpp +++ b/Telegram/SourceFiles/history/media/history_media_poll.cpp @@ -810,7 +810,7 @@ TextState HistoryPoll::textState(QPoint point, StateRequest request) const { using Flag = Ui::Text::StateRequest::Flag; if (request.flags & Flag::LookupCustomTooltip) { result.customTooltipText = answer.votes - ? lng_polls_votes_count(lt_count_decimal, answer.votes) + ? tr::lng_polls_votes_count(tr::now, lt_count_decimal, answer.votes) : tr::lng_polls_votes_none(tr::now); } } diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index e3b19472e..c3f537b15 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -86,7 +86,7 @@ void ContactStatus::Bar::showState(State state) { _share->setVisible(state == State::SharePhoneNumber); _report->setVisible(state == State::ReportSpam); _add->setText((state == State::Add) - ? lng_new_contact_add_name(lt_user, _name).toUpper() + ? tr::lng_new_contact_add_name(tr::now, lt_user, _name).toUpper() : tr::lng_new_contact_add(tr::now).toUpper()); updateButtonsGeometry(); } @@ -317,7 +317,7 @@ void ContactStatus::setupShareHandler(not_null user) { user->session().api().applyUpdates(result); Ui::Toast::Show( - lng_new_contact_share_done(lt_user, user->shortName())); + tr::lng_new_contact_share_done(tr::now, lt_user, user->shortName())); }).send(); }, _bar.lifetime()); } diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 51342c6d8..096796fd0 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -119,7 +119,7 @@ void UnreadBar::init(int newCount) { count = newCount; text = /*(count == kCountUnknown) // #feed ? tr::lng_unread_bar_some(tr::now) - : */lng_unread_bar(lt_count, count); + : */tr::lng_unread_bar(tr::now, lt_count, count); width = st::semiboldFont->width(text); } diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 6f602e7e5..0cbcd50a2 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -771,7 +771,7 @@ void TopBarWidget::updateOnlineDisplay() { } else if (chat->count <= 0) { text = tr::lng_group_status(tr::now); } else { - text = lng_chat_status_members(lt_count_decimal, chat->count); + text = tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->count); } } else { const auto self = Auth().user(); @@ -784,11 +784,11 @@ void TopBarWidget::updateOnlineDisplay() { } } if (online > 0 && !onlyMe) { - auto membersCount = lng_chat_status_members(lt_count_decimal, chat->participants.size()); - auto onlineCount = lng_chat_status_online(lt_count, online); - text = lng_chat_status_members_online(lt_members_count, membersCount, lt_online_count, onlineCount); + auto membersCount = tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->participants.size()); + auto onlineCount = tr::lng_chat_status_online(tr::now, lt_count, online); + text = tr::lng_chat_status_members_online(tr::now, lt_members_count, membersCount, lt_online_count, onlineCount); } else if (chat->participants.size() > 0) { - text = lng_chat_status_members(lt_count_decimal, chat->participants.size()); + text = tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->participants.size()); } else { text = tr::lng_group_status(tr::now); } @@ -810,16 +810,16 @@ void TopBarWidget::updateOnlineDisplay() { } } if (online && !onlyMe) { - auto membersCount = lng_chat_status_members(lt_count_decimal, channel->membersCount()); - auto onlineCount = lng_chat_status_online(lt_count, online); - text = lng_chat_status_members_online(lt_members_count, membersCount, lt_online_count, onlineCount); + auto membersCount = tr::lng_chat_status_members(tr::now, lt_count_decimal, channel->membersCount()); + auto onlineCount = tr::lng_chat_status_online(tr::now, lt_count, online); + text = tr::lng_chat_status_members_online(tr::now, lt_members_count, membersCount, lt_online_count, onlineCount); } else if (channel->membersCount() > 0) { - text = lng_chat_status_members(lt_count_decimal, channel->membersCount()); + text = tr::lng_chat_status_members(tr::now, lt_count_decimal, channel->membersCount()); } else { text = tr::lng_group_status(tr::now); } } else if (channel->membersCount() > 0) { - text = lng_chat_status_members(lt_count_decimal, channel->membersCount()); + text = tr::lng_chat_status_members(tr::now, lt_count_decimal, channel->membersCount()); } else { text = channel->isMegagroup() ? tr::lng_group_status(tr::now) : tr::lng_channel_status(tr::now); diff --git a/Telegram/SourceFiles/info/media/info_media_buttons.h b/Telegram/SourceFiles/info/media/info_media_buttons.h index ca2c4a418..d70a594c5 100644 --- a/Telegram/SourceFiles/info/media/info_media_buttons.h +++ b/Telegram/SourceFiles/info/media/info_media_buttons.h @@ -27,21 +27,21 @@ namespace Media { using Type = Storage::SharedMediaType; -inline auto MediaTextPhrase(Type type) { +inline tr::phrase MediaTextPhrase(Type type) { switch (type) { - case Type::Photo: return lng_profile_photos; - case Type::Video: return lng_profile_videos; - case Type::File: return lng_profile_files; - case Type::MusicFile: return lng_profile_songs; - case Type::Link: return lng_profile_shared_links; - case Type::RoundVoiceFile: return lng_profile_audios; + case Type::Photo: return tr::lng_profile_photos; + case Type::Video: return tr::lng_profile_videos; + case Type::File: return tr::lng_profile_files; + case Type::MusicFile: return tr::lng_profile_songs; + case Type::Link: return tr::lng_profile_shared_links; + case Type::RoundVoiceFile: return tr::lng_profile_audios; } Unexpected("Type in MediaTextPhrase()"); }; inline auto MediaText(Type type) { return [phrase = MediaTextPhrase(type)](int count) { - return phrase(lt_count, count); + return phrase(tr::now, lt_count, count); }; } @@ -106,7 +106,7 @@ inline auto AddCommonGroupsButton( parent, Profile::CommonGroupsCountValue(user), [](int count) { - return lng_profile_common_groups(lt_count, count); + return tr::lng_profile_common_groups(tr::now, lt_count, count); }, tracker)->entity(); result->addClickHandler([=] { diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index df073ef4e..b58c9d137 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -812,12 +812,10 @@ object_ptr SetupChannelMembers( channel, MTPDchannelFull::Flag::f_can_view_participants), (_1 > 0) && _2); - auto membersText = MembersCountValue( - channel - ) | rpl::map([](int count) { - return lng_chat_status_members(lt_count_decimal, count); - }); - auto membersCallback = [controller, channel] { + auto membersText = tr::lng_chat_status_members( + lt_count_decimal, + MembersCountValue(channel) | tr::to_count()); + auto membersCallback = [=] { controller->showSection(Info::Memento( channel->id, Section::Type::Members)); diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index 157801fdf..1be1a6bda 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -127,11 +127,11 @@ bool SectionToggle::checkRippleStartPosition(QPoint position) const { } auto MembersStatusText(int count) { - return lng_chat_status_members(lt_count_decimal, count); + return tr::lng_chat_status_members(tr::now, lt_count_decimal, count); }; auto OnlineStatusText(int count) { - return lng_chat_status_online(lt_count_decimal, count); + return tr::lng_chat_status_online(tr::now, lt_count_decimal, count); }; auto ChatStatusText(int fullCount, int onlineCount, bool isGroup) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_members.cpp b/Telegram/SourceFiles/info/profile/info_profile_members.cpp index 30077198f..b8fbaac11 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_members.cpp @@ -164,11 +164,11 @@ void Members::setupHeader() { object_ptr Members::setupTitle() { auto result = object_ptr( _titleWrap, - MembersCountValue( - _peer - ) | rpl::map([](int count) { - return lng_chat_status_members(lt_count_decimal, count); - }) | Ui::Text::ToUpper(), + tr::lng_chat_status_members( + lt_count_decimal, + MembersCountValue(_peer) | tr::to_count(), + Ui::Text::Upper + ), st::infoBlockHeaderLabel); result->setAttribute(Qt::WA_TransparentForMouseEvents); return result; diff --git a/Telegram/SourceFiles/intro/introcode.cpp b/Telegram/SourceFiles/intro/introcode.cpp index 11295acac..a90fb1397 100644 --- a/Telegram/SourceFiles/intro/introcode.cpp +++ b/Telegram/SourceFiles/intro/introcode.cpp @@ -128,13 +128,27 @@ void CodeWidget::updateCallText() { switch (_callStatus) { case Widget::Data::CallStatus::Waiting: { if (_callTimeout >= 3600) { - return lng_code_call(lt_minutes, qsl("%1:%2").arg(_callTimeout / 3600).arg((_callTimeout / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(_callTimeout % 60, 2, 10, QChar('0'))); + return tr::lng_code_call( + tr::now, + lt_minutes, + qsl("%1:%2" + ).arg(_callTimeout / 3600 + ).arg((_callTimeout / 60) % 60, 2, 10, QChar('0')), + lt_seconds, + qsl("%1").arg(_callTimeout % 60, 2, 10, QChar('0'))); } else { - return lng_code_call(lt_minutes, QString::number(_callTimeout / 60), lt_seconds, qsl("%1").arg(_callTimeout % 60, 2, 10, QChar('0'))); + return tr::lng_code_call( + tr::now, + lt_minutes, + QString::number(_callTimeout / 60), + lt_seconds, + qsl("%1").arg(_callTimeout % 60, 2, 10, QChar('0'))); } } break; - case Widget::Data::CallStatus::Calling: return tr::lng_code_calling(tr::now); - case Widget::Data::CallStatus::Called: return tr::lng_code_called(tr::now); + case Widget::Data::CallStatus::Calling: + return tr::lng_code_calling(tr::now); + case Widget::Data::CallStatus::Called: + return tr::lng_code_called(tr::now); } return QString(); })(); diff --git a/Telegram/SourceFiles/intro/intropwdcheck.cpp b/Telegram/SourceFiles/intro/intropwdcheck.cpp index 7d997263f..aba17dfa6 100644 --- a/Telegram/SourceFiles/intro/intropwdcheck.cpp +++ b/Telegram/SourceFiles/intro/intropwdcheck.cpp @@ -52,7 +52,8 @@ PwdCheckWidget::PwdCheckWidget( if (_hint.isEmpty()) { _pwdHint->hide(); } else { - _pwdHint->setText(lng_signin_hint(lt_password_hint, _hint)); + _pwdHint->setText( + tr::lng_signin_hint(tr::now, lt_password_hint, _hint)); } _codeField->hide(); _toPassword->hide(); @@ -61,10 +62,16 @@ PwdCheckWidget::PwdCheckWidget( } void PwdCheckWidget::refreshLang() { - if (_toRecover) _toRecover->setText(tr::lng_signin_recover(tr::now)); - if (_toPassword) _toPassword->setText(tr::lng_signin_try_password(tr::now)); + if (_toRecover) { + _toRecover->setText(tr::lng_signin_recover(tr::now)); + } + if (_toPassword) { + _toPassword->setText( + tr::lng_signin_try_password(tr::now)); + } if (!_hint.isEmpty()) { - _pwdHint->setText(lng_signin_hint(lt_password_hint, _hint)); + _pwdHint->setText( + tr::lng_signin_hint(tr::now, lt_password_hint, _hint)); } updateControlsGeometry(); } diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index b9e149769..f210224b1 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -373,22 +373,52 @@ void Widget::resetAccount() { auto type = error.type(); if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) { - auto seconds = type.mid(qstr("2FA_CONFIRM_WAIT_").size()).toInt(); - auto days = (seconds + 59) / 86400; - auto hours = ((seconds + 59) % 86400) / 3600; - auto minutes = ((seconds + 59) % 3600) / 60; - auto when = lng_signin_reset_minutes(lt_count, minutes); + const auto seconds = type.mid(qstr("2FA_CONFIRM_WAIT_").size()).toInt(); + 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); if (days > 0) { - auto daysCount = lng_signin_reset_days(lt_count, days); - auto hoursCount = lng_signin_reset_hours(lt_count, hours); - when = lng_signin_reset_in_days(lt_days_count, daysCount, lt_hours_count, hoursCount, lt_minutes_count, when); + const auto daysCount = tr::lng_signin_reset_days( + tr::now, + lt_count, + days); + const auto hoursCount = tr::lng_signin_reset_hours( + tr::now, + lt_count, + hours); + when = tr::lng_signin_reset_in_days( + tr::now, + lt_days_count, + daysCount, + lt_hours_count, + hoursCount, + lt_minutes_count, + when); } else if (hours > 0) { - auto hoursCount = lng_signin_reset_hours(lt_count, hours); - when = lng_signin_reset_in_hours(lt_hours_count, hoursCount, lt_minutes_count, when); + const auto hoursCount = tr::lng_signin_reset_hours( + tr::now, + lt_count, + hours); + when = tr::lng_signin_reset_in_hours( + tr::now, + lt_hours_count, + hoursCount, + lt_minutes_count, + when); } - Ui::show(Box(lng_signin_reset_wait(lt_phone_number, App::formatPhone(getData()->phone), lt_when, when))); + Ui::show(Box(tr::lng_signin_reset_wait( + tr::now, + lt_phone_number, + App::formatPhone(getData()->phone), + lt_when, + when))); } else if (type == qstr("2FA_RECENT_CONFIRM")) { - Ui::show(Box(tr::lng_signin_reset_cancelled(tr::now))); + Ui::show(Box( + tr::lng_signin_reset_cancelled(tr::now))); } else { Ui::hideLayer(); getStep()->showError(rpl::single(Lang::Hard::ServerError())); diff --git a/Telegram/SourceFiles/lang/lang_keys.cpp b/Telegram/SourceFiles/lang/lang_keys.cpp index 0cc69c259..207ab9222 100644 --- a/Telegram/SourceFiles/lang/lang_keys.cpp +++ b/Telegram/SourceFiles/lang/lang_keys.cpp @@ -12,20 +12,27 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { template -inline QString langDateMaybeWithYear(QDate date, WithYear withYear, WithoutYear withoutYear) { - auto month = date.month(); +inline QString langDateMaybeWithYear( + QDate date, + WithYear withYear, + WithoutYear withoutYear) { + const auto month = date.month(); if (month <= 0 || month > 12) { return qsl("MONTH_ERR"); }; - auto year = date.year(); - auto current = QDate::currentDate(); - auto currentYear = current.year(); - auto currentMonth = current.month(); + const auto year = date.year(); + const auto current = QDate::currentDate(); + const auto currentYear = current.year(); + const auto currentMonth = current.month(); if (year != currentYear) { - auto yearIsMuchGreater = [](int year, int otherYear) { + const auto yearIsMuchGreater = [](int year, int otherYear) { return (year > otherYear + 1); }; - auto monthIsMuchGreater = [](int year, int month, int otherYear, int otherMonth) { + const auto monthIsMuchGreater = []( + int year, + int month, + int otherYear, + int otherMonth) { return (year == otherYear + 1) && (month + 12 > otherMonth + 3); }; if (false @@ -123,23 +130,54 @@ bool langFirstNameGoesSecond() { QString langDayOfMonth(const QDate &date) { auto day = date.day(); return langDateMaybeWithYear(date, [&](int month, int year) { - return lng_month_day_year(lt_month, MonthSmall(month)(tr::now), lt_day, QString::number(day), lt_year, QString::number(year)); + return tr::lng_month_day_year( + tr::now, + lt_month, + MonthSmall(month)(tr::now), + lt_day, + QString::number(day), + lt_year, + QString::number(year)); }, [day](int month, int year) { - return lng_month_day(lt_month, MonthSmall(month)(tr::now), lt_day, QString::number(day)); + return tr::lng_month_day( + tr::now, + lt_month, + MonthSmall(month)(tr::now), + lt_day, + QString::number(day)); }); } QString langDayOfMonthFull(const QDate &date) { auto day = date.day(); return langDateMaybeWithYear(date, [day](int month, int year) { - return lng_month_day_year(lt_month, MonthDay(month)(tr::now), lt_day, QString::number(day), lt_year, QString::number(year)); + return tr::lng_month_day_year( + tr::now, + lt_month, + MonthDay(month)(tr::now), + lt_day, + QString::number(day), + lt_year, + QString::number(year)); }, [day](int month, int year) { - return lng_month_day(lt_month, MonthDay(month)(tr::now), lt_day, QString::number(day)); + return tr::lng_month_day( + tr::now, + lt_month, + MonthDay(month)(tr::now), + lt_day, + QString::number(day)); }); } QString langMonthOfYear(int month, int year) { - return (month > 0 && month <= 12) ? lng_month_year(lt_month, MonthSmall(month)(tr::now), lt_year, QString::number(year)) : qsl("MONTH_ERR"); + return (month > 0 && month <= 12) + ? tr::lng_month_year( + tr::now, + lt_month, + MonthSmall(month)(tr::now), + lt_year, + QString::number(year)) + : qsl("MONTH_ERR"); } QString langMonth(const QDate &date) { @@ -151,7 +189,14 @@ QString langMonth(const QDate &date) { } QString langMonthOfYearFull(int month, int year) { - return (month > 0 && month <= 12) ? lng_month_year(lt_month, Month(month)(tr::now), lt_year, QString::number(year)) : qsl("MONTH_ERR"); + return (month > 0 && month <= 12) + ? tr::lng_month_year( + tr::now, + lt_month, + Month(month)(tr::now), + lt_year, + QString::number(year)) + : qsl("MONTH_ERR"); } QString langMonthFull(const QDate &date) { diff --git a/Telegram/SourceFiles/lang/lang_keys.h b/Telegram/SourceFiles/lang/lang_keys.h index 8726f17b7..3d5d3e0f1 100644 --- a/Telegram/SourceFiles/lang/lang_keys.h +++ b/Telegram/SourceFiles/lang/lang_keys.h @@ -23,11 +23,21 @@ inline QString langDayOfWeek(const QDate &date) { } inline QString langDateTime(const QDateTime &date) { - return lng_mediaview_date_time(lt_date, langDayOfMonth(date.date()), lt_time, date.time().toString(cTimeFormat())); + return tr::lng_mediaview_date_time( + tr::now, + lt_date, + langDayOfMonth(date.date()), + lt_time, + date.time().toString(cTimeFormat())); } inline QString langDateTimeFull(const QDateTime &date) { - return lng_mediaview_date_time(lt_date, langDayOfMonthFull(date.date()), lt_time, date.time().toString(cTimeFormat())); + return tr::lng_mediaview_date_time( + tr::now, + lt_date, + langDayOfMonthFull(date.date()), + lt_time, + date.time().toString(cTimeFormat())); } bool langFirstNameGoesSecond(); diff --git a/Telegram/SourceFiles/layout.cpp b/Telegram/SourceFiles/layout.cpp index e96e140a2..eeb5837e8 100644 --- a/Telegram/SourceFiles/layout.cpp +++ b/Telegram/SourceFiles/layout.cpp @@ -48,7 +48,7 @@ QString formatDownloadText(qint64 ready, qint64 total) { totalStr = QString::number(total); mb = qsl("B"); } - return lng_save_downloaded(lt_ready, readyStr, lt_total, totalStr, lt_mb, mb); + return tr::lng_save_downloaded(tr::now, lt_ready, readyStr, lt_total, totalStr, lt_mb, mb); } QString formatDurationText(qint64 duration) { @@ -59,24 +59,24 @@ QString formatDurationText(qint64 duration) { QString formatDurationWords(qint64 duration) { if (duration > 59) { auto minutes = (duration / 60); - auto minutesCount = lng_duration_minsec_minutes(lt_count, minutes); + auto minutesCount = tr::lng_duration_minsec_minutes(tr::now, lt_count, minutes); auto seconds = (duration % 60); - auto secondsCount = lng_duration_minsec_seconds(lt_count, seconds); - return lng_duration_minutes_seconds(lt_minutes_count, minutesCount, lt_seconds_count, secondsCount); + 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 lng_duration_seconds(lt_count, duration); + return tr::lng_duration_seconds(tr::now, lt_count, duration); } QString formatDurationAndSizeText(qint64 duration, qint64 size) { - return lng_duration_and_size(lt_duration, formatDurationText(duration), lt_size, formatSizeText(size)); + return tr::lng_duration_and_size(tr::now, lt_duration, formatDurationText(duration), lt_size, formatSizeText(size)); } QString formatGifAndSizeText(qint64 size) { - return lng_duration_and_size(lt_duration, qsl("GIF"), lt_size, formatSizeText(size)); + return tr::lng_duration_and_size(tr::now, lt_duration, qsl("GIF"), lt_size, formatSizeText(size)); } QString formatPlayedText(qint64 played, qint64 duration) { - return lng_duration_played(lt_played, formatDurationText(played), lt_duration, formatDurationText(duration)); + return tr::lng_duration_played(tr::now, lt_played, formatDurationText(played), lt_duration, formatDurationText(duration)); } int32 documentColorIndex(DocumentData *document, QString &ext) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index c56cf42d1..a59f756bc 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -920,7 +920,7 @@ bool MainWidget::sendMessageFail(const RPCError &error) { const auto link = textcmdLink( Core::App().createInternalLinkFull(qsl("spambot")), tr::lng_cant_more_info(tr::now)); - const auto text = lng_error_public_groups_denied(lt_more_info, link); + const auto text = tr::lng_error_public_groups_denied(tr::now, lt_more_info, link); Ui::show(Box(text)); return true; } @@ -934,7 +934,7 @@ void MainWidget::cacheBackground() { auto &bg = Window::Theme::Background()->pixmapForTiled(); auto result = QImage(_willCacheFor.width() * cIntRetinaFactor(), _willCacheFor.height() * cIntRetinaFactor(), QImage::Format_RGB32); - result.setDevicePixelRatio(cRetinaFactor()); + result.setDevicePixelRatio(cRetinaFactor()); { QPainter p(&result); auto left = 0; @@ -3353,7 +3353,7 @@ bool MainWidget::usernameResolveFail(QString name, const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; if (error.code() == 400) { - Ui::show(Box(lng_username_not_found(lt_user, name))); + Ui::show(Box(tr::lng_username_not_found(tr::now, lt_user, name))); } return true; } diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index 5e7d12d43..34f6ecf96 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -522,11 +522,18 @@ void Widget::handleSongChange() { const auto time = parsed.time().toString(cTimeFormat()); const auto today = QDateTime::currentDateTime().date(); if (date == today) { - return lng_player_message_today(lt_time, time); + return tr::lng_player_message_today( + tr::now, + lt_time, + time); } else if (date.addDays(1) == today) { - return lng_player_message_yesterday(lt_time, time); + return tr::lng_player_message_yesterday( + tr::now, + lt_time, + time); } - return lng_player_message_date( + return tr::lng_player_message_date( + tr::now, lt_date, langDayOfMonthFull(date), lt_time, diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 3dd38a194..9dc054f3d 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -499,7 +499,7 @@ void OverlayWidget::updateDocSize() { totalStr = QString::number(total); mb = qsl("B"); } - _docSize = lng_media_save_progress(lt_ready, readyStr, lt_total, totalStr, lt_mb, mb); + _docSize = tr::lng_media_save_progress(tr::now, lt_ready, readyStr, lt_total, totalStr, lt_mb, mb); } else { _docSize = formatSizeText(_doc->size); } @@ -579,11 +579,11 @@ void OverlayWidget::updateControls() { return dNow; }(); if (d.date() == dNow.date()) { - _dateText = lng_mediaview_today(lt_time, d.time().toString(cTimeFormat())); + _dateText = tr::lng_mediaview_today(tr::now, lt_time, d.time().toString(cTimeFormat())); } else if (d.date().addDays(1) == dNow.date()) { - _dateText = lng_mediaview_yesterday(lt_time, d.time().toString(cTimeFormat())); + _dateText = tr::lng_mediaview_yesterday(tr::now, lt_time, d.time().toString(cTimeFormat())); } else { - _dateText = lng_mediaview_date_time(lt_date, d.date().toString(qsl("dd.MM.yy")), lt_time, d.time().toString(cTimeFormat())); + _dateText = tr::lng_mediaview_date_time(tr::now, lt_date, d.date().toString(qsl("dd.MM.yy")), lt_time, d.time().toString(cTimeFormat())); } if (!_fromName.isEmpty()) { _fromNameLabel.setText(st::mediaviewTextStyle, _fromName, Ui::NameTextOptions()); diff --git a/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp b/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp index 83445413f..a53d08750 100644 --- a/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp +++ b/Telegram/SourceFiles/media/view/media_view_playback_controls.cpp @@ -186,7 +186,8 @@ void PlaybackControls::setLoadingProgress(int ready, int total) { const auto percent = int(std::round(progress * 100)); if (_loadingPercent != percent) { _loadingPercent = percent; - _downloadProgress->setText(lng_mediaview_video_loading( + _downloadProgress->setText(tr::lng_mediaview_video_loading( + tr::now, lt_percent, QString::number(percent) + '%')); if (_playbackSlider->width() > _downloadProgress->width()) { diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 6efcf753b..61fe3e7af 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -595,7 +595,8 @@ Voice::Voice( TextParseOptions opts = { TextParseRichText, 0, 0, Qt::LayoutDirectionAuto }; _details.setText( st::defaultTextStyle, - lng_date_and_duration( + tr::lng_date_and_duration( + tr::now, lt_date, dateText, lt_duration, @@ -821,9 +822,9 @@ void Voice::updateName() { auto version = 0; if (const auto forwarded = parent()->Get()) { if (parent()->fromOriginal()->isChannel()) { - _name.setText(st::semiboldTextStyle, lng_forwarded_channel(lt_channel, App::peerName(parent()->fromOriginal())), Ui::NameTextOptions()); + _name.setText(st::semiboldTextStyle, tr::lng_forwarded_channel(tr::now, lt_channel, App::peerName(parent()->fromOriginal())), Ui::NameTextOptions()); } else { - _name.setText(st::semiboldTextStyle, lng_forwarded(lt_user, App::peerName(parent()->fromOriginal())), Ui::NameTextOptions()); + _name.setText(st::semiboldTextStyle, tr::lng_forwarded(tr::now, lt_user, App::peerName(parent()->fromOriginal())), Ui::NameTextOptions()); } } else { _name.setText(st::semiboldTextStyle, App::peerName(parent()->from()), Ui::NameTextOptions()); diff --git a/Telegram/SourceFiles/passport/passport_form_view_controller.cpp b/Telegram/SourceFiles/passport/passport_form_view_controller.cpp index fb0c926b4..8846993ba 100644 --- a/Telegram/SourceFiles/passport/passport_form_view_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_view_controller.cpp @@ -310,7 +310,8 @@ ScopeRow DocumentsOneOfRow( const auto type1 = documents.front()->type; const auto type2 = documents.back()->type; return { - lng_passport_or_title( + tr::lng_passport_or_title( + tr::now, lt_document, DocumentName(type1), lt_second_document, diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index f51f4fafd..9f6e112c4 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -44,7 +44,8 @@ ScanInfo CollectScanInfo(const EditFile &file) { file.fields.downloadOffset, file.fields.size); } else { - return lng_passport_scan_uploaded( + return tr::lng_passport_scan_uploaded( + tr::now, lt_date, langDateTimeFull(ParseDateTime(file.fields.date))); } @@ -56,7 +57,8 @@ ScanInfo CollectScanInfo(const EditFile &file) { file.uploadData->offset, file.uploadData->bytes.size()); } else { - return lng_passport_scan_uploaded( + return tr::lng_passport_scan_uploaded( + tr::now, lt_date, langDateTimeFull(ParseDateTime(file.fields.date))); } @@ -301,7 +303,8 @@ EditDocumentScheme GetDocumentScheme( const auto language = languageValue(countryCode); return language.isEmpty() ? tr::lng_passport_native_name_title(tr::now) - : lng_passport_native_name_language( + : tr::lng_passport_native_name_language( + tr::now, lt_language, language); }; @@ -312,7 +315,8 @@ EditDocumentScheme GetDocumentScheme( } const auto name = CountrySelectBox::NameByISO(countryCode); Assert(!name.isEmpty()); - return lng_passport_native_name_about( + return tr::lng_passport_native_name_about( + tr::now, lt_country, name); }; diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp index 3bd49b487..581fb6bc6 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp @@ -392,7 +392,10 @@ object_ptr VerifyPhoneBox( rpl::producer error) { return Box( tr::lng_passport_phone_title(), - lng_passport_confirm_phone(lt_phone, App::formatPhone(phone)), + tr::lng_passport_confirm_phone( + tr::now, + lt_phone, + App::formatPhone(phone)), codeLength, submit, nullptr, @@ -410,7 +413,7 @@ object_ptr VerifyEmailBox( rpl::producer resent) { return Box( tr::lng_passport_email_title(), - lng_passport_confirm_email(lt_email, email), + tr::lng_passport_confirm_email(tr::now, lt_email, email), codeLength, submit, resend, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp index f65f73914..8e86b03aa 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp @@ -272,7 +272,7 @@ void EditScans::List::pushScan(const ScanInfo &info) { rows.push_back(CreateScan( wrap, info, - lng_passport_scan_index(lt_index, QString::number(index + 1)))); + tr::lng_passport_scan_index(tr::now, lt_index, QString::number(index + 1)))); rows.back()->hide(anim::type::instant); const auto scan = rows.back()->entity(); diff --git a/Telegram/SourceFiles/passport/passport_panel_form.cpp b/Telegram/SourceFiles/passport/passport_panel_form.cpp index 2649b00ee..b554d4563 100644 --- a/Telegram/SourceFiles/passport/passport_panel_form.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_form.cpp @@ -232,7 +232,7 @@ not_null PanelForm::setupContent() { inner, object_ptr( inner, - lng_passport_request1(lt_bot, App::peerName(bot)), + tr::lng_passport_request1(tr::now, lt_bot, App::peerName(bot)), st::passportPasswordLabelBold)), st::passportFormAbout1Padding)->entity(); diff --git a/Telegram/SourceFiles/passport/passport_panel_password.cpp b/Telegram/SourceFiles/passport/passport_panel_password.cpp index d9c52484b..b4b12cad2 100644 --- a/Telegram/SourceFiles/passport/passport_panel_password.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_password.cpp @@ -35,7 +35,10 @@ PanelAskPassword::PanelAskPassword( st::passportPasswordUserpic) , _about1( this, - lng_passport_request1(lt_bot, App::peerName(_controller->bot())), + tr::lng_passport_request1( + tr::now, + lt_bot, + App::peerName(_controller->bot())), st::passportPasswordLabelBold) , _about2( this, @@ -173,7 +176,8 @@ void PanelNoPassword::setupContent() { _inner, object_ptr( _inner, - lng_passport_request1( + tr::lng_passport_request1( + tr::now, lt_bot, App::peerName(_controller->bot())), st::passportPasswordLabelBold)), @@ -221,7 +225,7 @@ void PanelNoPassword::refreshBottom() { _inner, (pattern.isEmpty() ? tr::lng_passport_about_password(tr::now) - : lng_passport_code_sent(lt_email, pattern)), + : tr::lng_passport_code_sent(tr::now, lt_email, pattern)), st::passportPasswordSetupLabel)), st::passportFormAbout2Padding)->entity()); if (pattern.isEmpty()) { diff --git a/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm b/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm index be7fe5342..0c724dc60 100644 --- a/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm +++ b/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm @@ -469,7 +469,7 @@ bool UnsafeShowOpenWith(const QString &filepath) { [button setHidden:YES]; #endif // OS_MAC_STORE NSTextField *goodLabel = [[NSTextField alloc] init]; - [goodLabel setStringValue:Q2NSString(lng_mac_this_app_can_open(lt_file, NS2QString(name)))]; + [goodLabel setStringValue:Q2NSString(tr::lng_mac_this_app_can_open(tr::now, lt_file, NS2QString(name)))]; [goodLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; [goodLabel setBezeled:NO]; [goodLabel setDrawsBackground:NO]; @@ -482,7 +482,7 @@ bool UnsafeShowOpenWith(const QString &filepath) { [goodLabel setFrame:goodFrame]; NSTextField *badLabel = [[NSTextField alloc] init]; - [badLabel setStringValue:Q2NSString(lng_mac_not_known_app(lt_file, NS2QString(name)))]; + [badLabel setStringValue:Q2NSString(tr::lng_mac_not_known_app(tr::now, lt_file, NS2QString(name)))]; [badLabel setFont:[goodLabel font]]; [badLabel setBezeled:NO]; [badLabel setDrawsBackground:NO]; diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 97137c32b..ec3d4f3f6 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -639,7 +639,7 @@ void MainWindow::psFirstShow() { void MainWindow::createGlobalMenu() { auto main = psMainMenu.addMenu(qsl("Telegram")); - auto about = main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram"))); + auto about = main->addAction(tr::lng_mac_menu_about_telegram(tr::now, lt_telegram, qsl("Telegram"))); connect(about, &QAction::triggered, about, [] { if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray(); Ui::show(Box()); diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index cd97f6f2a..505762777 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -772,7 +772,7 @@ void MainWindow::updateIconCounters() { iconOverlay.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(-32, counter, bg, fg, false))); ps_iconOverlay = createHIconFromQIcon(iconOverlay, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); } - auto description = (counter > 0) ? lng_unread_bar(lt_count, counter) : QString(); + auto description = (counter > 0) ? tr::lng_unread_bar(tr::now, lt_count, counter) : QString(); taskbarList->SetOverlayIcon(ps_hWnd, ps_iconOverlay, description.toStdWString().c_str()); } SetWindowPos(ps_hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); diff --git a/Telegram/SourceFiles/profile/profile_block_group_members.cpp b/Telegram/SourceFiles/profile/profile_block_group_members.cpp index 6906042a4..29aa10ad8 100644 --- a/Telegram/SourceFiles/profile/profile_block_group_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_group_members.cpp @@ -72,7 +72,7 @@ void GroupMembersWidget::removePeer(PeerData *selectedPeer) { auto user = selectedPeer->asUser(); Assert(user != nullptr); - auto text = lng_profile_sure_kick(lt_user, user->firstName); + auto text = tr::lng_profile_sure_kick(tr::now, lt_user, user->firstName); auto currentRestrictedRights = [&]() -> MTPChatBannedRights { if (auto channel = peer()->asMegagroup()) { auto it = channel->mgInfo->lastRestricted.find(user); diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index 2cb8d5136..a88c99696 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -48,11 +48,11 @@ void SetupConnectionType(not_null container) { if (Global::ProxySettings() != ProxyData::Settings::Enabled) { return transport.isEmpty() ? tr::lng_connection_auto_connecting(tr::now) - : lng_connection_auto(lt_transport, transport); + : tr::lng_connection_auto(tr::now, lt_transport, transport); } else { return transport.isEmpty() ? tr::lng_connection_proxy_connecting(tr::now) - : lng_connection_proxy(lt_transport, transport); + : tr::lng_connection_proxy(tr::now, lt_transport, transport); } }; const auto button = AddButtonWithLabel( @@ -83,7 +83,8 @@ void SetupUpdate(not_null container) { container.get()); const auto downloading = Ui::CreateChild>( container.get()); - const auto version = lng_settings_current_version( + const auto version = tr::lng_settings_current_version( + tr::now, lt_version, currentVersionText()); const auto toggle = AddButton( @@ -130,7 +131,8 @@ void SetupUpdate(not_null container) { label->setAttribute(Qt::WA_TransparentForMouseEvents); const auto showDownloadProgress = [=](int64 ready, int64 total) { - texts->fire(lng_settings_downloading_update( + texts->fire(tr::lng_settings_downloading_update( + tr::now, lt_progress, formatDownloadText(ready, total))); downloading->fire(true); diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index 7654982ec..3bc9015ae 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -150,7 +150,7 @@ void Calls::setupContent() { const auto updateOutputLabel = [=](int value) { const auto percent = QString::number(value); outputLabel->setText( - lng_settings_call_output_volume(lt_percent, percent)); + tr::lng_settings_call_output_volume(tr::now, lt_percent, percent)); }; const auto updateOutputVolume = [=](int value) { _needWriteSettings = true; @@ -228,7 +228,7 @@ void Calls::setupContent() { const auto updateInputLabel = [=](int value) { const auto percent = QString::number(value); inputLabel->setText( - lng_settings_call_input_volume(lt_percent, percent)); + tr::lng_settings_call_input_volume(tr::now, lt_percent, percent)); }; const auto updateInputVolume = [=](int value) { _needWriteSettings = true; diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index e17a54974..9303612e2 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -675,7 +675,8 @@ void ForwardsPrivacyController::PaintForwardedTooltip( const auto innerWidth = bubbleWidth - st::msgPadding.left() - st::msgPadding.right(); - const auto phrase = lng_forwarded( + const auto phrase = tr::lng_forwarded( + tr::now, lt_user, App::peerName(view->data()->history()->session().user())); const auto kReplacementPosition = QChar(0x0001); diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index 99b7ed17e..d9f41c2d9 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -218,8 +218,8 @@ void SetupLocalPasscode(not_null container) { ) | rpl::map([] { const auto autolock = Global::AutoLock(); return (autolock % 3600) - ? lng_passcode_autolock_minutes(lt_count, autolock / 60) - : lng_passcode_autolock_hours(lt_count, autolock / 3600); + ? tr::lng_passcode_autolock_minutes(tr::now, lt_count, autolock / 60) + : tr::lng_passcode_autolock_hours(tr::now, lt_count, autolock / 3600); }); AddButtonWithLabel( @@ -263,7 +263,7 @@ void SetupCloudPassword(not_null container) { ) | rpl::filter([](const QString &pattern) { return !pattern.isEmpty(); }) | rpl::map([](const QString &pattern) { - return lng_cloud_password_waiting_code(lt_email, pattern); + return tr::lng_cloud_password_waiting_code(tr::now, lt_email, pattern); })); auto unconfirmed = rpl::duplicate( pattern diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp index c6ecc0486..a90f30f08 100644 --- a/Telegram/SourceFiles/storage/localimageloader.cpp +++ b/Telegram/SourceFiles/storage/localimageloader.cpp @@ -997,13 +997,14 @@ void FileLoadTask::process() { void FileLoadTask::finish() { if (!_result || !_result->filesize || _result->filesize < 0) { Ui::show( - Box(lng_send_image_empty(lt_name, _filepath)), + Box( + tr::lng_send_image_empty(tr::now, lt_name, _filepath)), LayerOption::KeepOther); removeFromAlbum(); } else if (_result->filesize > App::kFileSizeLimit) { Ui::show( Box( - lng_send_image_too_large(lt_name, _filepath)), + tr::lng_send_image_too_large(tr::now, lt_name, _filepath)), LayerOption::KeepOther); removeFromAlbum(); } else if (App::main()) { diff --git a/Telegram/SourceFiles/support/support_helper.cpp b/Telegram/SourceFiles/support/support_helper.cpp index cb4899865..954e2f48e 100644 --- a/Telegram/SourceFiles/support/support_helper.cpp +++ b/Telegram/SourceFiles/support/support_helper.cpp @@ -121,15 +121,18 @@ QString FormatDateTime(TimeId value) { const auto now = QDateTime::currentDateTime(); const auto date = ParseDateTime(value); if (date.date() == now.date()) { - return lng_mediaview_today( + return tr::lng_mediaview_today( + tr::now, lt_time, date.time().toString(cTimeFormat())); } else if (date.date().addDays(1) == now.date()) { - return lng_mediaview_yesterday( + return tr::lng_mediaview_yesterday( + tr::now, lt_time, date.time().toString(cTimeFormat())); } else { - return lng_mediaview_date_time( + return tr::lng_mediaview_date_time( + tr::now, lt_date, date.date().toString(qsl("dd.MM.yy")), lt_time, diff --git a/Telegram/SourceFiles/ui/text/text_utilities.h b/Telegram/SourceFiles/ui/text/text_utilities.h index 5f7efb9c0..eaecbc39c 100644 --- a/Telegram/SourceFiles/ui/text/text_utilities.h +++ b/Telegram/SourceFiles/ui/text/text_utilities.h @@ -9,13 +9,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Ui { namespace Text { +namespace details { -inline auto ToUpper() { - return rpl::map([](QString &&text) { +struct ToUpperType { + inline QString operator()(const QString &text) const { + return text.toUpper(); + } + inline QString operator()(QString &&text) const { return std::move(text).toUpper(); - }); -} + } +}; +} // namespace details + +inline constexpr auto Upper = details::ToUpperType{}; TextWithEntities Bold(const QString &text); TextWithEntities Link( const QString &text, @@ -25,6 +32,10 @@ inline TextWithEntities WithEntities(const QString &text) { return { text }; } +inline auto ToUpper() { + return rpl::map(Upper); +} + inline auto ToBold() { return rpl::map(Bold); } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 824d40868..6e6c550ca 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -521,7 +521,7 @@ void NativeManager::doShowNotification(HistoryItem *item, int forwardedCount) { ? tr::lng_notification_preview(tr::now) : (forwardedCount < 2 ? (item->groupId() ? tr::lng_in_dlg_album(tr::now) : item->notificationText()) - : lng_forward_messages(lt_count, forwardedCount)); + : tr::lng_forward_messages(tr::now, lt_count, forwardedCount)); doShowNativeNotification( item->history()->peer, diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 71f944901..56f6f5b5e 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -705,7 +705,7 @@ void Notification::updateNotifyDisplay() { r.setTop(r.top() + st::dialogsTextFont->height); } p.setPen(st::dialogsTextFg); - p.drawText(r.left(), r.top() + st::dialogsTextFont->ascent, lng_forward_messages(lt_count, _forwardedCount)); + p.drawText(r.left(), r.top() + st::dialogsTextFont->ascent, tr::lng_forward_messages(tr::now, lt_count, _forwardedCount)); } } else { static QString notifyText = st::dialogsTextFont->elided(tr::lng_notification_preview(tr::now), itemWidth); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index 05c560ea8..02fa2dfe6 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -563,7 +563,7 @@ ThemeExportBox::ThemeExportBox(QWidget*, const QByteArray &paletteContent, const , _backgroundContent(backgroundContent) , _chooseFromFile(this, tr::lng_settings_bg_from_file(tr::now), st::boxLinkButton) , _tileBackground(this, tr::lng_settings_bg_tile(tr::now), tileBackground, st::defaultBoxCheckbox) { - _imageText = lng_theme_editor_saved_to_jpg(lt_size, formatSizeText(_backgroundContent.size())); + _imageText = tr::lng_theme_editor_saved_to_jpg(tr::now, lt_size, formatSizeText(_backgroundContent.size())); _chooseFromFile->setClickedCallback([this] { chooseBackgroundFromFile(); }); } @@ -638,7 +638,7 @@ void ThemeExportBox::chooseBackgroundFromFile() { _backgroundContent = content; _isPng = (format == "png"); auto sizeText = formatSizeText(_backgroundContent.size()); - _imageText = _isPng ? lng_theme_editor_read_from_png(lt_size, sizeText) : lng_theme_editor_read_from_jpg(lt_size, sizeText); + _imageText = _isPng ? tr::lng_theme_editor_read_from_png(tr::now, lt_size, sizeText) : tr::lng_theme_editor_read_from_jpg(tr::now, lt_size, sizeText); _tileBackground->setChecked(false); updateThumbnail(); } diff --git a/Telegram/SourceFiles/window/themes/window_theme_warning.cpp b/Telegram/SourceFiles/window/themes/window_theme_warning.cpp index 3bab5c834..63dea3048 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_warning.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_warning.cpp @@ -106,7 +106,7 @@ void WarningWidget::setSecondsLeft(int secondsLeft) { } void WarningWidget::updateText() { - _text = lng_theme_reverting(lt_count, _secondsLeft); + _text = tr::lng_theme_reverting(tr::now, lt_count, _secondsLeft); } void WarningWidget::showAnimated() { diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index 6bf645626..626ae3d55 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -404,12 +404,12 @@ auto ConnectionState::computeLayout(const State &state) const -> Layout { case State::Type::Waiting: Assert(state.waitTillRetry > 0); - result.text = lng_reconnecting(lt_count, state.waitTillRetry); + result.text = tr::lng_reconnecting(tr::now, lt_count, state.waitTillRetry); break; } result.textWidth = st::normalFont->width(result.text); const auto maxTextWidth = (state.type == State::Type::Waiting) - ? st::normalFont->width(lng_reconnecting(lt_count, 88)) + ? st::normalFont->width(tr::lng_reconnecting(tr::now, lt_count, 88)) : result.textWidth; result.contentWidth = (result.textWidth > 0) ? (st::connectingTextPadding.left() diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index 29618af83..ecd11002f 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -224,7 +224,7 @@ void TermsBox::prepare() { this, object_ptr( this, - lng_terms_age(lt_count, *_data.minAge), + tr::lng_terms_age(tr::now, lt_count, *_data.minAge), st::defaultCheckbox, std::move(check)), st::termsAgePadding) @@ -251,7 +251,7 @@ void TermsBox::prepare() { : QString(); if (TextUtilities::RegExpMention().match(link).hasMatch()) { _lastClickedMention = link; - Ui::Toast::Show(lng_terms_agree_to_proceed(lt_bot, link)); + Ui::Toast::Show(tr::lng_terms_agree_to_proceed(tr::now, lt_bot, link)); return false; } return true; diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 761b2fed9..87655654b 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -197,7 +197,7 @@ MainMenu::MainMenu( qsl("Telegram Desktop"), qsl("https://desktop.telegram.org"))); _telegram->setLinksTrusted(); - _version->setRichText(textcmdLink(1, lng_settings_current_version(lt_version, currentVersionText())) + QChar(' ') + QChar(8211) + QChar(' ') + textcmdLink(2, tr::lng_menu_about(tr::now))); + _version->setRichText(textcmdLink(1, tr::lng_settings_current_version(tr::now, lt_version, currentVersionText())) + QChar(' ') + QChar(8211) + QChar(' ') + textcmdLink(2, tr::lng_menu_about(tr::now))); _version->setLink(1, std::make_shared(qsl("https://desktop.telegram.org/changelog"))); _version->setLink(2, std::make_shared([] { Ui::show(Box()); })); diff --git a/Telegram/SourceFiles/window/window_outdated_bar.cpp b/Telegram/SourceFiles/window/window_outdated_bar.cpp index bdf91217c..a53ef766d 100644 --- a/Telegram/SourceFiles/window/window_outdated_bar.cpp +++ b/Telegram/SourceFiles/window/window_outdated_bar.cpp @@ -56,7 +56,7 @@ Bar::Bar(not_null parent, QDate date) _title->setTryMakeSimilarLines(true); _details->setTryMakeSimilarLines(true); _details->setText(_soon - ? lng_outdated_soon(lt_date, langDayOfMonthFull(date)) + ? tr::lng_outdated_soon(tr::now, lt_date, langDayOfMonthFull(date)) : tr::lng_outdated_now(tr::now)); } diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 38bbfe03f..c296280b7 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -138,7 +138,8 @@ bool PinnedLimitReached(Dialogs::Key key) { Auth().data().setChatPinned(key, true); Auth().api().savePinnedOrder(folder); } else { - auto errorText = lng_error_pinned_max( + auto errorText = tr::lng_error_pinned_max( + tr::now, lt_count, pinnedMax); Ui::show(Box(errorText)); @@ -624,7 +625,8 @@ void PeerMenuExportChat(not_null peer) { } void PeerMenuDeleteContact(not_null user) { - const auto text = lng_sure_delete_contact( + const auto text = tr::lng_sure_delete_contact( + tr::now, lt_contact, App::peerName(user)); const auto deleteSure = [=] { @@ -662,7 +664,7 @@ void PeerMenuShareContactBox(not_null user) { ? peer->name : '\xAB' + peer->name + '\xBB'; Ui::show(Box( - lng_forward_share_contact(lt_recipient, recipient), + tr::lng_forward_share_contact(tr::now, lt_recipient, recipient), tr::lng_forward_send(tr::now), [peer, user] { const auto history = peer->owner().history(peer); @@ -768,7 +770,7 @@ void PeerMenuBlockUserBox( } Ui::Toast::Show( - lng_new_contact_block_done(lt_user, user->shortName())); + tr::lng_new_contact_block_done(tr::now, lt_user, user->shortName())); }, st::attentionBoxButton); box->addButton(tr::lng_cancel(), [=] {