From 87fc066e67cde0b643b349b0617624efad1fe4e8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 19 Jun 2019 17:09:03 +0200 Subject: [PATCH] Use tr:: instead of lang(). --- Telegram/SourceFiles/apiwrap.cpp | 30 ++-- Telegram/SourceFiles/app.cpp | 2 +- .../SourceFiles/boxes/add_contact_box.cpp | 117 ++++++++----- Telegram/SourceFiles/boxes/background_box.cpp | 8 +- .../boxes/background_preview_box.cpp | 12 +- .../SourceFiles/boxes/change_phone_box.cpp | 18 +- Telegram/SourceFiles/boxes/confirm_box.cpp | 66 ++++--- .../SourceFiles/boxes/confirm_phone_box.cpp | 20 +-- Telegram/SourceFiles/boxes/connection_box.cpp | 44 ++--- .../SourceFiles/boxes/create_poll_box.cpp | 2 +- .../SourceFiles/boxes/download_path_box.cpp | 8 +- .../SourceFiles/boxes/edit_caption_box.cpp | 22 +-- .../SourceFiles/boxes/edit_privacy_box.cpp | 12 +- Telegram/SourceFiles/boxes/edit_privacy_box.h | 2 +- Telegram/SourceFiles/boxes/language_box.cpp | 8 +- .../SourceFiles/boxes/local_storage_box.cpp | 10 +- .../SourceFiles/boxes/mute_settings_box.cpp | 4 +- Telegram/SourceFiles/boxes/passcode_box.cpp | 72 ++++---- Telegram/SourceFiles/boxes/peer_list_box.cpp | 16 +- .../boxes/peer_list_controllers.cpp | 37 ++-- .../boxes/peers/add_participants_box.cpp | 35 ++-- .../boxes/peers/edit_contact_box.cpp | 2 +- .../boxes/peers/edit_linked_chat_box.cpp | 12 +- .../boxes/peers/edit_participant_box.cpp | 48 ++--- .../boxes/peers/edit_participants_box.cpp | 53 +++--- .../boxes/peers/edit_peer_info_box.cpp | 8 +- .../boxes/peers/edit_peer_permissions_box.cpp | 58 +++--- .../boxes/peers/edit_peer_type_box.cpp | 14 +- Telegram/SourceFiles/boxes/report_box.cpp | 16 +- .../boxes/self_destruction_box.cpp | 6 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 10 +- Telegram/SourceFiles/boxes/sessions_box.cpp | 14 +- Telegram/SourceFiles/boxes/share_box.cpp | 20 +-- .../SourceFiles/boxes/sticker_set_box.cpp | 10 +- Telegram/SourceFiles/boxes/stickers_box.cpp | 24 +-- Telegram/SourceFiles/boxes/username_box.cpp | 32 ++-- .../calls/calls_box_controller.cpp | 4 +- Telegram/SourceFiles/calls/calls_call.cpp | 2 +- Telegram/SourceFiles/calls/calls_instance.cpp | 2 +- Telegram/SourceFiles/calls/calls_panel.cpp | 22 +-- Telegram/SourceFiles/calls/calls_top_bar.cpp | 2 +- .../chat_helpers/emoji_list_widget.cpp | 18 +- .../chat_helpers/emoji_sets_manager.cpp | 6 +- .../chat_helpers/gifs_list_widget.cpp | 4 +- .../SourceFiles/chat_helpers/stickers.cpp | 6 +- .../chat_helpers/stickers_list_widget.cpp | 22 +-- .../chat_helpers/tabbed_selector.cpp | 16 +- .../SourceFiles/codegen/lang/generator.cpp | 17 +- Telegram/SourceFiles/core/application.cpp | 2 +- Telegram/SourceFiles/core/changelogs.cpp | 2 +- .../SourceFiles/core/click_handler_types.cpp | 16 +- .../SourceFiles/core/local_url_handlers.cpp | 6 +- Telegram/SourceFiles/data/data_document.cpp | 16 +- Telegram/SourceFiles/data/data_folder.cpp | 2 +- .../SourceFiles/data/data_media_types.cpp | 118 ++++++------- Telegram/SourceFiles/data/data_peer.cpp | 34 ++-- Telegram/SourceFiles/data/data_peer.h | 2 +- .../SourceFiles/data/data_peer_values.cpp | 24 +-- Telegram/SourceFiles/data/data_session.cpp | 6 +- .../dialogs/dialogs_inner_widget.cpp | 29 +-- .../SourceFiles/dialogs/dialogs_layout.cpp | 6 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 4 +- .../export/view/export_view_content.cpp | 20 +-- .../view/export_view_panel_controller.cpp | 27 ++- .../export/view/export_view_progress.cpp | 6 +- .../export/view/export_view_settings.cpp | 98 ++++++----- .../export/view/export_view_settings.h | 14 +- .../export/view/export_view_top_bar.cpp | 2 +- Telegram/SourceFiles/facades.cpp | 6 +- .../admin_log/history_admin_log_filter.cpp | 20 +-- .../admin_log/history_admin_log_inner.cpp | 39 +++-- .../admin_log/history_admin_log_item.cpp | 60 ++++--- .../admin_log/history_admin_log_section.cpp | 12 +- Telegram/SourceFiles/history/history.cpp | 22 +-- .../history/history_inner_widget.cpp | 90 +++++----- Telegram/SourceFiles/history/history_item.cpp | 8 +- .../history/history_item_components.cpp | 10 +- .../SourceFiles/history/history_item_text.cpp | 6 +- .../history/history_location_manager.cpp | 2 +- .../SourceFiles/history/history_message.cpp | 14 +- .../SourceFiles/history/history_service.cpp | 52 +++--- .../SourceFiles/history/history_widget.cpp | 132 +++++++------- Telegram/SourceFiles/history/history_widget.h | 2 +- .../history/media/history_media_contact.cpp | 4 +- .../history/media/history_media_document.cpp | 10 +- .../history/media/history_media_file.cpp | 2 +- .../history/media/history_media_game.cpp | 4 +- .../history/media/history_media_gif.cpp | 4 +- .../history/media/history_media_invoice.cpp | 8 +- .../history/media/history_media_poll.cpp | 8 +- .../history/media/history_media_web_page.cpp | 2 +- .../view/history_view_contact_status.cpp | 18 +- .../view/history_view_context_menu.cpp | 81 ++++----- .../history/view/history_view_element.cpp | 2 +- .../history/view/history_view_list_widget.cpp | 2 +- .../history/view/history_view_message.cpp | 10 +- .../view/history_view_service_message.cpp | 12 +- .../view/history_view_top_bar_widget.cpp | 15 +- .../info_common_groups_inner_widget.cpp | 2 +- .../SourceFiles/info/info_wrap_widget.cpp | 8 +- .../info/media/info_media_empty_widget.cpp | 23 ++- .../info/media/info_media_inner_widget.cpp | 6 +- .../info/media/info_media_list_widget.cpp | 32 ++-- .../info/profile/info_profile_actions.cpp | 6 +- .../info/profile/info_profile_cover.cpp | 26 +-- .../inline_bot_layout_internal.cpp | 4 +- .../inline_bots/inline_bot_send_data.cpp | 24 +-- .../inline_bots/inline_results_widget.cpp | 8 +- Telegram/SourceFiles/intro/introcode.cpp | 12 +- Telegram/SourceFiles/intro/introphone.cpp | 2 +- Telegram/SourceFiles/intro/intropwdcheck.cpp | 16 +- Telegram/SourceFiles/intro/introsignup.cpp | 4 +- Telegram/SourceFiles/intro/introwidget.cpp | 6 +- .../SourceFiles/lang/lang_cloud_manager.cpp | 18 +- Telegram/SourceFiles/lang/lang_keys.cpp | 165 ++++++++++++++++-- Telegram/SourceFiles/lang/lang_keys.h | 84 +-------- Telegram/SourceFiles/lang/lang_translator.cpp | 30 ++-- Telegram/SourceFiles/layout.cpp | 4 +- Telegram/SourceFiles/mainwidget.cpp | 42 ++--- Telegram/SourceFiles/mainwindow.cpp | 32 ++-- .../media/player/media_player_widget.cpp | 2 +- .../media/view/media_view_overlay_widget.cpp | 54 +++--- .../SourceFiles/overview/overview_layout.cpp | 2 +- .../passport/passport_form_controller.cpp | 36 ++-- .../passport_form_view_controller.cpp | 68 ++++---- .../passport/passport_panel_controller.cpp | 140 +++++++-------- .../passport/passport_panel_details_row.cpp | 10 +- .../passport/passport_panel_edit_contact.cpp | 2 +- .../passport/passport_panel_edit_document.cpp | 6 +- .../passport/passport_panel_edit_scans.cpp | 28 +-- .../passport/passport_panel_form.cpp | 4 +- .../passport/passport_panel_password.cpp | 10 +- .../linux/notifications_manager_linux.cpp | 2 +- .../platform/mac/file_utilities_mac.mm | 17 +- .../SourceFiles/platform/mac/mac_touchbar.mm | 17 +- .../SourceFiles/platform/mac/mac_utilities.h | 7 - .../platform/mac/main_window_mac.mm | 34 ++-- .../platform/mac/specific_mac_p.mm | 1 - .../platform/win/file_utilities_win.cpp | 2 +- .../platform/win/main_window_win.cpp | 2 +- .../profile/profile_block_group_members.cpp | 8 +- .../settings/settings_advanced.cpp | 34 ++-- .../SourceFiles/settings/settings_calls.cpp | 22 +-- .../SourceFiles/settings/settings_chat.cpp | 36 ++-- .../SourceFiles/settings/settings_common.cpp | 4 +- .../settings/settings_information.cpp | 6 +- .../SourceFiles/settings/settings_main.cpp | 10 +- .../settings/settings_notifications.cpp | 40 ++--- .../settings/settings_privacy_controllers.cpp | 50 +++--- .../settings/settings_privacy_controllers.h | 2 +- .../settings/settings_privacy_security.cpp | 49 +++--- Telegram/SourceFiles/storage/localstorage.cpp | 6 +- Telegram/SourceFiles/ui/countryinput.cpp | 10 +- Telegram/SourceFiles/ui/special_buttons.cpp | 14 +- .../SourceFiles/ui/widgets/input_fields.cpp | 30 ++-- Telegram/SourceFiles/ui/widgets/labels.cpp | 10 +- Telegram/SourceFiles/window/main_window.cpp | 6 +- .../window/notifications_manager.cpp | 4 +- .../window/notifications_manager_default.cpp | 4 +- .../window/themes/window_theme_editor.cpp | 30 ++-- .../themes/window_theme_editor_block.cpp | 2 +- .../window/themes/window_theme_preview.cpp | 4 +- .../window/themes/window_theme_warning.cpp | 2 +- .../window/window_connecting_widget.cpp | 6 +- .../window/window_lock_widgets.cpp | 8 +- .../SourceFiles/window/window_main_menu.cpp | 18 +- .../window/window_outdated_bar.cpp | 2 +- .../SourceFiles/window/window_peer_menu.cpp | 150 ++++++++-------- 168 files changed, 1905 insertions(+), 1744 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 0bccdc082..b90b3e91b 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -462,11 +462,11 @@ void ApiWrap::importChatInvite(const QString &hash) { }).fail([=](const RPCError &error) { const auto &type = error.type(); if (type == qstr("CHANNELS_TOO_MUCH")) { - Ui::show(Box(lang(lng_join_channel_error))); + Ui::show(Box(tr::lng_join_channel_error(tr::now))); } else if (error.code() == 400) { - Ui::show(Box(lang(type == qstr("USERS_TOO_MUCH") - ? lng_group_invite_no_room - : lng_group_invite_bad_link))); + Ui::show(Box((type == qstr("USERS_TOO_MUCH")) + ? tr::lng_group_invite_no_room(tr::now) + : tr::lng_group_invite_bad_link(tr::now))); } }).send(); } @@ -550,7 +550,7 @@ void ApiWrap::sendMessageFail(const RPCError &error) { } else if (error.type() == qstr("USER_BANNED_IN_CHANNEL")) { const auto link = textcmdLink( Core::App().createInternalLinkFull(qsl("spambot")), - lang(lng_cant_more_info)); + tr::lng_cant_more_info(tr::now)); Ui::show(Box(lng_error_public_groups_denied( lt_more_info, link))); @@ -1409,7 +1409,7 @@ void ApiWrap::migrateDone( void ApiWrap::migrateFail(not_null peer, const RPCError &error) { const auto &type = error.type(); if (type == qstr("CHANNELS_TOO_MUCH")) { - Ui::show(Box(lang(lng_migrate_error))); + Ui::show(Box(tr::lng_migrate_error(tr::now))); } if (auto handlers = _migrateCallbacks.take(peer)) { for (auto &handler : *handlers) { @@ -2167,13 +2167,13 @@ void ApiWrap::joinChannel(not_null channel) { if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA") || error.type() == qstr("USER_BANNED_IN_CHANNEL")) { - Ui::show(Box(lang(channel->isMegagroup() - ? lng_group_not_accessible - : lng_channel_not_accessible))); + Ui::show(Box(channel->isMegagroup() + ? tr::lng_group_not_accessible(tr::now) + : tr::lng_channel_not_accessible(tr::now))); } else if (error.type() == qstr("CHANNELS_TOO_MUCH")) { - Ui::show(Box(lang(lng_join_channel_error))); + Ui::show(Box(tr::lng_join_channel_error(tr::now))); } else if (error.type() == qstr("USERS_TOO_MUCH")) { - Ui::show(Box(lang(lng_group_full))); + Ui::show(Box(tr::lng_group_full(tr::now))); } _channelAmInRequests.remove(channel); }).send(); @@ -2826,7 +2826,7 @@ void ApiWrap::requestAttachedStickerSets(not_null photo) { MTP_inputStickeredMediaPhoto(photo->mtpInput()) )).done([=](const MTPVector &result) { if (result.v.isEmpty()) { - Ui::show(Box(lang(lng_stickers_not_found))); + Ui::show(Box(tr::lng_stickers_not_found(tr::now))); return; } else if (result.v.size() > 1) { Ui::show(Box(result)); @@ -2847,7 +2847,7 @@ void ApiWrap::requestAttachedStickerSets(not_null photo) { LayerOption::KeepOther); }).fail([=](const RPCError &error) { - Ui::show(Box(lang(lng_stickers_not_found))); + Ui::show(Box(tr::lng_stickers_not_found(tr::now))); }).send(); } @@ -3377,7 +3377,7 @@ void ApiWrap::requestRecentStickersWithHash(int32 hash) { auto &d = result.c_messages_recentStickers(); Stickers::SpecialSetReceived( Stickers::CloudRecentSetId, - lang(lng_recent_stickers), + tr::lng_recent_stickers(tr::now), d.vstickers.v, d.vhash.v, d.vpacks.v, @@ -4864,7 +4864,7 @@ void ApiWrap::editUploadedFile( item->returnSavedMedia(); _session->data().sendHistoryChangeNotifications(); Ui::show( - Box(lang(lng_edit_media_invalid_file)), + Box(tr::lng_edit_media_invalid_file(tr::now)), LayerOption::KeepOther); } else { sendMessageFail(error); diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index a223271e8..8dcdccfc2 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -143,7 +143,7 @@ namespace App { } QString peerName(const PeerData *peer, bool forDialogs) { - return peer ? ((forDialogs && peer->isUser() && !peer->asUser()->nameOrPhone.isEmpty()) ? peer->asUser()->nameOrPhone : peer->name) : lang(lng_deleted); + return peer ? ((forDialogs && peer->isUser() && !peer->asUser()->nameOrPhone.isEmpty()) ? peer->asUser()->nameOrPhone : peer->name) : tr::lng_deleted(tr::now); } void prepareCorners(RoundCorners index, int32 radius, const QBrush &brush, const style::color *shadow = nullptr, QImage *cors = nullptr) { diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index fee5cd004..9877d8b7f 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -67,7 +67,7 @@ style::InputField CreateBioFieldStyle() { QString PeerFloodErrorText(PeerFloodType type) { auto link = textcmdLink( Core::App().createInternalLinkFull(qsl("spambot")), - lang(lng_cant_more_info)); + tr::lng_cant_more_info(tr::now)); if (type == PeerFloodType::InviteGroup) { return lng_cant_invite_not_contact(lt_more_info, link); } @@ -107,9 +107,9 @@ void ShowAddParticipantsError( }; Ui::show( Box( - lang(lng_cant_invite_offer_admin), - lang(lng_cant_invite_make_admin), - lang(lng_cancel), + tr::lng_cant_invite_offer_admin(tr::now), + tr::lng_cant_invite_make_admin(tr::now), + tr::lng_cancel(tr::now), makeAdmin), LayerOption::KeepOther); return; @@ -121,33 +121,32 @@ void ShowAddParticipantsError( const auto hasBot = (bot != end(users)); const auto text = [&] { if (error == qstr("USER_BOT")) { - return lang(lng_cant_invite_bot_to_channel); + return tr::lng_cant_invite_bot_to_channel(tr::now); } else if (error == qstr("USER_LEFT_CHAT")) { // Trying to return a user who has left. } else if (error == qstr("USER_KICKED")) { // Trying to return a user who was kicked by admin. - return lang(lng_cant_invite_banned); + return tr::lng_cant_invite_banned(tr::now); } else if (error == qstr("USER_PRIVACY_RESTRICTED")) { - return lang(lng_cant_invite_privacy); + return tr::lng_cant_invite_privacy(tr::now); } else if (error == qstr("USER_NOT_MUTUAL_CONTACT")) { // Trying to return user who does not have me in contacts. - return lang(lng_failed_add_not_mutual); + return tr::lng_failed_add_not_mutual(tr::now); } else if (error == qstr("USER_ALREADY_PARTICIPANT") && hasBot) { - return lang(lng_bot_already_in_group); + return tr::lng_bot_already_in_group(tr::now); } else if (error == qstr("BOT_GROUPS_BLOCKED")) { - return lang(lng_error_cant_add_bot); + return tr::lng_error_cant_add_bot(tr::now); } else if (error == qstr("PEER_FLOOD")) { const auto isGroup = (chat->isChat() || chat->isMegagroup()); return PeerFloodErrorText(isGroup ? PeerFloodType::InviteGroup : PeerFloodType::InviteChannel); } else if (error == qstr("ADMINS_TOO_MUCH")) { - const auto isGroup = (chat->isChat() || chat->isMegagroup()); - return lang(isGroup - ? lng_error_admin_limit - : lng_error_admin_limit_channel); + return ((chat->isChat() || chat->isMegagroup()) + ? tr::lng_error_admin_limit + : tr::lng_error_admin_limit_channel)(tr::now); } - return lang(lng_failed_add_participant); + return tr::lng_failed_add_participant(tr::now); }(); Ui::show(Box(text), LayerOption::KeepOther); } @@ -424,9 +423,9 @@ void GroupInfoBox::prepare() { _photo.create( this, - lang((_type == Type::Channel) - ? lng_create_channel_crop - : lng_create_group_crop), + ((_type == Type::Channel) + ? tr::lng_create_channel_crop + : tr::lng_create_group_crop)(tr::now), Ui::UserpicButton::Role::ChangePhoto, st::defaultUserpicButton); _title.create( @@ -582,7 +581,7 @@ void GroupInfoBox::createGroup( } } else if (error.type() == qstr("USERS_TOO_FEW")) { Ui::show( - Box(lang(lng_cant_invite_privacy)), + Box(tr::lng_cant_invite_privacy(tr::now)), LayerOption::KeepOther); } else if (error.type() == qstr("PEER_FLOOD")) { Ui::show( @@ -591,7 +590,7 @@ void GroupInfoBox::createGroup( LayerOption::KeepOther); } else if (error.type() == qstr("USER_RESTRICTED")) { Ui::show( - Box(lang(lng_cant_do_this)), + Box(tr::lng_cant_do_this(tr::now)), LayerOption::KeepOther); } }).send(); @@ -703,9 +702,9 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio _title->setFocus(); _title->showError(); } else if (error.type() == qstr("USER_RESTRICTED")) { - Ui::show(Box(lang(lng_cant_do_this))); + Ui::show(Box(tr::lng_cant_do_this(tr::now))); } else if (error.type() == qstr("CHANNELS_TOO_MUCH")) { - Ui::show(Box(lang(lng_cant_do_this))); // TODO + Ui::show(Box(tr::lng_cant_do_this(tr::now))); // TODO } }).send(); } @@ -733,11 +732,37 @@ SetupChannelBox::SetupChannelBox(QWidget*, ChannelData *channel, bool existing) : _channel(channel) , _existing(existing) , _privacyGroup(std::make_shared>(Privacy::Public)) -, _public(this, _privacyGroup, Privacy::Public, lang(channel->isMegagroup() ? lng_create_public_group_title : lng_create_public_channel_title), st::defaultBoxCheckbox) -, _private(this, _privacyGroup, Privacy::Private, lang(channel->isMegagroup() ? lng_create_private_group_title : lng_create_private_channel_title), st::defaultBoxCheckbox) +, _public( + this, + _privacyGroup, + Privacy::Public, + (channel->isMegagroup() + ? tr::lng_create_public_group_title + : tr::lng_create_public_channel_title)(tr::now), + st::defaultBoxCheckbox) +, _private( + this, + _privacyGroup, + Privacy::Private, + (channel->isMegagroup() + ? tr::lng_create_private_group_title + : tr::lng_create_private_channel_title)(tr::now), + st::defaultBoxCheckbox) , _aboutPublicWidth(st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultRadio.diameter - st::defaultBoxCheckbox.textPosition.x()) -, _aboutPublic(st::defaultTextStyle, lang(channel->isMegagroup() ? lng_create_public_group_about : lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth) -, _aboutPrivate(st::defaultTextStyle, lang(channel->isMegagroup() ? lng_create_private_group_about : lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth) +, _aboutPublic( + st::defaultTextStyle, + (channel->isMegagroup() + ? tr::lng_create_public_group_about + : tr::lng_create_public_channel_about)(tr::now), + _defaultOptions, + _aboutPublicWidth) +, _aboutPrivate( + st::defaultTextStyle, + (channel->isMegagroup() + ? tr::lng_create_private_group_about + : tr::lng_create_private_channel_about)(tr::now), + _defaultOptions, + _aboutPublicWidth) , _link(this, st::setupChannelLink, nullptr, channel->username, true) { } @@ -826,7 +851,13 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) { if (!_channel->isMegagroup() || !_link->isHidden()) { p.setPen(st::boxTextFg); p.setFont(st::newGroupLinkFont); - p.drawTextLeft(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultInputField.textMargins.left(), _link->y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop, width(), lang(_link->isHidden() ? lng_create_group_invite_link : lng_create_group_link)); + p.drawTextLeft( + st::boxPadding.left() + st::newGroupPadding.left() + st::defaultInputField.textMargins.left(), + _link->y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop, + width(), + (_link->isHidden() + ? tr::lng_create_group_invite_link + : tr::lng_create_group_link)(tr::now)); } if (_link->isHidden()) { @@ -835,7 +866,7 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) { option.setWrapMode(QTextOption::WrapAnywhere); p.setFont(_linkOver ? st::boxTextFont->underline() : st::boxTextFont); p.setPen(st::defaultLinkButton.color); - auto inviteLinkText = _channel->inviteLink().isEmpty() ? lang(lng_group_invite_create) : _channel->inviteLink(); + auto inviteLinkText = _channel->inviteLink().isEmpty() ? tr::lng_group_invite_create(tr::now) : _channel->inviteLink(); p.drawText(_invitationLink, inviteLinkText, option); } } else { @@ -872,7 +903,7 @@ void SetupChannelBox::mousePressEvent(QMouseEvent *e) { _channel->session().api().exportInviteLink(_channel); } else { QGuiApplication::clipboard()->setText(_channel->inviteLink()); - Ui::Toast::Show(lang(lng_create_channel_link_copied)); + Ui::Toast::Show(tr::lng_create_channel_link_copied(tr::now)); } } } @@ -927,8 +958,8 @@ void SetupChannelBox::handleChange() { for (int32 i = 0; i < len; ++i) { QChar ch = name.at(i); if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z') && (ch < '0' || ch > '9') && ch != '_') { - if (_errorText != lang(lng_create_channel_link_bad_symbols)) { - _errorText = lang(lng_create_channel_link_bad_symbols); + if (_errorText != tr::lng_create_channel_link_bad_symbols(tr::now)) { + _errorText = tr::lng_create_channel_link_bad_symbols(tr::now); update(); } _checkTimer.stop(); @@ -936,8 +967,8 @@ void SetupChannelBox::handleChange() { } } if (name.size() < kMinUsernameLength) { - if (_errorText != lang(lng_create_channel_link_too_short)) { - _errorText = lang(lng_create_channel_link_too_short); + if (_errorText != tr::lng_create_channel_link_too_short(tr::now)) { + _errorText = tr::lng_create_channel_link_too_short(tr::now); update(); } _checkTimer.stop(); @@ -1008,13 +1039,13 @@ bool SetupChannelBox::onUpdateFail(const RPCError &error) { } else if (err == "USERNAME_INVALID") { _link->setFocus(); _link->showError(); - _errorText = lang(lng_create_channel_link_invalid); + _errorText = tr::lng_create_channel_link_invalid(tr::now); update(); return true; } else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") { _link->setFocus(); _link->showError(); - _errorText = lang(lng_create_channel_link_occupied); + _errorText = tr::lng_create_channel_link_occupied(tr::now); update(); return true; } @@ -1024,8 +1055,8 @@ bool SetupChannelBox::onUpdateFail(const RPCError &error) { void SetupChannelBox::onCheckDone(const MTPBool &result) { _checkRequestId = 0; - QString newError = (mtpIsTrue(result) || _checkUsername == _channel->username) ? QString() : lang(lng_create_channel_link_occupied); - QString newGood = newError.isEmpty() ? lang(lng_create_channel_link_available) : QString(); + QString newError = (mtpIsTrue(result) || _checkUsername == _channel->username) ? QString() : tr::lng_create_channel_link_occupied(tr::now); + QString newGood = newError.isEmpty() ? tr::lng_create_channel_link_available(tr::now) : QString(); if (_errorText != newError || _goodText != newGood) { _errorText = newError; _goodText = newGood; @@ -1050,11 +1081,11 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) { } return true; } else if (err == qstr("USERNAME_INVALID")) { - _errorText = lang(lng_create_channel_link_invalid); + _errorText = tr::lng_create_channel_link_invalid(tr::now); update(); return true; } else if (err == qstr("USERNAME_OCCUPIED") && _checkUsername != _channel->username) { - _errorText = lang(lng_create_channel_link_occupied); + _errorText = tr::lng_create_channel_link_occupied(tr::now); update(); return true; } @@ -1218,7 +1249,7 @@ bool EditNameBox::saveSelfFail(const RPCError &error) { RevokePublicLinkBox::Inner::Inner(QWidget *parent, Fn revokeCallback) : TWidget(parent) , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) -, _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke))) +, _revokeWidth(st::normalFont->width(tr::lng_channels_too_much_public_revoke(tr::now))) , _revokeCallback(std::move(revokeCallback)) { setMouseTracking(true); @@ -1260,7 +1291,7 @@ RevokePublicLinkBox::RevokePublicLinkBox( Fn revokeCallback) : _aboutRevoke( this, - lang(lng_channels_too_much_public_about), + tr::lng_channels_too_much_public_about(tr::now), st::aboutRevokePublicLabel) , _revokeCallback(std::move(revokeCallback)) { } @@ -1319,7 +1350,7 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) { 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 confirmText = lang(lng_channels_too_much_public_revoke); + 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; _revokeRequestId = request(MTPchannels_UpdateUsername( @@ -1370,7 +1401,7 @@ void RevokePublicLinkBox::Inner::paintChat(Painter &p, const ChatRow &row, bool p.setFont(selected ? st::linkOverFont : st::linkFont); p.setPen(selected ? st::defaultLinkButton.overColor : st::defaultLinkButton.color); - p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), lang(lng_channels_too_much_public_revoke), _revokeWidth); + p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), tr::lng_channels_too_much_public_revoke(tr::now), _revokeWidth); p.setPen(st::contactsStatusFg); p.setTextPalette(st::revokePublicLinkStatusPalette); diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index dfb47012f..5175dbeba 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -159,9 +159,9 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) { }; *box = Ui::show( Box( - lang(lng_background_sure_delete), - lang(lng_selected_delete), - lang(lng_cancel), + tr::lng_background_sure_delete(tr::now), + tr::lng_selected_delete(tr::now), + tr::lng_cancel(tr::now), remove), LayerOption::KeepOther); } @@ -251,7 +251,7 @@ void BackgroundBox::Inner::paintEvent(QPaintEvent *e) { if (_papers.empty()) { p.setFont(st::noContactsFont); p.setPen(st::noContactsColor); - p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center); + p.drawText(QRect(0, 0, width(), st::noContactsHeight), tr::lng_contacts_loading(tr::now), style::al_center); return; } auto row = 0; diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 77142c828..02852282f 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -390,12 +390,12 @@ BackgroundPreviewBox::BackgroundPreviewBox( : _text1(GenerateTextItem( delegate(), Auth().data().history(peerFromUser(PeerData::kServiceNotificationsId)), - lang(lng_background_text1), + tr::lng_background_text1(tr::now), false)) , _text2(GenerateTextItem( delegate(), Auth().data().history(peerFromUser(PeerData::kServiceNotificationsId)), - lang(lng_background_text2), + tr::lng_background_text2(tr::now), true)) , _paper(paper) , _radial([=](crl::time now) { radialAnimationCallback(now); }) { @@ -439,7 +439,7 @@ void BackgroundPreviewBox::prepare() { void BackgroundPreviewBox::createBlurCheckbox() { _blur.create( this, - lang(lng_background_blur), + tr::lng_background_blur(tr::now), st::backgroundCheckbox, std::make_unique( st::backgroundCheck, @@ -492,7 +492,7 @@ void BackgroundPreviewBox::apply() { void BackgroundPreviewBox::share() { QApplication::clipboard()->setText(_paper.shareUrl()); - Ui::Toast::Show(lang(lng_background_link_copied)); + Ui::Toast::Show(tr::lng_background_link_copied(tr::now)); } void BackgroundPreviewBox::paintEvent(QPaintEvent *e) { @@ -742,13 +742,13 @@ bool BackgroundPreviewBox::Start( return true; } if (!IsValidWallPaperSlug(slug)) { - Ui::show(Box(lang(lng_background_bad_link))); + Ui::show(Box(tr::lng_background_bad_link(tr::now))); return false; } Auth().api().requestWallPaper(slug, [=](const Data::WallPaper &result) { Ui::show(Box(result.withUrlParams(params))); }, [](const RPCError &error) { - Ui::show(Box(lang(lng_background_bad_link))); + Ui::show(Box(tr::lng_background_bad_link(tr::now))); }); return true; } diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 58e322da5..2180bc6b9 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -129,7 +129,7 @@ void ChangePhoneBox::EnterPhone::prepare() { _phone->moveToLeft(st::boxPadding.left(), st::boxLittleSkip); connect(_phone, &Ui::PhoneInput::submitted, [=] { submit(); }); - auto description = object_ptr(this, lang(lng_change_phone_new_description), st::changePhoneLabel); + auto description = object_ptr(this, tr::lng_change_phone_new_description(tr::now), st::changePhoneLabel); auto errorSkip = st::boxLittleSkip + st::changePhoneError.style.font->height; description->moveToLeft(st::boxPadding.left(), _phone->y() + _phone->height() + errorSkip + st::boxLittleSkip); @@ -196,11 +196,11 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone(const QString &phoneNumber, const bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const RPCError &error) { auto errorText = Lang::Hard::ServerError(); if (MTP::isFloodError(error)) { - errorText = lang(lng_flood_error); + errorText = tr::lng_flood_error(tr::now); } else if (MTP::isDefaultHandledError(error)) { return false; } else if (error.type() == qstr("PHONE_NUMBER_INVALID")) { - errorText = lang(lng_bad_phone); + errorText = tr::lng_bad_phone(tr::now); } else if (error.type() == qstr("PHONE_NUMBER_BANNED")) { ShowPhoneBannedError(phoneNumber); _requestId = 0; @@ -210,7 +210,7 @@ bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const lng_change_phone_occupied( lt_phone, App::formatPhone(phoneNumber)), - lang(lng_box_ok))); + tr::lng_box_ok(tr::now))); _requestId = 0; return true; } @@ -286,7 +286,7 @@ void ChangePhoneBox::EnterCode::submit() { if (weak) { Ui::hideLayer(); } - Ui::Toast::Show(lang(lng_change_phone_success)); + Ui::Toast::Show(tr::lng_change_phone_success(tr::now)); }), rpcFail(crl::guard(this, [this](const RPCError &error) { return sendCodeFail(error); }))); @@ -321,18 +321,18 @@ void ChangePhoneBox::EnterCode::showError(const QString &text) { bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) { auto errorText = Lang::Hard::ServerError(); if (MTP::isFloodError(error)) { - errorText = lang(lng_flood_error); + errorText = tr::lng_flood_error(tr::now); } else if (MTP::isDefaultHandledError(error)) { return false; } else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) { - errorText = lang(lng_bad_code); + errorText = tr::lng_bad_code(tr::now); } else if (error.type() == qstr("PHONE_CODE_EXPIRED") || error.type() == qstr("PHONE_NUMBER_BANNED")) { closeBox(); // Go back to phone input. _requestId = 0; return true; } else if (error.type() == qstr("PHONE_NUMBER_INVALID")) { - errorText = lang(lng_bad_phone); + errorText = tr::lng_bad_phone(tr::now); } _requestId = 0; showError(errorText); @@ -342,7 +342,7 @@ bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) { void ChangePhoneBox::prepare() { setTitle(tr::lng_change_phone_title()); addButton(tr::lng_change_phone_button(), [] { - Ui::show(Box(lang(lng_change_phone_warning), [] { + Ui::show(Box(tr::lng_change_phone_warning(tr::now), [] { Ui::show(Box()); })); }); diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 4fb193d2c..43d16cf8d 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -45,8 +45,8 @@ ConfirmBox::ConfirmBox( const QString &text, FnMut confirmedCallback, FnMut cancelledCallback) -: _confirmText(lang(lng_box_ok)) -, _cancelText(lang(lng_cancel)) +: _confirmText(tr::lng_box_ok(tr::now)) +, _cancelText(tr::lng_cancel(tr::now)) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) , _confirmedCallback(std::move(confirmedCallback)) @@ -61,7 +61,7 @@ ConfirmBox::ConfirmBox( FnMut confirmedCallback, FnMut cancelledCallback) : _confirmText(confirmText) -, _cancelText(lang(lng_cancel)) +, _cancelText(tr::lng_cancel(tr::now)) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) , _confirmedCallback(std::move(confirmedCallback)) @@ -76,7 +76,7 @@ ConfirmBox::ConfirmBox( FnMut confirmedCallback, FnMut cancelledCallback) : _confirmText(confirmText) -, _cancelText(lang(lng_cancel)) +, _cancelText(tr::lng_cancel(tr::now)) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) , _confirmedCallback(std::move(confirmedCallback)) @@ -92,7 +92,7 @@ ConfirmBox::ConfirmBox( FnMut confirmedCallback, FnMut cancelledCallback) : _confirmText(confirmText) -, _cancelText(lang(lng_cancel)) +, _cancelText(tr::lng_cancel(tr::now)) , _confirmStyle(confirmStyle) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) , _confirmedCallback(std::move(confirmedCallback)) @@ -301,13 +301,13 @@ void ConfirmBox::paintEvent(QPaintEvent *e) { } } -InformBox::InformBox(QWidget*, const QString &text, Fn closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) { +InformBox::InformBox(QWidget*, const QString &text, Fn closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, tr::lng_box_ok(tr::now), std::move(closedCallback)) { } InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, Fn closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) { } -InformBox::InformBox(QWidget*, const TextWithEntities &text, Fn closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) { +InformBox::InformBox(QWidget*, const TextWithEntities &text, Fn closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, tr::lng_box_ok(tr::now), std::move(closedCallback)) { } InformBox::InformBox(QWidget*, const TextWithEntities &text, const QString &doneText, Fn closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) { @@ -345,7 +345,7 @@ void MaxInviteBox::mousePressEvent(QMouseEvent *e) { _channel->session().api().exportInviteLink(_channel); } else { QGuiApplication::clipboard()->setText(_channel->inviteLink()); - Ui::Toast::Show(lang(lng_create_channel_link_copied)); + Ui::Toast::Show(tr::lng_create_channel_link_copied(tr::now)); } } } @@ -378,7 +378,7 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) { option.setWrapMode(QTextOption::WrapAnywhere); p.setFont(_linkOver ? st::defaultInputField.font->underline() : st::defaultInputField.font); p.setPen(st::defaultLinkButton.color); - auto inviteLinkText = _channel->inviteLink().isEmpty() ? lang(lng_group_invite_create) : _channel->inviteLink(); + auto inviteLinkText = _channel->inviteLink().isEmpty() ? tr::lng_group_invite_create(tr::now) : _channel->inviteLink(); p.drawText(_invitationLink, inviteLinkText, option); } @@ -393,7 +393,7 @@ PinMessageBox::PinMessageBox( MsgId msgId) : _peer(peer) , _msgId(msgId) -, _text(this, lang(lng_pinned_pin_sure), st::boxLabel) { +, _text(this, tr::lng_pinned_pin_sure(tr::now), st::boxLabel) { } void PinMessageBox::prepare() { @@ -401,7 +401,7 @@ void PinMessageBox::prepare() { addButton(tr::lng_cancel(), [this] { closeBox(); }); if (_peer->isChat() || _peer->isMegagroup()) { - _notify.create(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox); + _notify.create(this, tr::lng_pinned_notify(tr::now), true, st::defaultBoxCheckbox); } auto height = st::boxPadding.top() + _text->height() + st::boxPadding.bottom(); @@ -494,21 +494,21 @@ void DeleteMessagesBox::prepare() { if (const auto peer = _wipeHistoryPeer) { if (_wipeHistoryJustClear) { details.text = peer->isSelf() - ? lang(lng_sure_delete_saved_messages) + ? 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); deleteStyle = &st::attentionBoxButton; } else { details.text = peer->isSelf() - ? lang(lng_sure_delete_saved_messages) + ? tr::lng_sure_delete_saved_messages(tr::now) : peer->isUser() - ? lng_sure_delete_history(lt_contact, peer->name) + ? tr::lng_sure_delete_history(tr::now, lt_contact, peer->name) : peer->isChat() - ? lng_sure_delete_and_exit(lt_group, peer->name) - : lang(peer->isMegagroup() - ? lng_sure_leave_group - : lng_sure_leave_channel); + ? tr::lng_sure_delete_and_exit(tr::now, lt_group, peer->name) + : peer->isMegagroup() + ? tr::lng_sure_leave_group(tr::now) + : tr::lng_sure_leave_channel(tr::now); deleteText = _wipeHistoryPeer->isUser() ? tr::lng_box_delete() : tr::lng_box_leave(); @@ -523,17 +523,17 @@ void DeleteMessagesBox::prepare() { } else if (_moderateFrom) { Assert(_moderateInChannel != nullptr); - details.text = lang(lng_selected_delete_sure_this); + details.text = tr::lng_selected_delete_sure_this(tr::now); if (_moderateBan) { - _banUser.create(this, lang(lng_ban_user), false, st::defaultBoxCheckbox); + _banUser.create(this, tr::lng_ban_user(tr::now), false, st::defaultBoxCheckbox); } - _reportSpam.create(this, lang(lng_report_spam), false, st::defaultBoxCheckbox); + _reportSpam.create(this, tr::lng_report_spam(tr::now), false, st::defaultBoxCheckbox); if (_moderateDeleteAll) { - _deleteAll.create(this, lang(lng_delete_all_from), false, st::defaultBoxCheckbox); + _deleteAll.create(this, tr::lng_delete_all_from(tr::now), false, st::defaultBoxCheckbox); } } else { details.text = (_ids.size() == 1) - ? lang(lng_selected_delete_sure_this) + ? tr::lng_selected_delete_sure_this(tr::now) : lng_selected_delete_sure(lt_count, _ids.size()); if (const auto peer = checkFromSinglePeer()) { auto count = int(_ids.size()); @@ -601,7 +601,7 @@ auto DeleteMessagesBox::revokeText(not_null peer) const lt_user, user->firstName); } else { - result.checkbox = lang(lng_delete_for_everyone_check); + result.checkbox = tr::lng_delete_for_everyone_check(tr::now); } return result; } @@ -793,17 +793,13 @@ ConfirmInviteBox::ConfirmInviteBox( const auto title = qs(data.vtitle); const auto count = data.vparticipants_count.v; const auto status = [&] { - if (_participants.empty() || _participants.size() >= count) { - if (count > 0) { - return lng_chat_status_members(lt_count_decimal, count); - } else { - return lang(_isChannel - ? lng_channel_status - : lng_group_status); - } - } else { - return lng_group_invite_members(lt_count, count); - } + return (!_participants.empty() && _participants.size() < count) + ? tr::lng_group_invite_members(tr::now, lt_count, count) + : (count > 0) + ? tr::lng_chat_status_members(tr::now, lt_count_decimal, count) + : _isChannel + ? tr::lng_channel_status(tr::now) + : tr::lng_group_status(tr::now); }(); _title->setText(title); _status->setText(status); diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index 5a046dfa7..2f999fb60 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -58,9 +58,9 @@ void ShowPhoneBannedError(const QString &phone) { } }; *box = Ui::show(Box( - lang(lng_signin_banned_text), - lang(lng_box_ok), - lang(lng_signin_banned_help), + tr::lng_signin_banned_text(tr::now), + tr::lng_box_ok(tr::now), + tr::lng_signin_banned_help(tr::now), close, [=] { SendToBannedHelp(phone); close(); })); @@ -185,8 +185,8 @@ QString SentCodeCall::getText() const { } return lng_code_call(lt_minutes, QString::number(_status.timeout / 60), lt_seconds, qsl("%1").arg(_status.timeout % 60, 2, 10, QChar('0'))); } break; - case State::Calling: return lang(lng_code_calling); - case State::Called: return lang(lng_code_called); + case State::Calling: return tr::lng_code_calling(tr::now); + case State::Called: return tr::lng_code_called(tr::now); } return QString(); } @@ -246,11 +246,11 @@ void ConfirmPhoneBox::sendCodeDone(const MTPauth_SentCode &result) { bool ConfirmPhoneBox::sendCodeFail(const RPCError &error) { auto errorText = Lang::Hard::ServerError(); if (MTP::isFloodError(error)) { - errorText = lang(lng_flood_error); + errorText = tr::lng_flood_error(tr::now); } else if (MTP::isDefaultHandledError(error)) { return false; } else if (error.code() == 400) { - errorText = lang(lng_confirm_phone_link_invalid); + errorText = tr::lng_confirm_phone_link_invalid(tr::now); } _sendCodeRequestId = 0; Ui::show(Box(errorText)); @@ -327,13 +327,13 @@ void ConfirmPhoneBox::confirmDone(const MTPBool &result) { bool ConfirmPhoneBox::confirmFail(const RPCError &error) { auto errorText = Lang::Hard::ServerError(); if (MTP::isFloodError(error)) { - errorText = lang(lng_flood_error); + errorText = tr::lng_flood_error(tr::now); } else if (MTP::isDefaultHandledError(error)) { return false; } else { auto &errorType = error.type(); if (errorType == qstr("PHONE_CODE_EMPTY") || errorType == qstr("PHONE_CODE_INVALID")) { - errorText = lang(lng_bad_code); + errorText = tr::lng_bad_code(tr::now); } } _sendCodeRequestId = 0; @@ -369,7 +369,7 @@ void ConfirmPhoneBox::paintEvent(QPaintEvent *e) { auto errorText = _error; if (errorText.isEmpty()) { p.setPen(st::usernameDefaultFg); - errorText = lang(lng_confirm_phone_enter_code); + errorText = tr::lng_confirm_phone_enter_code(tr::now); } else { p.setPen(st::boxTextFgError); } diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index f0b72df39..a48bc2d27 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -308,13 +308,13 @@ void ProxyRow::paintEvent(QPaintEvent *e) { lt_ping, QString::number(_view.ping)); case State::Checking: - return lang(lng_proxy_checking); + return tr::lng_proxy_checking(tr::now); case State::Connecting: - return lang(lng_proxy_connecting); + return tr::lng_proxy_connecting(tr::now); case State::Online: - return lang(lng_proxy_online); + return tr::lng_proxy_online(tr::now); case State::Unavailable: - return lang(lng_proxy_unavailable); + return tr::lng_proxy_unavailable(tr::now); } Unexpected("State in ProxyRow::paintEvent."); }(); @@ -409,20 +409,20 @@ void ProxyRow::showMenu() { Fn callback) { return _menu->addAction(text, std::move(callback)); }; - addAction(lang(lng_proxy_menu_edit), [=] { + addAction(tr::lng_proxy_menu_edit(tr::now), [=] { _editClicks.fire({}); }); if (_view.supportsShare) { - addAction(lang(lng_proxy_edit_share), [=] { + addAction(tr::lng_proxy_edit_share(tr::now), [=] { _shareClicks.fire({}); }); } if (_view.deleted) { - addAction(lang(lng_proxy_menu_restore), [=] { + addAction(tr::lng_proxy_menu_restore(tr::now), [=] { _restoreClicks.fire({}); }); } else { - addAction(lang(lng_proxy_menu_delete), [=] { + addAction(tr::lng_proxy_menu_delete(tr::now), [=] { _deleteClicks.fire({}); }); } @@ -483,7 +483,7 @@ void ProxiesBox::setupContent() { _tryIPv6 = inner->add( object_ptr( inner, - lang(lng_connection_try_ipv6), + tr::lng_connection_try_ipv6(tr::now), Global::TryIPv6()), st::proxyTryIPv6Padding); _proxySettings @@ -494,28 +494,28 @@ void ProxiesBox::setupContent() { inner, _proxySettings, ProxyData::Settings::Disabled, - lang(lng_proxy_disable)), + tr::lng_proxy_disable(tr::now)), st::proxyUsePadding); inner->add( object_ptr>( inner, _proxySettings, ProxyData::Settings::System, - lang(lng_proxy_use_system_settings)), + tr::lng_proxy_use_system_settings(tr::now)), st::proxyUsePadding); inner->add( object_ptr>( inner, _proxySettings, ProxyData::Settings::Enabled, - lang(lng_proxy_use_custom)), + tr::lng_proxy_use_custom(tr::now)), st::proxyUsePadding); _proxyForCalls = inner->add( object_ptr>( inner, object_ptr( inner, - lang(lng_proxy_use_for_calls), + tr::lng_proxy_use_for_calls(tr::now), Global::UseProxyForCalls()), style::margins( 0, @@ -533,7 +533,7 @@ void ProxiesBox::setupContent() { inner, object_ptr( inner, - lang(lng_proxy_about), + tr::lng_proxy_about(tr::now), st::boxDividerLabel), st::proxyAboutPadding), style::margins(0, 0, 0, st::proxyRowPadding.top())); @@ -650,7 +650,7 @@ void ProxiesBox::createNoRowsLabel() { _noRows->height()); const auto label = Ui::CreateChild( _noRows.get(), - lang(lng_proxy_description), + tr::lng_proxy_description(tr::now), st::proxyEmptyListLabel); _noRows->widthValue( ) | rpl::start_with_next([=](int width) { @@ -777,13 +777,13 @@ void ProxyBox::setupTypes() { _content, object_ptr( _content, - lang(lng_proxy_sponsor_warning), + tr::lng_proxy_sponsor_warning(tr::now), st::boxDividerLabel), st::proxyAboutSponsorPadding))); } void ProxyBox::setupSocketAddress(const ProxyData &data) { - addLabel(_content, lang(lng_proxy_address_label)); + addLabel(_content, tr::lng_proxy_address_label(tr::now)); const auto address = _content->add( object_ptr( _content, @@ -815,7 +815,7 @@ void ProxyBox::setupCredentials(const ProxyData &data) { _content, object_ptr(_content))); const auto credentials = _credentials->entity(); - addLabel(credentials, lang(lng_proxy_credentials_optional)); + addLabel(credentials, tr::lng_proxy_credentials_optional(tr::now)); _user = credentials->add( object_ptr( credentials, @@ -848,7 +848,7 @@ void ProxyBox::setupMtprotoCredentials(const ProxyData &data) { _content, object_ptr(_content))); const auto mtproto = _mtprotoCredentials->entity(); - addLabel(mtproto, lang(lng_proxy_credentials)); + addLabel(mtproto, tr::lng_proxy_credentials(tr::now)); auto secretWrap = object_ptr(mtproto); _secret = Ui::CreateChild( @@ -958,9 +958,9 @@ void ProxiesBoxController::ShowApplyConfirmation( lt_port, QString::number(port)) + (proxy.type == Type::Mtproto - ? "\n\n" + lang(lng_proxy_sponsor_warning) + ? "\n\n" + tr::lng_proxy_sponsor_warning(tr::now) : QString()); - *box = Ui::show(Box(text, lang(lng_sure_enable), [=] { + *box = Ui::show(Box(text, tr::lng_sure_enable(tr::now), [=] { auto &proxies = Global::RefProxiesList(); if (ranges::find(proxies, proxy) == end(proxies)) { proxies.push_back(proxy); @@ -1372,7 +1372,7 @@ void ProxiesBoxController::share(const ProxyData &proxy) { + ((proxy.type == Type::Mtproto && !proxy.password.isEmpty()) ? "&secret=" + proxy.password : ""); QApplication::clipboard()->setText(link); - Ui::Toast::Show(lang(lng_username_copied)); + Ui::Toast::Show(tr::lng_username_copied(tr::now)); } ProxiesBoxController::~ProxiesBoxController() { diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 163b32b17..99fd36897 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -655,7 +655,7 @@ object_ptr CreatePollBox::setupContent() { }) | rpl::map([=](int count) { return (count < kMaxOptionsCount) ? lng_polls_create_limit(lt_count, kMaxOptionsCount - count) - : lang(lng_polls_create_maximum); + : tr::lng_polls_create_maximum(tr::now); }) | rpl::after_next([=] { container->resizeToWidth(container->widthNoMargins()); }); diff --git a/Telegram/SourceFiles/boxes/download_path_box.cpp b/Telegram/SourceFiles/boxes/download_path_box.cpp index 3bfc1c1ec..9584c0e7f 100644 --- a/Telegram/SourceFiles/boxes/download_path_box.cpp +++ b/Telegram/SourceFiles/boxes/download_path_box.cpp @@ -19,9 +19,9 @@ DownloadPathBox::DownloadPathBox(QWidget *parent) : _path(Global::DownloadPath()) , _pathBookmark(Global::DownloadPathBookmark()) , _group(std::make_shared>(typeFromPath(_path))) -, _default(this, _group, Directory::Downloads, lang(lng_download_path_default_radio), st::defaultBoxCheckbox) -, _temp(this, _group, Directory::Temp, lang(lng_download_path_temp_radio), st::defaultBoxCheckbox) -, _dir(this, _group, Directory::Custom, lang(lng_download_path_dir_radio), st::defaultBoxCheckbox) +, _default(this, _group, Directory::Downloads, tr::lng_download_path_default_radio(tr::now), st::defaultBoxCheckbox) +, _temp(this, _group, Directory::Temp, tr::lng_download_path_temp_radio(tr::now), st::defaultBoxCheckbox) +, _dir(this, _group, Directory::Custom, tr::lng_download_path_dir_radio(tr::now), st::defaultBoxCheckbox) , _pathLink(this, QString(), st::boxLinkButton) { } @@ -99,7 +99,7 @@ void DownloadPathBox::editPath() { }; FileDialog::GetFolder( this, - lang(lng_download_path_choose), + tr::lng_download_path_choose(tr::now), initialPath, crl::guard(this, handleFolder)); } diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 421f1df94..442f30fc8 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -107,7 +107,7 @@ EditCaptionBox::EditCaptionBox( if (doc) { const auto nameString = doc->isVoiceMessage() - ? lang(lng_media_audio) + ? tr::lng_media_audio(tr::now) : doc->composeNameString(); setName(nameString, doc->size); _isImage = doc->isImage(); @@ -262,7 +262,7 @@ EditCaptionBox::EditCaptionBox( this, object_ptr( this, - lang(lng_send_file), + tr::lng_send_file(tr::now), false, st::defaultBoxCheckbox), st::editMediaCheckboxMargins); @@ -481,7 +481,7 @@ void EditCaptionBox::createEditMediaButton() { const auto isValidFile = [](QString mimeType) { if (mimeType == qstr("image/webp")) { Ui::show( - Box(lang(lng_edit_media_invalid_file)), + Box(tr::lng_edit_media_invalid_file(tr::now)), LayerOption::KeepOther); return false; } @@ -509,7 +509,7 @@ void EditCaptionBox::createEditMediaButton() { if (ranges::find(albumMimes, file->mime) == end(albumMimes) || file->type == Storage::PreparedFile::AlbumType::None) { Ui::show( - Box(lang(lng_edit_media_album_error)), + Box(tr::lng_edit_media_album_error(tr::now)), LayerOption::KeepOther); return; } @@ -539,7 +539,7 @@ void EditCaptionBox::createEditMediaButton() { }); if (!valid) { Ui::show( - Box(lang(lng_edit_media_album_error)), + Box(tr::lng_edit_media_album_error(tr::now)), LayerOption::KeepOther); return; } @@ -563,7 +563,7 @@ void EditCaptionBox::createEditMediaButton() { : QStringList(FileDialog::AllFilesFilter()); FileDialog::GetOpenPath( this, - lang(lng_choose_file), + tr::lng_choose_file(tr::now), filters.join(qsl(";;")), crl::guard(this, callback)); }; @@ -674,7 +674,7 @@ bool EditCaptionBox::fileFromClipboard(not_null data) { if (list.files.front().type == Storage::PreparedFile::AlbumType::None && _isAlbum) { Ui::show( - Box(lang(lng_edit_media_album_error)), + Box(tr::lng_edit_media_album_error(tr::now)), LayerOption::KeepOther); return false; } @@ -827,7 +827,7 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { } else { p.setFont(st::boxTitleFont); p.setPen(st::boxTextFg); - p.drawTextLeft(_field->x(), st::boxPhotoPadding.top(), width(), lang(lng_edit_message)); + p.drawTextLeft(_field->x(), st::boxPhotoPadding.top(), width(), tr::lng_edit_message(tr::now)); } if (!_error.isEmpty()) { @@ -875,7 +875,7 @@ void EditCaptionBox::save() { const auto item = Auth().data().message(_msgId); if (!item) { - _error = lang(lng_edit_deleted); + _error = tr::lng_edit_deleted(tr::now); update(); return; } @@ -945,7 +945,7 @@ bool EditCaptionBox::saveFail(const RPCError &error) { _saveRequestId = 0; QString err = error.type(); if (err == qstr("MESSAGE_ID_INVALID") || err == qstr("CHAT_ADMIN_REQUIRED") || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) { - _error = lang(lng_edit_error); + _error = tr::lng_edit_error(tr::now); } else if (err == qstr("MESSAGE_NOT_MODIFIED")) { closeBox(); return true; @@ -953,7 +953,7 @@ bool EditCaptionBox::saveFail(const RPCError &error) { _field->setFocus(); _field->showError(); } else { - _error = lang(lng_edit_error); + _error = tr::lng_edit_error(tr::now); } update(); return true; diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 75a6c0c7f..34e01263e 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -102,11 +102,11 @@ std::unique_ptr PrivacyExceptionsBoxControl } // namespace -LangKey EditPrivacyController::optionLabelKey(Option option) { +QString EditPrivacyController::optionLabel(Option option) { switch (option) { - case Option::Everyone: return lng_edit_privacy_everyone; - case Option::Contacts: return lng_edit_privacy_contacts; - case Option::Nobody: return lng_edit_privacy_nobody; + case Option::Everyone: return tr::lng_edit_privacy_everyone(tr::now); + case Option::Contacts: return tr::lng_edit_privacy_contacts(tr::now); + case Option::Nobody: return tr::lng_edit_privacy_nobody(tr::now); } Unexpected("Option value in optionsLabelKey."); } @@ -244,7 +244,7 @@ Ui::Radioenum *EditPrivacyBox::addOption( container, group, option, - lang(_controller->optionLabelKey(option)), + _controller->optionLabel(option), st::settingsSendType), st::settingsSendTypePadding); } @@ -303,7 +303,7 @@ void EditPrivacyBox::setupContent() { }) | rpl::map([](int count) { return count ? lng_edit_privacy_exceptions_count(lt_count, count) - : lang(lng_edit_privacy_exceptions_add); + : tr::lng_edit_privacy_exceptions_add(tr::now); }); auto text = _controller->exceptionButtonTextKey(exception); const auto button = content->add( diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.h b/Telegram/SourceFiles/boxes/edit_privacy_box.h index 2784d9e98..64aed7d6d 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.h +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.h @@ -44,7 +44,7 @@ public: return true; } [[nodiscard]] virtual rpl::producer optionsTitleKey() = 0; - [[nodiscard]] virtual LangKey optionLabelKey(Option option); + [[nodiscard]] virtual QString optionLabel(Option option); [[nodiscard]] virtual rpl::producer warning() { return nullptr; } diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 6450d41fa..a45cd07ef 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -409,7 +409,7 @@ bool Rows::hasMenu(not_null row) const { void Rows::share(not_null row) const { const auto link = qsl("https://t.me/setlanguage/") + row->data.id; QApplication::clipboard()->setText(link); - Ui::Toast::Show(lang(lng_username_copied)); + Ui::Toast::Show(tr::lng_username_copied(tr::now)); } void Rows::remove(not_null row) { @@ -461,15 +461,15 @@ void Rows::showMenu(int index) { }; const auto id = row->data.id; if (canShare(row)) { - addAction(lang(lng_proxy_edit_share), [=] { share(row); }); + addAction(tr::lng_proxy_edit_share(tr::now), [=] { share(row); }); } if (canRemove(row)) { if (row->removed) { - addAction(lang(lng_proxy_menu_restore), [=] { + addAction(tr::lng_proxy_menu_restore(tr::now), [=] { restore(row); }); } else { - addAction(lang(lng_proxy_menu_delete), [=] { + addAction(tr::lng_proxy_menu_delete(tr::now), [=] { remove(row); }); } diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index 6ca24418b..747ed5293 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -106,7 +106,7 @@ QString TimeLimitText(size_type limit) { ? lng_local_storage_limit_months(lt_count, months) : (limit > 0) ? lng_local_storage_limit_weeks(lt_count, weeks) - : lang(lng_local_storage_limit_never); + : tr::lng_local_storage_limit_never(tr::now); } size_type LimitToValue(size_type timeLimit) { @@ -189,7 +189,7 @@ void LocalStorageBox::Row::toggleProgress(bool shown) { _progress->start(); _clearing = object_ptr( this, - lang(lng_local_storage_clearing), + tr::lng_local_storage_clearing(tr::now), st::localStorageRowSize); _clearing->show(); _description->hide(); @@ -260,7 +260,7 @@ QString LocalStorageBox::Row::titleText(const Database::TaggedSummary &data) con QString LocalStorageBox::Row::sizeText(const Database::TaggedSummary &data) const { return data.totalSize ? formatSizeText(data.totalSize) - : lang(lng_local_storage_empty); + : tr::lng_local_storage_empty(tr::now); } LocalStorageBox::LocalStorageBox( @@ -399,10 +399,10 @@ void LocalStorageBox::setupControls() { data)); }; auto summaryTitle = [](size_type) { - return lang(lng_local_storage_summary); + return tr::lng_local_storage_summary(tr::now); }; auto mediaCacheTitle = [](size_type) { - return lang(lng_local_storage_media); + return tr::lng_local_storage_media(tr::now); }; createRow( 0, diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index 9de1132d8..b17810897 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -30,7 +30,7 @@ void MuteSettingsBox::prepare() { auto y = 0; object_ptr info(this, st::boxLabel); - info->setText(lang(lng_mute_box_tip)); + info->setText(tr::lng_mute_box_tip(tr::now)); info->moveToLeft(st::boxPadding.left(), y); y += info->height() + st::boxLittleSkip; @@ -60,7 +60,7 @@ void MuteSettingsBox::prepare() { } else if (hours < kForeverHours) { return lng_mute_duration_days(lt_count, hours / 24); } else { - return lang(lng_mute_duration_forever); + return tr::lng_mute_duration_forever(tr::now); } }(); object_ptr option(this, group, hours, text); diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index 613f61f67..f861d088a 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -48,7 +48,7 @@ PasscodeBox::PasscodeBox(QWidget*, bool turningOff) , _reenterPasscode(this, st::defaultInputField, tr::lng_passcode_confirm_new()) , _passwordHint(this, st::defaultInputField, tr::lng_cloud_password_hint()) , _recoverEmail(this, st::defaultInputField, tr::lng_cloud_password_email()) -, _recover(this, lang(lng_signin_recover)) { +, _recover(this, tr::lng_signin_recover(tr::now)) { } PasscodeBox::PasscodeBox(QWidget*, const CloudFields &fields) @@ -61,7 +61,7 @@ PasscodeBox::PasscodeBox(QWidget*, const CloudFields &fields) , _reenterPasscode(this, st::defaultInputField, tr::lng_cloud_password_confirm_new()) , _passwordHint(this, st::defaultInputField, fields.curRequest ? tr::lng_cloud_password_change_hint() : tr::lng_cloud_password_hint()) , _recoverEmail(this, st::defaultInputField, tr::lng_cloud_password_email()) -, _recover(this, lang(lng_signin_recover)) { +, _recover(this, tr::lng_signin_recover(tr::now)) { Expects(!_turningOff || _cloudFields.curRequest); if (!_cloudFields.hint.isEmpty()) { @@ -103,9 +103,11 @@ void PasscodeBox::prepare() { _about.setText( st::passcodeTextStyle, - _cloudFields.customDescription.value_or(lang(_cloudPwd - ? lng_cloud_password_about - : lng_passcode_about))); + (_cloudFields.customDescription + ? *_cloudFields.customDescription + : _cloudPwd + ? tr::lng_cloud_password_about(tr::now) + : tr::lng_passcode_about(tr::now))); _aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() * 1.5); const auto onlyCheck = onlyCheckCurrent(); if (onlyCheck) { @@ -259,7 +261,11 @@ void PasscodeBox::setPasswordDone(const QByteArray &newPasswordBytes) { _setRequest = 0; _newPasswordSet.fire_copy(newPasswordBytes); const auto weak = make_weak(this); - const auto text = lang(_reenterPasscode->isHidden() ? lng_cloud_password_removed : (_oldPasscode->isHidden() ? lng_cloud_password_was_set : lng_cloud_password_updated)); + const auto text = _reenterPasscode->isHidden() + ? tr::lng_cloud_password_removed(tr::now) + : _oldPasscode->isHidden() + ? tr::lng_cloud_password_was_set(tr::now) + : tr::lng_cloud_password_updated(tr::now); getDelegate()->show(Box(text)); if (weak) { closeBox(); @@ -282,7 +288,7 @@ void PasscodeBox::setPasswordFail(const RPCError &error) { _oldPasscode->selectAll(); _oldPasscode->setFocus(); _oldPasscode->showError(); - _oldError = lang(lng_flood_error); + _oldError = tr::lng_flood_error(tr::now); if (_cloudFields.hasRecovery && _hintText.isEmpty()) { _recover->hide(); } @@ -306,7 +312,7 @@ void PasscodeBox::setPasswordFail(const RPCError &error) { //} else if (err == qstr("NEW_PASSWORD_BAD")) { //} else if (err == qstr("NEW_SALT_INVALID")) { } else if (err == qstr("EMAIL_INVALID")) { - _emailError = lang(lng_cloud_password_bad_email); + _emailError = tr::lng_cloud_password_bad_email(tr::now); _recoverEmail->setFocus(); _recoverEmail->showError(); update(); @@ -349,9 +355,9 @@ void PasscodeBox::validateEmail( }).fail([=](const RPCError &error) { _setRequest = 0; if (MTP::isFloodError(error)) { - errors->fire(lang(lng_flood_error)); + errors->fire(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("CODE_INVALID")) { - errors->fire(lang(lng_signin_wrong_code)); + errors->fire(tr::lng_signin_wrong_code(tr::now)); } else if (error.type() == qstr("EMAIL_HASH_EXPIRED")) { const auto weak = make_weak(this); _clearUnconfirmedPassword.fire({}); @@ -374,7 +380,7 @@ void PasscodeBox::validateEmail( _setRequest = request(MTPaccount_ResendPasswordEmail( )).done([=](const MTPBool &result) { _setRequest = 0; - resent->fire(lang(lng_cloud_password_resent)); + resent->fire(tr::lng_cloud_password_resent(tr::now)); }).fail([=](const RPCError &error) { _setRequest = 0; errors->fire(Lang::Hard::ServerError()); @@ -424,7 +430,7 @@ void PasscodeBox::save(bool force) { const auto has = currentlyHave(); if (!_cloudPwd && (_turningOff || has)) { if (!passcodeCanTry()) { - _oldError = lang(lng_flood_error); + _oldError = tr::lng_flood_error(tr::now); _oldPasscode->setFocus(); _oldPasscode->showError(); update(); @@ -453,14 +459,18 @@ void PasscodeBox::save(bool force) { _reenterPasscode->setFocus(); _reenterPasscode->showError(); if (!conf.isEmpty()) { - _newError = lang(_cloudPwd ? lng_cloud_password_differ : lng_passcode_differ); + _newError = _cloudPwd + ? tr::lng_cloud_password_differ(tr::now) + : tr::lng_passcode_differ(tr::now); update(); } closeReplacedBy(); } else if (!onlyCheck && has && old == pwd) { _newPasscode->setFocus(); _newPasscode->showError(); - _newError = lang(_cloudPwd ? lng_cloud_password_is_same : lng_passcode_is_same); + _newError = _cloudPwd + ? tr::lng_cloud_password_is_same(tr::now) + : tr::lng_passcode_is_same(tr::now); update(); closeReplacedBy(); } else if (_cloudPwd) { @@ -471,7 +481,7 @@ void PasscodeBox::save(bool force) { && pwd == hint) { _newPasscode->setFocus(); _newPasscode->showError(); - _newError = lang(lng_cloud_password_bad); + _newError = tr::lng_cloud_password_bad(tr::now); update(); closeReplacedBy(); return; @@ -480,8 +490,8 @@ void PasscodeBox::save(bool force) { _skipEmailWarning = true; _replacedBy = getDelegate()->show( Box( - lang(lng_cloud_password_about_recover), - lang(lng_cloud_password_skip_email), + tr::lng_cloud_password_about_recover(tr::now), + tr::lng_cloud_password_skip_email(tr::now), st::attentionBoxButton, crl::guard(this, [this] { save(true); }))); } else if (onlyCheck) { @@ -520,8 +530,8 @@ void PasscodeBox::submitOnlyCheckCloudPassword(const QString &oldPassword) { } }; *box = getDelegate()->show(Box( - lang(lng_cloud_password_passport_losing), - lang(lng_continue), + tr::lng_cloud_password_passport_losing(tr::now), + tr::lng_continue(tr::now), confirmed)); } else { send(); @@ -817,7 +827,9 @@ void PasscodeBox::badOldPasscode() { _oldPasscode->selectAll(); _oldPasscode->setFocus(); _oldPasscode->showError(); - _oldError = lang(_cloudPwd ? lng_cloud_password_wrong : lng_passcode_wrong); + _oldError = _cloudPwd + ? tr::lng_cloud_password_wrong(tr::now) + : tr::lng_passcode_wrong(tr::now); if (_cloudFields.hasRecovery && _hintText.isEmpty()) { _recover->hide(); } @@ -977,8 +989,8 @@ void RecoverBox::submit() { } }; *box = getDelegate()->show(Box( - lang(lng_cloud_password_passport_losing), - lang(lng_continue), + tr::lng_cloud_password_passport_losing(tr::now), + tr::lng_continue(tr::now), confirmed)); } else { send(); @@ -997,14 +1009,14 @@ void RecoverBox::codeSubmitDone( _passwordCleared.fire({}); getDelegate()->show( - Box(lang(lng_cloud_password_removed)), + Box(tr::lng_cloud_password_removed(tr::now)), LayerOption::CloseOther); } bool RecoverBox::codeSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { _submitRequest = 0; - _error = lang(lng_flood_error); + _error = tr::lng_flood_error(tr::now); update(); _recoverCode->showError(); return true; @@ -1017,7 +1029,7 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) { if (err == qstr("PASSWORD_EMPTY")) { _passwordCleared.fire({}); getDelegate()->show( - Box(lang(lng_cloud_password_removed)), + Box(tr::lng_cloud_password_removed(tr::now)), LayerOption::CloseOther); return true; } else if (err == qstr("PASSWORD_RECOVERY_NA")) { @@ -1028,7 +1040,7 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) { closeBox(); return true; } else if (err == qstr("CODE_INVALID")) { - _error = lang(lng_signin_wrong_code); + _error = tr::lng_signin_wrong_code(tr::now); update(); _recoverCode->selectAll(); _recoverCode->setFocus(); @@ -1062,7 +1074,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) { reloads->fire({}); if (*weak) { (*weak)->getDelegate()->show( - Box(lang(lng_cloud_password_was_set)), + Box(tr::lng_cloud_password_was_set(tr::now)), LayerOption::CloseOther); } }; @@ -1074,9 +1086,9 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) { } *requestId = 0; if (MTP::isFloodError(error)) { - errors->fire(lang(lng_flood_error)); + errors->fire(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("CODE_INVALID")) { - errors->fire(lang(lng_signin_wrong_code)); + errors->fire(tr::lng_signin_wrong_code(tr::now)); } else if (error.type() == qstr("EMAIL_HASH_EXPIRED")) { cancels->fire({}); if (*weak) { @@ -1103,7 +1115,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) { *requestId = MTP::send(MTPaccount_ResendPasswordEmail( ), rpcDone([=](const MTPBool &result) { *requestId = 0; - resent->fire(lang(lng_cloud_password_resent)); + resent->fire(tr::lng_cloud_password_resent(tr::now)); }), rpcFail([=](const RPCError &error) { *requestId = 0; errors->fire(Lang::Hard::ServerError()); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 141401963..46eac107c 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -295,7 +295,7 @@ void PeerListBox::addSelectItem(not_null peer, PeerListRow::SetStyle } const auto respect = _controller->respectSavedMessagesChat(); const auto text = (respect && peer->isSelf()) - ? lang(lng_saved_short) + ? tr::lng_saved_short(tr::now) : peer->shortName(); const auto callback = PaintUserpicCallback(peer, respect); if (style == PeerListRow::SetStyle::Fast) { @@ -375,7 +375,7 @@ void PeerListRow::refreshStatus() { _statusValidTill = 0; if (auto user = peer()->asUser()) { if (_isSavedMessagesChat) { - setStatusText(lang(lng_saved_forward_here)); + setStatusText(tr::lng_saved_forward_here(tr::now)); } else { auto time = unixtime(); setStatusText(Data::OnlineText(user, time)); @@ -387,16 +387,16 @@ void PeerListRow::refreshStatus() { } } else if (auto chat = peer()->asChat()) { if (!chat->amIn()) { - setStatusText(lang(lng_chat_status_unaccessible)); + setStatusText(tr::lng_chat_status_unaccessible(tr::now)); } else if (chat->count > 0) { setStatusText(lng_chat_status_members(lt_count_decimal, chat->count)); } else { - setStatusText(lang(lng_group_status)); + setStatusText(tr::lng_group_status(tr::now)); } } else if (peer()->isMegagroup()) { - setStatusText(lang(lng_group_status)); + setStatusText(tr::lng_group_status(tr::now)); } else if (peer()->isChannel()) { - setStatusText(lang(lng_channel_status)); + setStatusText(tr::lng_channel_status(tr::now)); } } @@ -409,7 +409,7 @@ void PeerListRow::refreshName(const style::PeerListItem &st) { return; } const auto text = _isSavedMessagesChat - ? lang(lng_saved_messages) + ? tr::lng_saved_messages(tr::now) : peer()->name; _name.setText(st.nameStyle, text, Ui::NameTextOptions()); } @@ -888,7 +888,7 @@ void PeerListContent::setSearchMode(PeerListSearchMode mode) { if (!_searchLoading) { setSearchLoading(object_ptr( this, - lang(lng_contacts_loading), + tr::lng_contacts_loading(tr::now), st::membersAbout)); } } else { diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index d8bcddab5..9740882ae 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -221,7 +221,7 @@ ChatsListBoxController::ChatsListBoxController( } void ChatsListBoxController::prepare() { - setSearchNoResultsText(lang(lng_blocked_list_not_found)); + setSearchNoResultsText(tr::lng_blocked_list_not_found(tr::now)); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); prepareViewHook(); @@ -293,12 +293,12 @@ void ChatsListBoxController::checkForEmptyRows() { } else { const auto loaded = Auth().data().contactsLoaded().current() && Auth().data().chatsListLoaded(); - setDescriptionText(loaded ? emptyBoxText() : lang(lng_contacts_loading)); + setDescriptionText(loaded ? emptyBoxText() : tr::lng_contacts_loading(tr::now)); } } QString ChatsListBoxController::emptyBoxText() const { - return lang(lng_contacts_not_found); + return tr::lng_contacts_not_found(tr::now); } std::unique_ptr ChatsListBoxController::createSearchRow(not_null peer) { @@ -323,7 +323,7 @@ ContactsBoxController::ContactsBoxController( } void ContactsBoxController::prepare() { - setSearchNoResultsText(lang(lng_blocked_list_not_found)); + setSearchNoResultsText(tr::lng_blocked_list_not_found(tr::now)); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); delegate()->peerListSetTitle(tr::lng_contacts_header()); @@ -355,12 +355,11 @@ void ContactsBoxController::rebuildRows() { } void ContactsBoxController::checkForEmptyRows() { - if (delegate()->peerListFullRowsCount()) { - setDescriptionText(QString()); - } else { - const auto loaded = Auth().data().contactsLoaded().current(); - setDescriptionText(lang(loaded ? lng_contacts_not_found : lng_contacts_loading)); - } + setDescriptionText(delegate()->peerListFullRowsCount() + ? QString() + : Auth().data().contactsLoaded().current() + ? tr::lng_contacts_not_found(tr::now) + : tr::lng_contacts_loading(tr::now)); } std::unique_ptr ContactsBoxController::createSearchRow( @@ -432,7 +431,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null chat) { if (const auto megagroup = chat->asMegagroup()) { if (!megagroup->canAddMembers()) { Ui::show( - Box(lang(lng_error_cant_add_member)), + Box(tr::lng_error_cant_add_member(tr::now)), LayerOption::KeepOther); return; } @@ -481,15 +480,19 @@ bool AddBotToGroupBoxController::sharingBotGame() const { } QString AddBotToGroupBoxController::emptyBoxText() const { - return lang(Auth().data().chatsListLoaded() - ? (sharingBotGame() ? lng_bot_no_chats : lng_bot_no_groups) - : lng_contacts_loading); + return !Auth().data().chatsListLoaded() + ? tr::lng_contacts_loading(tr::now) + : sharingBotGame() + ? tr::lng_bot_no_chats(tr::now) + : tr::lng_bot_no_groups(tr::now); } QString AddBotToGroupBoxController::noResultsText() const { - return lang(Auth().data().chatsListLoaded() - ? (sharingBotGame() ? lng_bot_chats_not_found : lng_bot_groups_not_found) - : lng_contacts_loading); + return !Auth().data().chatsListLoaded() + ? tr::lng_contacts_loading(tr::now) + : sharingBotGame() + ? tr::lng_bot_chats_not_found(tr::now) + : tr::lng_bot_groups_not_found(tr::now); } void AddBotToGroupBoxController::updateLabels() { diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index a1205d76e..6babe78bf 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -91,7 +91,7 @@ void AddParticipantsBoxController::rowClicked(not_null row) { } else if (count >= Global::ChatSizeMax() && count < Global::MegagroupSizeMax()) { Ui::show( - Box(lang(lng_profile_add_more_after_create)), + Box(tr::lng_profile_add_more_after_create(tr::now)), LayerOption::KeepOther); } } @@ -299,8 +299,8 @@ void AddSpecialBoxController::prepare() { Unexpected("Role in AddSpecialBoxController::prepare()"); }(); delegate()->peerListSetTitle(std::move(title)); - setDescriptionText(lang(lng_contacts_loading)); - setSearchNoResultsText(lang(lng_blocked_list_not_found)); + setDescriptionText(tr::lng_contacts_loading(tr::now)); + setSearchNoResultsText(tr::lng_blocked_list_not_found(tr::now)); if (const auto chat = _peer->asChat()) { prepareChatRows(chat); @@ -409,7 +409,7 @@ void AddSpecialBoxController::loadMoreRows() { if (delegate()->peerListFullRowsCount() > 0) { setDescriptionText(QString()); } else if (_allLoaded) { - setDescriptionText(lang(lng_blocked_list_not_found)); + setDescriptionText(tr::lng_blocked_list_not_found(tr::now)); } delegate()->peerListRefreshRows(); }).fail([this](const RPCError &error) { @@ -488,20 +488,20 @@ void AddSpecialBoxController::showAdmin( if (!sure) { _editBox = Ui::show( Box( - lang(lng_sure_add_admin_unremove), + tr::lng_sure_add_admin_unremove(tr::now), showAdminSure), LayerOption::KeepOther); return; } } else { Ui::show(Box( - lang(lng_error_cant_add_admin_unban)), + tr::lng_error_cant_add_admin_unban(tr::now)), LayerOption::KeepOther); return; } } else { Ui::show(Box( - lang(lng_error_cant_add_admin_invite)), + tr::lng_error_cant_add_admin_invite(tr::now)), LayerOption::KeepOther); return; } @@ -511,14 +511,14 @@ void AddSpecialBoxController::showAdmin( if (!sure) { _editBox = Ui::show( Box( - lang(lng_sure_add_admin_unremove), + tr::lng_sure_add_admin_unremove(tr::now), showAdminSure), LayerOption::KeepOther); return; } } else { Ui::show(Box( - lang(lng_error_cant_add_admin_unban)), + tr::lng_error_cant_add_admin_unban(tr::now)), LayerOption::KeepOther); return; } @@ -526,10 +526,9 @@ void AddSpecialBoxController::showAdmin( // The user is not in the group yet. if (canAddMembers) { if (!sure) { - const auto text = lang( - ((_peer->isChat() || _peer->isMegagroup()) - ? lng_sure_add_admin_invite - : lng_sure_add_admin_invite_channel)); + const auto text = ((_peer->isChat() || _peer->isMegagroup()) + ? tr::lng_sure_add_admin_invite + : tr::lng_sure_add_admin_invite_channel)(tr::now); _editBox = Ui::show( Box( text, @@ -539,7 +538,7 @@ void AddSpecialBoxController::showAdmin( } } else { Ui::show( - Box(lang(lng_error_cant_add_admin_invite)), + Box(tr::lng_error_cant_add_admin_invite(tr::now)), LayerOption::KeepOther); return; } @@ -626,14 +625,14 @@ void AddSpecialBoxController::showRestricted( if (!sure) { _editBox = Ui::show( Box( - lang(lng_sure_ban_admin), + tr::lng_sure_ban_admin(tr::now), showRestrictedSure), LayerOption::KeepOther); return; } } else { Ui::show( - Box(lang(lng_error_cant_ban_admin)), + Box(tr::lng_error_cant_ban_admin(tr::now)), LayerOption::KeepOther); return; } @@ -716,14 +715,14 @@ void AddSpecialBoxController::kickUser( if (!sure) { _editBox = Ui::show( Box( - lang(lng_sure_ban_admin), + tr::lng_sure_ban_admin(tr::now), kickUserSure), LayerOption::KeepOther); return; } } else { Ui::show( - Box(lang(lng_error_cant_ban_admin)), + Box(tr::lng_error_cant_ban_admin(tr::now)), LayerOption::KeepOther); return; } diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index b25aab530..2a57dc614 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -231,7 +231,7 @@ void Controller::setupSharePhoneNumber() { _sharePhone = _box->addRow( object_ptr( _box, - lang(lng_contact_share_phone), + tr::lng_contact_share_phone(tr::now), true, st::defaultBoxCheckbox), st::addContactWarningMargin); diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index f0eca8573..7916fc10f 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -81,7 +81,7 @@ void Controller::prepare() { auto row = std::make_unique(chat); const auto username = chat->userName(); row->setCustomStatus(username.isEmpty() - ? lang(lng_manage_discussion_group_private_status) + ? tr::lng_manage_discussion_group_private_status(tr::now) : ('@' + username)); delegate()->peerListAppendRow(std::move(row)); }; @@ -148,7 +148,7 @@ void Controller::choose(not_null chat) { *box = Ui::show( Box( text, - lang(lng_manage_discussion_group_link), + tr::lng_manage_discussion_group_link(tr::now), sure), LayerOption::KeepOther); } @@ -183,7 +183,7 @@ void Controller::choose(not_null chat) { *box = Ui::show( Box( text, - lang(lng_manage_discussion_group_link), + tr::lng_manage_discussion_group_link(tr::now), sure), LayerOption::KeepOther); } @@ -222,9 +222,9 @@ object_ptr SetupFooter( not_null channel) { return object_ptr( parent, - lang(channel->isBroadcast() - ? lng_manage_discussion_group_posted - : lng_manage_linked_channel_posted), + (channel->isBroadcast() + ? tr::lng_manage_discussion_group_posted + : tr::lng_manage_linked_channel_posted)(), st::linkedChatAbout); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index c667758fc..0b414fdd8 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -199,9 +199,9 @@ void EditParticipantBox::Inner::paintEvent(QPaintEvent *e) { if (_user->botInfo) { const auto seesAllMessages = _user->botInfo->readsAllHistory || _hasAdminRights; - return lang(seesAllMessages - ? lng_status_bot_reads_all - : lng_status_bot_not_reads_all); + return (seesAllMessages + ? tr::lng_status_bot_reads_all + : tr::lng_status_bot_not_reads_all)(tr::now); } return Data::OnlineText(_user->onlineTill, unixtime()); }; @@ -305,16 +305,16 @@ void EditAdminBox::prepare() { if (!canSave()) { result.emplace( ~Flags(0), - lang(lng_rights_about_admin_cant_edit)); + tr::lng_rights_about_admin_cant_edit(tr::now)); } else { result.emplace( disabledByDefaults, - lang(lng_rights_permission_for_all)); + tr::lng_rights_permission_for_all(tr::now)); if (const auto channel = peer()->asChannel()) { if (!channel->amCreator()) { result.emplace( ~channel->adminRights(), - lang(lng_rights_permission_cant_edit)); + tr::lng_rights_permission_cant_edit(tr::now)); } } } @@ -444,7 +444,7 @@ void EditAdminBox::transferOwnership() { lt_user, Ui::Text::Bold(user()->shortName()), Ui::Text::RichLangValue), - lang(lng_rights_transfer_sure), + tr::lng_rights_transfer_sure(tr::now), crl::guard(this, [=] { transferOwnershipChecked(); }))); } }).send(); @@ -492,7 +492,7 @@ void EditAdminBox::requestTransferPassword(not_null channel) { auto fields = PasscodeBox::CloudFields::From(state); fields.customTitle = tr::lng_rights_transfer_password_title(); fields.customDescription - = lang(lng_rights_transfer_password_description); + = tr::lng_rights_transfer_password_description(tr::now); fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = crl::guard(this, [=]( const Core::CloudPasswordResult &result) { @@ -533,15 +533,15 @@ void EditAdminBox::sendTransferRequestFrom( const auto &type = error.type(); const auto problem = [&] { if (type == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) { - return lang(lng_channels_too_much_public_other); + return tr::lng_channels_too_much_public_other(tr::now); } else if (type == qstr("ADMINS_TOO_MUCH")) { - return lang(channel->isBroadcast() - ? lng_error_admin_limit_channel - : lng_error_admin_limit); + return (channel->isBroadcast() + ? tr::lng_error_admin_limit_channel + : tr::lng_error_admin_limit)(tr::now); } else if (type == qstr("CHANNEL_INVALID")) { - return lang(channel->isBroadcast() - ? lng_channel_not_accessible - : lng_group_not_accessible); + return (channel->isBroadcast() + ? tr::lng_channel_not_accessible + : tr::lng_group_not_accessible)(tr::now); } return Lang::Hard::ServerError(); }(); @@ -565,11 +565,11 @@ void EditAdminBox::sendTransferRequestFrom( void EditAdminBox::refreshAboutAddAdminsText(bool canAddAdmins) { _aboutAddAdmins->setText([&] { if (!canSave()) { - return lang(lng_rights_about_admin_cant_edit); + return tr::lng_rights_about_admin_cant_edit(tr::now); } else if (canAddAdmins) { - return lang(lng_rights_about_add_admins_yes); + return tr::lng_rights_about_add_admins_yes(tr::now); } - return lang(lng_rights_about_add_admins_no); + return tr::lng_rights_about_add_admins_no(tr::now); }()); } @@ -611,7 +611,7 @@ void EditRestrictedBox::prepare() { if (!canSave()) { result.emplace( ~Flags(0), - lang(lng_rights_about_restriction_cant_edit)); + tr::lng_rights_about_restriction_cant_edit(tr::now)); } else { const auto disabled = FixDependentRestrictions( defaultRestrictions @@ -620,7 +620,7 @@ void EditRestrictedBox::prepare() { : Flags(0))); result.emplace( disabled, - lang(lng_rights_restriction_for_all)); + tr::lng_rights_restriction_for_all(tr::now)); } return result; }(); @@ -637,7 +637,7 @@ void EditRestrictedBox::prepare() { addControl( object_ptr( this, - lang(lng_rights_chat_banned_until_header), + tr::lng_rights_chat_banned_until_header(tr::now), st::rightsHeaderLabel), st::rightsHeaderMargin); setRestrictUntil(_until); @@ -645,7 +645,7 @@ void EditRestrictedBox::prepare() { //addControl( // object_ptr( // this, - // lang(lng_rights_chat_banned_block), + // tr::lng_rights_chat_banned_block(tr::now), // st::boxLinkButton)); if (canSave()) { @@ -759,7 +759,7 @@ void EditRestrictedBox::createUntilVariants() { addCustomVariant(oldUntil, from, to); } }; - addVariant(0, lang(lng_rights_chat_banned_forever)); + addVariant(0, tr::lng_rights_chat_banned_forever(tr::now)); auto now = unixtime(); auto nextDay = now + kSecondsInDay; @@ -769,7 +769,7 @@ void EditRestrictedBox::createUntilVariants() { addCurrentVariant(nextDay, nextWeek); addVariant(kUntilOneWeek, lng_rights_chat_banned_week(lt_count, 1)); addCurrentVariant(nextWeek, INT_MAX); - addVariant(kUntilCustom, lang(lng_rights_chat_banned_custom)); + addVariant(kUntilCustom, tr::lng_rights_chat_banned_custom(tr::now)); } TimeId EditRestrictedBox::getRealUntilValue() const { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 3a0ccc3c8..0744c4cb3 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1024,8 +1024,8 @@ void ParticipantsBoxController::prepare() { }(); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); delegate()->peerListSetTitle(std::move(title)); - setDescriptionText(lang(lng_contacts_loading)); - setSearchNoResultsText(lang(lng_blocked_list_not_found)); + setDescriptionText(tr::lng_contacts_loading(tr::now)); + setSearchNoResultsText(tr::lng_blocked_list_not_found(tr::now)); if (const auto chat = _peer->asChat()) { prepareChatRows(chat); @@ -1268,12 +1268,12 @@ void ParticipantsBoxController::loadMoreRows() { void ParticipantsBoxController::refreshDescription() { setDescriptionText((_role == Role::Kicked) - ? lang((_peer->isChat() || _peer->isMegagroup()) - ? lng_group_removed_list_about - : lng_channel_removed_list_about) + ? ((_peer->isChat() || _peer->isMegagroup()) + ? tr::lng_group_removed_list_about + : tr::lng_channel_removed_list_about)(tr::now) : (delegate()->peerListFullRowsCount() > 0) ? QString() - : lang(lng_blocked_list_not_found)); + : tr::lng_blocked_list_not_found(tr::now)); } bool ParticipantsBoxController::feedMegagroupLastParticipants() { @@ -1357,18 +1357,18 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( const auto user = row->peer()->asUser(); auto result = base::make_unique_q(parent); result->addAction( - lang(lng_context_view_profile), + tr::lng_context_view_profile(tr::now), crl::guard(this, [=] { _navigation->showPeerInfo(user); })); if (_role == Role::Kicked) { if (_peer->isMegagroup() && _additional.canRestrictUser(user)) { if (channel->canAddMembers()) { result->addAction( - lang(lng_context_add_to_group), + tr::lng_context_add_to_group(tr::now), crl::guard(this, [=] { unkickMember(user); })); } result->addAction( - lang(lng_profile_delete_removed), + tr::lng_profile_delete_removed(tr::now), crl::guard(this, [=] { removeKickedWithRow(user); })); } return result; @@ -1376,11 +1376,10 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( if (_additional.canAddOrEditAdmin(user)) { const auto isAdmin = _additional.isCreator(user) || _additional.adminRights(user).has_value(); - const auto labelKey = isAdmin - ? lng_context_edit_permissions - : lng_context_promote_admin; result->addAction( - lang(labelKey), + (isAdmin + ? tr::lng_context_edit_permissions + : tr::lng_context_promote_admin)(tr::now), crl::guard(this, [=] { showAdmin(user); })); } if (_additional.canRestrictUser(user)) { @@ -1392,15 +1391,15 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( }(); if (canRestrictWithoutKick) { result->addAction( - lang(lng_context_restrict_user), + tr::lng_context_restrict_user(tr::now), crl::guard(this, [=] { showRestricted(user); })); } if (!_additional.isKicked(user)) { const auto isGroup = _peer->isChat() || _peer->isMegagroup(); result->addAction( - lang(isGroup - ? lng_context_remove_from_group - : lng_profile_kick), + (isGroup + ? tr::lng_context_remove_from_group + : tr::lng_profile_kick)(tr::now), crl::guard(this, [=] { kickMember(user); })); } } @@ -1560,7 +1559,7 @@ void ParticipantsBoxController::kickMember(not_null user) { _editBox = Ui::show( Box( text, - lang(lng_box_remove), + tr::lng_box_remove(tr::now), crl::guard(this, [=] { kickMemberSure(user); })), LayerOption::KeepOther); } @@ -1602,7 +1601,7 @@ void ParticipantsBoxController::removeAdmin(not_null user) { lng_profile_sure_remove_admin( lt_user, user->firstName), - lang(lng_box_remove), + tr::lng_box_remove(tr::now), crl::guard(this, [=] { removeAdminSure(user); })), LayerOption::KeepOther); } @@ -1645,7 +1644,7 @@ void ParticipantsBoxController::removeKicked( delegate()->peerListRemoveRow(row); if (_role != Role::Kicked && !delegate()->peerListFullRowsCount()) { - setDescriptionText(lang(lng_blocked_list_not_found)); + setDescriptionText(tr::lng_blocked_list_not_found(tr::now)); } delegate()->peerListRefreshRows(); removeKicked(user); @@ -1684,14 +1683,14 @@ bool ParticipantsBoxController::removeRow(not_null user) { if (auto row = delegate()->peerListFindRow(user->id)) { if (_role == Role::Admins) { // Perhaps we are removing an admin from search results. - row->setCustomStatus(lang(lng_channel_admin_status_not_admin)); + row->setCustomStatus(tr::lng_channel_admin_status_not_admin(tr::now)); delegate()->peerListConvertRowToSearchResult(row); } else { delegate()->peerListRemoveRow(row); } if (_role != Role::Kicked && !delegate()->peerListFullRowsCount()) { - setDescriptionText(lang(lng_blocked_list_not_found)); + setDescriptionText(tr::lng_blocked_list_not_found(tr::now)); } return true; } @@ -1710,17 +1709,17 @@ std::unique_ptr ParticipantsBoxController::createRow( if (_role == Role::Admins && _additional.adminRights(user).has_value() && _additional.canEditAdmin(user)) { - row->setActionLink(lang(lng_profile_kick)); + row->setActionLink(tr::lng_profile_kick(tr::now)); } else if (_role == Role::Kicked || _role == Role::Restricted) { if (_additional.canRestrictUser(user)) { - row->setActionLink(lang(lng_profile_delete_removed)); + row->setActionLink(tr::lng_profile_delete_removed(tr::now)); } } else if (_role == Role::Members) { if ((chat ? chat->canBanMembers() : channel->canBanMembers()) && !_additional.isCreator(user) && (!_additional.adminRights(user) || _additional.canEditAdmin(user))) { - row->setActionLink(lang(lng_profile_kick)); + row->setActionLink(tr::lng_profile_kick(tr::now)); } } return std::move(row); @@ -1759,10 +1758,10 @@ void ParticipantsBoxController::refreshCustomStatus( } else { if (_additional.isCreator(user)) { row->setCustomStatus( - lang(lng_channel_admin_status_creator)); + tr::lng_channel_admin_status_creator(tr::now)); } else { row->setCustomStatus( - lang(lng_channel_admin_status_not_admin)); + tr::lng_channel_admin_status_not_admin(tr::now)); } } } else if (_role == Role::Kicked || _role == Role::Restricted) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 50283d98d..d1b38e093 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -1296,16 +1296,16 @@ void Controller::deleteWithConfirmation() { const auto channel = _peer->asChannel(); Assert(channel != nullptr); - const auto text = lang(_isGroup - ? lng_sure_delete_group - : lng_sure_delete_channel); + const auto text = (_isGroup + ? tr::lng_sure_delete_group + : tr::lng_sure_delete_channel)(tr::now); const auto deleteCallback = crl::guard(this, [=] { deleteChannel(); }); Ui::show( Box( text, - lang(lng_box_delete), + tr::lng_box_delete(tr::now), st::attentionBoxButton, deleteCallback), LayerOption::KeepOther); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 19d7c71ef..754da311f 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -79,51 +79,51 @@ void ApplyDependencies( }; } -std::vector> RestrictionLabels() { +std::vector> RestrictionLabels() { const auto langKeys = { - lng_rights_chat_send_text, - lng_rights_chat_send_media, - lng_rights_chat_send_stickers, - lng_rights_chat_send_links, - lng_rights_chat_send_polls, - lng_rights_chat_add_members, - lng_rights_group_pin, - lng_rights_group_info, + tr::lng_rights_chat_send_text, + tr::lng_rights_chat_send_media, + tr::lng_rights_chat_send_stickers, + tr::lng_rights_chat_send_links, + tr::lng_rights_chat_send_polls, + tr::lng_rights_chat_add_members, + tr::lng_rights_group_pin, + tr::lng_rights_group_info, }; - std::vector> vector; + std::vector> vector; const auto restrictions = Data::ListOfRestrictions(); auto i = 0; - for (const auto key : langKeys) { - vector.emplace_back(restrictions[i++], key); + for (const auto &key : langKeys) { + vector.emplace_back(restrictions[i++], key(tr::now)); } return vector; } -std::vector> AdminRightLabels( +std::vector> AdminRightLabels( bool isGroup, bool anyoneCanAddMembers) { using Flag = ChatAdminRight; if (isGroup) { return { - { Flag::f_change_info, lng_rights_group_info }, - { Flag::f_delete_messages, lng_rights_group_delete }, - { Flag::f_ban_users, lng_rights_group_ban }, + { Flag::f_change_info, tr::lng_rights_group_info(tr::now) }, + { Flag::f_delete_messages, tr::lng_rights_group_delete(tr::now) }, + { Flag::f_ban_users, tr::lng_rights_group_ban(tr::now) }, { Flag::f_invite_users, anyoneCanAddMembers - ? lng_rights_group_invite_link - : lng_rights_group_invite }, - { Flag::f_pin_messages, lng_rights_group_pin }, - { Flag::f_add_admins, lng_rights_add_admins }, + ? tr::lng_rights_group_invite_link(tr::now) + : tr::lng_rights_group_invite(tr::now) }, + { Flag::f_pin_messages, tr::lng_rights_group_pin(tr::now) }, + { Flag::f_add_admins, tr::lng_rights_add_admins(tr::now) }, }; } else { return { - { Flag::f_change_info, lng_rights_channel_info }, - { Flag::f_post_messages, lng_rights_channel_post }, - { Flag::f_edit_messages, lng_rights_channel_edit }, - { Flag::f_delete_messages, lng_rights_channel_delete }, - { Flag::f_invite_users, lng_rights_group_invite }, - { Flag::f_add_admins, lng_rights_add_admins } + { Flag::f_change_info, tr::lng_rights_channel_info(tr::now) }, + { Flag::f_post_messages, tr::lng_rights_channel_post(tr::now) }, + { Flag::f_edit_messages, tr::lng_rights_channel_edit(tr::now) }, + { Flag::f_delete_messages, tr::lng_rights_channel_delete(tr::now) }, + { Flag::f_invite_users, tr::lng_rights_group_invite(tr::now) }, + { Flag::f_add_admins, tr::lng_rights_add_admins(tr::now) } }; } } @@ -323,12 +323,12 @@ void EditPeerPermissionsBox::prepare() { auto result = std::map(); result.emplace( disabledByAdminRights, - lang(lng_rights_permission_cant_edit)); + tr::lng_rights_permission_cant_edit(tr::now)); if (const auto channel = _peer->asChannel()) { if (channel->isPublic()) { result.emplace( Flag::f_change_info | Flag::f_pin_messages, - lang(lng_rights_permission_unavailable)); + tr::lng_rights_permission_unavailable(tr::now)); } } return result; @@ -473,7 +473,7 @@ EditFlagsControl CreateEditFlags( checkboxes->emplace(flags, control); }; for (const auto &[flags, label] : flagLabelPairs) { - addCheckbox(flags, lang(label)); + addCheckbox(flags, label); } applyDependencies(nullptr); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index 11ea635fb..fed537541 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -516,13 +516,13 @@ void Controller::showUsernameResult( } void Controller::createInviteLink() { - exportInviteLink(lang(_isGroup - ? lng_group_invite_about - : lng_group_invite_about_channel)); + exportInviteLink((_isGroup + ? tr::lng_group_invite_about + : tr::lng_group_invite_about_channel)(tr::now)); } void Controller::revokeInviteLink() { - exportInviteLink(lang(lng_group_invite_about_new)); + exportInviteLink(tr::lng_group_invite_about_new(tr::now)); } void Controller::exportInviteLink(const QString &confirmation) { @@ -595,7 +595,7 @@ object_ptr Controller::createInviteLinkEdit() { _controls.inviteLink->setBreakEverywhere(true); _controls.inviteLink->setClickHandlerFilter([=](auto&&...) { QApplication::clipboard()->setText(inviteLinkText()); - Ui::Toast::Show(lang(lng_group_invite_copied)); + Ui::Toast::Show(tr::lng_group_invite_copied(tr::now)); return false; }); @@ -604,7 +604,7 @@ object_ptr Controller::createInviteLinkEdit() { st::editPeerInviteLinkSkip)); container->add(object_ptr( container, - lang(lng_group_invite_create_new), + tr::lng_group_invite_create_new(tr::now), st::editPeerInviteLinkButton) )->addClickHandler([=] { revokeInviteLink(); }); @@ -663,7 +663,7 @@ object_ptr Controller::createInviteLinkCreate() { container->add(object_ptr( _wrap, - lang(lng_group_invite_create), + tr::lng_group_invite_create(tr::now), st::editPeerInviteLinkButton) )->addClickHandler([this] { createInviteLink(); diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index fb20282ef..e94be583e 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -54,21 +54,21 @@ void ReportBox::prepare() { const auto createButton = [&]( object_ptr> &button, Reason reason, - LangKey key) { + const QString &text) { button.create( this, _reasonGroup, reason, - lang(key), + text, st::defaultBoxCheckbox); }; - createButton(_reasonSpam, Reason::Spam, lng_report_reason_spam); - createButton(_reasonViolence, Reason::Violence, lng_report_reason_violence); + createButton(_reasonSpam, Reason::Spam, tr::lng_report_reason_spam(tr::now)); + createButton(_reasonViolence, Reason::Violence, tr::lng_report_reason_violence(tr::now)); if (_ids) { - createButton(_reasonChildAbuse, Reason::ChildAbuse, lng_report_reason_child_abuse); + createButton(_reasonChildAbuse, Reason::ChildAbuse, tr::lng_report_reason_child_abuse(tr::now)); } - createButton(_reasonPornography, Reason::Pornography, lng_report_reason_pornography); - createButton(_reasonOther, Reason::Other, lng_report_reason_other); + createButton(_reasonPornography, Reason::Pornography, tr::lng_report_reason_pornography(tr::now)); + createButton(_reasonOther, Reason::Other, tr::lng_report_reason_other(tr::now)); _reasonGroup->setChangedCallback([=](Reason value) { reasonChanged(value); }); @@ -173,7 +173,7 @@ void ReportBox::report() { void ReportBox::reportDone(const MTPBool &result) { _requestId = 0; - Ui::Toast::Show(lang(lng_report_thanks)); + Ui::Toast::Show(tr::lng_report_thanks(tr::now)); closeBox(); } diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index 633467ebf..f3135ded6 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -20,7 +20,7 @@ SelfDestructionBox::SelfDestructionBox( : _ttlValues{ 30, 90, 180, 365 } , _loading( this, - lang(lng_contacts_loading), + tr::lng_contacts_loading(tr::now), st::membersAbout) { std::move( preloaded @@ -53,7 +53,7 @@ void SelfDestructionBox::showContent() { auto y = st::boxOptionListPadding.top(); _description.create( this, - lang(lng_self_destruct_description), + tr::lng_self_destruct_description(tr::now), st::boxLabel); _description->moveToLeft(st::boxPadding.left(), y); y += _description->height() + st::boxMediumSkip; @@ -90,7 +90,7 @@ void SelfDestructionBox::prepare() { auto fake = object_ptr( this, - lang(lng_self_destruct_description), + tr::lng_self_destruct_description(tr::now), st::boxLabel); const auto boxHeight = st::boxOptionListPadding.top() + fake->height() + st::boxMediumSkip diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index fe9c6cce0..68d6f29a8 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1541,19 +1541,19 @@ void SendFilesBox::setupSendWayControls() { button->show(); }; if (_list.albumIsPossible) { - addRadio(_sendAlbum, SendFilesWay::Album, lang(lng_send_album)); + addRadio(_sendAlbum, SendFilesWay::Album, tr::lng_send_album(tr::now)); } if (!_list.albumIsPossible || _albumPhotosCount > 0) { addRadio(_sendPhotos, SendFilesWay::Photos, (_list.files.size() == 1) - ? lang(lng_send_photo) + ? tr::lng_send_photo(tr::now) : (_albumVideosCount > 0) - ? lang(lng_send_separate_photos_videos) + ? tr::lng_send_separate_photos_videos(tr::now) : (_list.albumIsPossible - ? lang(lng_send_separate_photos) + ? tr::lng_send_separate_photos(tr::now) : lng_send_photos(lt_count, _list.files.size()))); } addRadio(_sendFiles, SendFilesWay::Files, (_list.files.size() == 1) - ? lang(lng_send_file) + ? tr::lng_send_file(tr::now) : lng_send_files(lt_count, _list.files.size())); } diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index b2cb0b613..3776dcd24 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -131,7 +131,7 @@ void SessionsBox::paintEvent(QPaintEvent *e) { p.setPen(st::noContactsColor); p.drawText( QRect(0, 0, width(), st::noContactsHeight), - lang(lng_contacts_loading), + tr::lng_contacts_loading(tr::now), style::al_center); } } @@ -226,8 +226,8 @@ SessionsBox::Entry SessionsBox::ParseEntry(const MTPDauthorization &data) { result.info = qs(data.vdevice_model) + qstr(", ") + (platform.isEmpty() ? QString() : platform + ' ') + qs(data.vsystem_version); result.ip = qs(data.vip) + (country.isEmpty() ? QString() : QString::fromUtf8(" \xe2\x80\x93 ") + country); if (!result.hash) { - result.active = lang(lng_status_online); - result.activeWidth = st::sessionWhenFont->width(lang(lng_status_online)); + result.active = tr::lng_status_online(tr::now); + result.activeWidth = st::sessionWhenFont->width(tr::lng_status_online(tr::now)); } else { const auto now = QDateTime::currentDateTime(); const auto lastTime = ParseDateTime(result.activeTime); @@ -315,8 +315,8 @@ void SessionsBox::terminateOne(uint64 hash) { }); _terminateBox = Ui::show( Box( - lang(lng_settings_reset_one_sure), - lang(lng_settings_reset_button), + tr::lng_settings_reset_one_sure(tr::now), + tr::lng_settings_reset_button(tr::now), st::attentionBoxButton, callback), LayerOption::KeepOther); @@ -341,8 +341,8 @@ void SessionsBox::terminateAll() { }); _terminateBox = Ui::show( Box( - lang(lng_settings_reset_sure), - lang(lng_settings_reset_button), + tr::lng_settings_reset_sure(tr::now), + tr::lng_settings_reset_button(tr::now), st::attentionBoxButton, callback), LayerOption::KeepOther); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index e3bed8bef..dbb18f181 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -417,7 +417,7 @@ void ShareBox::addPeerToMultiSelect(PeerData *peer, bool skipAnimation) { auto addItemWay = skipAnimation ? AddItemWay::SkipAnimation : AddItemWay::Default; _select->addItem( peer->id, - peer->isSelf() ? lang(lng_saved_short) : peer->shortName(), + peer->isSelf() ? tr::lng_saved_short(tr::now) : peer->shortName(), st::activeButtonBg, PaintUserpicCallback(peer, true), addItemWay); @@ -590,7 +590,7 @@ void ShareBox::Inner::updateChat(not_null peer) { void ShareBox::Inner::updateChatName( not_null chat, not_null peer) { - const auto text = peer->isSelf() ? lang(lng_saved_messages) : peer->name; + const auto text = peer->isSelf() ? tr::lng_saved_messages(tr::now) : peer->name; chat->name.setText(st::shareNameStyle, text, Ui::NameTextOptions()); } @@ -791,7 +791,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) { p.setPen(st::noContactsColor); p.drawText( rect().marginsRemoved(st::boxPadding), - lang(lng_bot_no_chats), + tr::lng_bot_no_chats(tr::now), style::al_center); } } else { @@ -802,7 +802,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) { p.setPen(st::noContactsColor); p.drawText( rect().marginsRemoved(st::boxPadding), - lang(lng_bot_chats_not_found), + tr::lng_bot_chats_not_found(tr::now), style::al_center); } else { auto filteredSize = _filtered.size(); @@ -1081,7 +1081,7 @@ void ShareGameScoreByHash(const QString &hash) { auto hashEncrypted = QByteArray::fromBase64(hash.toLatin1(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); if (hashEncrypted.size() <= key128Size || (hashEncrypted.size() % 0x10) != 0) { - Ui::show(Box(lang(lng_confirm_phone_link_invalid))); + Ui::show(Box(tr::lng_confirm_phone_link_invalid(tr::now))); return; } @@ -1101,20 +1101,20 @@ void ShareGameScoreByHash(const QString &hash) { // Check next 64 bits of SHA1() of data. auto skipSha1Part = sizeof(channelAccessHash); if (memcmp(dataSha1 + skipSha1Part, hashEncrypted.constData() + skipSha1Part, key128Size - skipSha1Part) != 0) { - Ui::show(Box(lang(lng_share_wrong_user))); + Ui::show(Box(tr::lng_share_wrong_user(tr::now))); return; } auto hashDataInts = reinterpret_cast(hashData.data()); if (!AuthSession::Exists() || hashDataInts[0] != Auth().userId()) { - Ui::show(Box(lang(lng_share_wrong_user))); + Ui::show(Box(tr::lng_share_wrong_user(tr::now))); return; } // Check first 32 bits of channel access hash. auto channelAccessHashInts = reinterpret_cast(&channelAccessHash); if (channelAccessHashInts[0] != hashDataInts[3]) { - Ui::show(Box(lang(lng_share_wrong_user))); + Ui::show(Box(tr::lng_share_wrong_user(tr::now))); return; } @@ -1122,7 +1122,7 @@ void ShareGameScoreByHash(const QString &hash) { auto msgId = hashDataInts[2]; if (!channelId && channelAccessHash) { // If there is no channel id, there should be no channel access_hash. - Ui::show(Box(lang(lng_share_wrong_user))); + Ui::show(Box(tr::lng_share_wrong_user(tr::now))); return; } @@ -1136,7 +1136,7 @@ void ShareGameScoreByHash(const QString &hash) { if (const auto item = Auth().data().message(channel, msgId)) { FastShareMessage(item); } else { - Ui::show(Box(lang(lng_edit_deleted))); + Ui::show(Box(tr::lng_edit_deleted(tr::now))); } }); }; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 264716265..1ffcf7603 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -145,7 +145,7 @@ void StickerSetBox::addStickers() { void StickerSetBox::shareStickers() { auto url = Core::App().createInternalLinkFull(qsl("addstickers/") + _inner->shortName()); QApplication::clipboard()->setText(url); - Ui::show(Box(lang(lng_stickers_copied))); + Ui::show(Box(tr::lng_stickers_copied(tr::now))); } void StickerSetBox::updateTitleAndButtons() { @@ -260,7 +260,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) { }); if (_pack.isEmpty()) { - Ui::show(Box(lang(lng_stickers_not_found))); + Ui::show(Box(tr::lng_stickers_not_found(tr::now))); return; } else { int32 rows = _pack.size() / kStickersPanelPerRow + ((_pack.size() % kStickersPanelPerRow) ? 1 : 0); @@ -285,7 +285,7 @@ bool StickerSetBox::Inner::failedSet(const RPCError &error) { _loaded = true; - Ui::show(Box(lang(lng_stickers_not_found))); + Ui::show(Box(tr::lng_stickers_not_found(tr::now))); return true; } @@ -359,7 +359,7 @@ void StickerSetBox::Inner::installDone(const MTPmessages_StickerSetInstallResult bool StickerSetBox::Inner::installFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; - Ui::show(Box(lang(lng_stickers_not_found))); + Ui::show(Box(tr::lng_stickers_not_found(tr::now))); return true; } @@ -538,7 +538,7 @@ QString StickerSetBox::Inner::shortName() const { void StickerSetBox::Inner::install() { if (isMasksSet()) { Ui::show( - Box(lang(lng_stickers_masks_pack)), + Box(tr::lng_stickers_masks_pack(tr::now)), LayerOption::KeepOther); return; } diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index fd1e15938..9c67d5281 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -341,14 +341,14 @@ void StickersBox::refreshTabs() { _tabIndices.clear(); auto sections = QStringList(); - sections.push_back(lang(lng_stickers_installed_tab).toUpper()); + sections.push_back(tr::lng_stickers_installed_tab(tr::now).toUpper()); _tabIndices.push_back(Section::Installed); if (!Auth().data().featuredStickerSetsOrder().isEmpty()) { - sections.push_back(lang(lng_stickers_featured_tab).toUpper()); + sections.push_back(tr::lng_stickers_featured_tab(tr::now).toUpper()); _tabIndices.push_back(Section::Featured); } if (!Auth().data().archivedStickerSetsOrder().isEmpty()) { - sections.push_back(lang(lng_stickers_archived_tab).toUpper()); + sections.push_back(tr::lng_stickers_archived_tab(tr::now).toUpper()); _tabIndices.push_back(Section::Archived); } _tabs->setSections(sections); @@ -407,7 +407,7 @@ void StickersBox::updateTabsGeometry() { auto featuredLeft = width() / 3; auto featuredRight = 2 * width() / 3; - auto featuredTextWidth = st::stickersTabs.labelFont->width(lang(lng_stickers_featured_tab).toUpper()); + auto featuredTextWidth = st::stickersTabs.labelFont->width(tr::lng_stickers_featured_tab(tr::now).toUpper()); auto featuredTextRight = featuredLeft + (featuredRight - featuredLeft - featuredTextWidth) / 2 + featuredTextWidth; auto unreadBadgeLeft = featuredTextRight - st::stickersFeaturedBadgeSkip; auto unreadBadgeTop = st::stickersFeaturedBadgeTop; @@ -661,9 +661,9 @@ StickersBox::Inner::Inner(QWidget *parent, StickersBox::Section section) : TWidg return shiftingAnimationCallback(now); }) , _itemsTop(st::membersMarginTop) -, _addText(lang(lng_stickers_featured_add).toUpper()) +, _addText(tr::lng_stickers_featured_add(tr::now).toUpper()) , _addWidth(st::stickersTrendingAdd.font->width(_addText)) -, _undoText(lang(lng_stickers_return).toUpper()) +, _undoText(tr::lng_stickers_return(tr::now).toUpper()) , _undoWidth(st::stickersUndoRemove.font->width(_undoText)) { setup(); } @@ -679,7 +679,7 @@ StickersBox::Inner::Inner(QWidget *parent, not_null megagroup) : T , _megagroupSetInput(_megagroupSet->mgInfo->stickerSet) , _megagroupSetField(this, st::groupStickersField, rpl::single(qsl("stickerset")), QString(), true) , _megagroupDivider(this) -, _megagroupSubTitle(this, lang(lng_stickers_group_from_your), st::boxTitle) { +, _megagroupSubTitle(this, tr::lng_stickers_group_from_your(tr::now), st::boxTitle) { _megagroupSetField->setLinkPlaceholder(Core::App().createInternalLink(qsl("addstickers/"))); _megagroupSetField->setPlaceholderHidden(false); _megagroupSetAddressChangedTimer.setCallback([this] { handleMegagroupSetAddressChange(); }); @@ -733,7 +733,7 @@ void StickersBox::Inner::paintEvent(QPaintEvent *e) { if (_rows.empty()) { p.setFont(st::noContactsFont); p.setPen(st::noContactsColor); - p.drawText(QRect(0, y, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center); + p.drawText(QRect(0, y, width(), st::noContactsHeight), tr::lng_contacts_loading(tr::now), style::al_center); } else { p.translate(0, _itemsTop); @@ -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) : lang(lng_contacts_loading); + auto statusText = (set->count > 0) ? lng_stickers_count(lt_count, set->count) : tr::lng_contacts_loading(tr::now); p.setFont(st::contactsStatusFont); p.setPen(st::contactsStatusFg); @@ -1484,9 +1484,9 @@ void StickersBox::Inner::rebuild() { auto &sets = Auth().data().stickerSets(); if (_megagroupSet) { auto usingFeatured = Auth().data().stickerSetsOrder().empty(); - _megagroupSubTitle->setText(lang(usingFeatured - ? lng_stickers_group_from_featured - : lng_stickers_group_from_your)); + _megagroupSubTitle->setText(usingFeatured + ? tr::lng_stickers_group_from_featured(tr::now) + : tr::lng_stickers_group_from_your(tr::now)); updateControlsGeometry(); } else if (_section == Section::Installed) { auto cloudIt = sets.constFind(Stickers::CloudRecentSetId); diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index 4901ee250..298b03cac 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -40,7 +40,7 @@ UsernameBox::UsernameBox(QWidget*) void UsernameBox::prepare() { _goodText = Auth().user()->username.isEmpty() ? QString() - : lang(lng_username_available); + : tr::lng_username_available(tr::now); setTitle(tr::lng_username_title()); @@ -51,7 +51,7 @@ void UsernameBox::prepare() { connect(_username, &Ui::MaskedInputField::submitted, [=] { save(); }); _link->addClickHandler([=] { linkClick(); }); - _about.setText(st::usernameTextStyle, lang(lng_username_about)); + _about.setText(st::usernameTextStyle, tr::lng_username_about(tr::now)); setDimensions(st::boxWidth, st::usernamePadding.top() + _username->height() + st::usernameSkip + _about.countHeight(st::boxWidth - st::usernamePadding.left()) + 3 * st::usernameTextStyle.lineHeight + st::usernamePadding.bottom()); _checkTimer->setSingleShot(true); @@ -78,7 +78,7 @@ void UsernameBox::paintEvent(QPaintEvent *e) { p.drawTextLeft(st::usernamePadding.left(), _username->y() + _username->height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), _goodText); } else { p.setPen(st::usernameDefaultFg); - p.drawTextLeft(st::usernamePadding.left(), _username->y() + _username->height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), lang(lng_username_choose)); + p.drawTextLeft(st::usernamePadding.left(), _username->y() + _username->height() + ((st::usernameSkip - st::boxTextFont->height) / 2), width(), tr::lng_username_choose(tr::now)); } p.setPen(st::boxTextFg); int32 availw = st::boxWidth - st::usernamePadding.left(), h = _about.countHeight(availw); @@ -86,11 +86,11 @@ void UsernameBox::paintEvent(QPaintEvent *e) { int32 linky = _username->y() + _username->height() + st::usernameSkip + h + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2); if (_link->isHidden()) { - p.drawTextLeft(st::usernamePadding.left(), linky, width(), lang(lng_username_link_willbe)); + p.drawTextLeft(st::usernamePadding.left(), linky, width(), tr::lng_username_link_willbe(tr::now)); p.setPen(st::usernameDefaultFg); p.drawTextLeft(st::usernamePadding.left(), linky + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2), width(), Core::App().createInternalLinkFull(qsl("username"))); } else { - p.drawTextLeft(st::usernamePadding.left(), linky, width(), lang(lng_username_link)); + p.drawTextLeft(st::usernamePadding.left(), linky, width(), tr::lng_username_link(tr::now)); } } @@ -141,8 +141,8 @@ void UsernameBox::changed() { for (int32 i = 0; i < len; ++i) { QChar ch = name.at(i); if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z') && (ch < '0' || ch > '9') && ch != '_' && (ch != '@' || i > 0)) { - if (_errorText != lang(lng_username_bad_symbols)) { - _errorText = lang(lng_username_bad_symbols); + if (_errorText != tr::lng_username_bad_symbols(tr::now)) { + _errorText = tr::lng_username_bad_symbols(tr::now); update(); } _checkTimer->stop(); @@ -150,8 +150,8 @@ void UsernameBox::changed() { } } if (name.size() < kMinUsernameLength) { - if (_errorText != lang(lng_username_too_short)) { - _errorText = lang(lng_username_too_short); + if (_errorText != tr::lng_username_too_short(tr::now)) { + _errorText = tr::lng_username_too_short(tr::now); update(); } _checkTimer->stop(); @@ -167,7 +167,7 @@ void UsernameBox::changed() { void UsernameBox::linkClick() { QApplication::clipboard()->setText(Core::App().createInternalLinkFull(getName())); - Ui::Toast::Show(lang(lng_username_copied)); + Ui::Toast::Show(tr::lng_username_copied(tr::now)); } void UsernameBox::onUpdateDone(const MTPUser &user) { @@ -192,13 +192,13 @@ bool UsernameBox::onUpdateFail(const RPCError &error) { } else if (err == qstr("USERNAME_INVALID")) { _username->setFocus(); _username->showError(); - _errorText = lang(lng_username_invalid); + _errorText = tr::lng_username_invalid(tr::now); update(); return true; } else if (err == qstr("USERNAME_OCCUPIED") || err == qstr("USERNAMES_UNAVAILABLE")) { _username->setFocus(); _username->showError(); - _errorText = lang(lng_username_occupied); + _errorText = tr::lng_username_occupied(tr::now); update(); return true; } @@ -211,9 +211,9 @@ void UsernameBox::onCheckDone(const MTPBool &result) { const auto newError = (mtpIsTrue(result) || _checkUsername == Auth().user()->username) ? QString() - : lang(lng_username_occupied); + : tr::lng_username_occupied(tr::now); const auto newGood = newError.isEmpty() - ? lang(lng_username_available) + ? tr::lng_username_available(tr::now) : QString(); if (_errorText != newError || _goodText != newGood) { _errorText = newError; @@ -228,11 +228,11 @@ bool UsernameBox::onCheckFail(const RPCError &error) { _checkRequestId = 0; QString err(error.type()); if (err == qstr("USERNAME_INVALID")) { - _errorText = lang(lng_username_invalid); + _errorText = tr::lng_username_invalid(tr::now); update(); return true; } else if (err == qstr("USERNAME_OCCUPIED") && _checkUsername != Auth().user()->username) { - _errorText = lang(lng_username_occupied); + _errorText = tr::lng_username_occupied(tr::now); update(); return true; } diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index f26edea3e..7447c674b 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -232,7 +232,7 @@ void BoxController::prepare() { }); delegate()->peerListSetTitle(tr::lng_call_box_title()); - setDescriptionText(lang(lng_contacts_loading)); + setDescriptionText(tr::lng_contacts_loading(tr::now)); delegate()->peerListRefreshRows(); loadMoreRows(); @@ -284,7 +284,7 @@ void BoxController::loadMoreRows() { } void BoxController::refreshAbout() { - setDescriptionText(delegate()->peerListFullRowsCount() ? QString() : lang(lng_call_box_about)); + setDescriptionText(delegate()->peerListFullRowsCount() ? QString() : tr::lng_call_box_about(tr::now)); } void BoxController::rowClicked(not_null row) { diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 07ba64da1..57b932bed 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -888,7 +888,7 @@ void Call::handleControllerError(int error) { "{user}", App::peerName(_user)))); } else if (error == tgvoip::ERROR_AUDIO_IO) { - Ui::show(Box(lang(lng_call_error_audio_io))); + Ui::show(Box(tr::lng_call_error_audio_io(tr::now))); } finish(FinishType::Failed); } diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index 0b6af08a6..995ebc90b 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -286,7 +286,7 @@ void Instance::requestMicrophonePermissionOrFail(Fn onSuccess) { if (alreadyInCall()) { _currentCall->hangup(); } - Ui::show(Box(lang(lng_no_mic_permission), lang(lng_menu_settings), crl::guard(this, [] { + Ui::show(Box(tr::lng_no_mic_permission(tr::now), tr::lng_menu_settings(tr::now), crl::guard(this, [] { Platform::OpenSystemSettingsForPermission(Platform::PermissionType::Microphone); Ui::hideLayer(); }))); diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index d2c140d57..a061e91f6 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -892,7 +892,7 @@ void Panel::updateStatusText(State state) { switch (state) { case State::Starting: case State::WaitingInit: - case State::WaitingInitAck: return lang(lng_call_status_connecting); + case State::WaitingInitAck: return tr::lng_call_status_connecting(tr::now); case State::Established: { if (_call) { auto durationMs = _call->getDurationMs(); @@ -900,19 +900,19 @@ void Panel::updateStatusText(State state) { startDurationUpdateTimer(durationMs); return formatDurationText(durationSeconds); } - return lang(lng_call_status_ended); + return tr::lng_call_status_ended(tr::now); } break; case State::FailedHangingUp: - case State::Failed: return lang(lng_call_status_failed); - case State::HangingUp: return lang(lng_call_status_hanging); + case State::Failed: return tr::lng_call_status_failed(tr::now); + case State::HangingUp: return tr::lng_call_status_hanging(tr::now); case State::Ended: - case State::EndedByOtherDevice: return lang(lng_call_status_ended); - case State::ExchangingKeys: return lang(lng_call_status_exchanging); - case State::Waiting: return lang(lng_call_status_waiting); - case State::Requesting: return lang(lng_call_status_requesting); - case State::WaitingIncoming: return lang(lng_call_status_incoming); - case State::Ringing: return lang(lng_call_status_ringing); - case State::Busy: return lang(lng_call_status_busy); + case State::EndedByOtherDevice: return tr::lng_call_status_ended(tr::now); + case State::ExchangingKeys: return tr::lng_call_status_exchanging(tr::now); + case State::Waiting: return tr::lng_call_status_waiting(tr::now); + case State::Requesting: return tr::lng_call_status_requesting(tr::now); + case State::WaitingIncoming: return tr::lng_call_status_incoming(tr::now); + case State::Ringing: return tr::lng_call_status_ringing(tr::now); + case State::Busy: return tr::lng_call_status_busy(tr::now); } Unexpected("State in stateChanged()"); }; diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index 0da971ee8..83dffb8c5 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -80,7 +80,7 @@ TopBar::TopBar( , _signalBars(this, _call.get(), st::callBarSignalBars) , _fullInfoLabel(this, st::callBarInfoLabel) , _shortInfoLabel(this, st::callBarInfoLabel) -, _hangupLabel(this, st::callBarLabel, lang(lng_call_bar_hangup).toUpper()) +, _hangupLabel(this, st::callBarLabel, tr::lng_call_bar_hangup(tr::now).toUpper()) , _mute(this, st::callBarMuteToggle) , _info(this) , _hangup(this, st::callBarHangup) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index e7c5a1d5a..879833305 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -18,6 +18,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_chat_helpers.h" namespace ChatHelpers { +namespace { + +tr::phrase<> CategoryTitle(int index) { + switch (index) { + case 1: return tr::lng_emoji_category1; + case 2: return tr::lng_emoji_category2; + case 3: return tr::lng_emoji_category3; + case 4: return tr::lng_emoji_category4; + case 5: return tr::lng_emoji_category5; + case 6: return tr::lng_emoji_category6; + case 7: return tr::lng_emoji_category7; + } + Unexpected("Index in CategoryTitle."); +} + +} // namespace class EmojiColorPicker : public Ui::RpWidget { public: @@ -529,7 +545,7 @@ void EmojiListWidget::paintEvent(QPaintEvent *e) { if (info.section > 0 && r.top() < info.rowsTop) { p.setFont(st::emojiPanHeaderFont); p.setPen(st::emojiPanHeaderFg); - p.drawTextLeft(st::emojiPanHeaderLeft - st::buttonRadius, info.top + st::emojiPanHeaderTop, width(), lang(LangKey(lng_emoji_category1 + info.section - 1))); + p.drawTextLeft(st::emojiPanHeaderLeft - st::buttonRadius, info.top + st::emojiPanHeaderTop, width(), CategoryTitle(info.section)(tr::now)); } if (r.top() + r.height() > info.rowsTop) { ensureLoaded(info.section); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 0adfbc9aa..592bd2dcf 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -169,9 +169,9 @@ QString StateDescription(const SetState &state) { return state.match([](const Available &data) { return lng_emoji_set_download(lt_size, formatSizeText(data.size)); }, [](const Ready &data) -> QString { - return lang(lng_emoji_set_ready); + return tr::lng_emoji_set_ready(tr::now); }, [](const Active &data) -> QString { - return lang(lng_emoji_set_active); + return tr::lng_emoji_set_active(tr::now); }, [](const Loading &data) { const auto percent = (data.size > 0) ? snap((data.already * 100) / float64(data.size), 0., 100.) @@ -182,7 +182,7 @@ QString StateDescription(const SetState &state) { lt_progress, formatDownloadText(data.already, data.size)); }, [](const Failed &data) { - return lang(lng_attach_failed); + return tr::lng_attach_failed(tr::now); }); } diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 042057172..207614c37 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -274,7 +274,9 @@ void GifsListWidget::paintInlineItems(Painter &p, QRect clip) { if (_rows.isEmpty()) { p.setFont(st::normalFont); p.setPen(st::noContactsColor); - auto text = lang(_inlineQuery.isEmpty() ? lng_gifs_no_saved : lng_inline_bot_no_results); + auto text = _inlineQuery.isEmpty() + ? tr::lng_gifs_no_saved(tr::now) + : tr::lng_inline_bot_no_results(tr::now); p.drawText(QRect(0, 0, width(), (height() / 3) * 2 + st::normalFont->height), text, style::al_center); return; } diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index d6c7a58f6..7a6726b08 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -67,7 +67,7 @@ void ApplyArchivedResult(const MTPDmessages_stickerSetInstallResultArchive &d) { Local::writeArchivedStickers(); Ui::Toast::Config toast; - toast.text = lang(lng_stickers_packs_archived); + toast.text = tr::lng_stickers_packs_archived(tr::now); toast.maxWidth = st::stickersToastMaxWidth; toast.padding = st::stickersToastPadding; Ui::Toast::Show(toast); @@ -175,7 +175,7 @@ void UndoInstallLocally(uint64 setId) { Auth().data().notifyStickersUpdated(); Ui::show( - Box(lang(lng_stickers_not_found)), + Box(tr::lng_stickers_not_found(tr::now)), LayerOption::KeepOther); } @@ -1064,7 +1064,7 @@ void NewSetReceived(const MTPmessages_StickerSet &data) { QString GetSetTitle(const MTPDstickerSet &s) { auto title = qs(s.vtitle); if ((s.vflags.v & MTPDstickerSet::Flag::f_official) && !title.compare(qstr("Great Minds"), Qt::CaseInsensitive)) { - return lang(lng_stickers_default_set); + return tr::lng_stickers_default_set(tr::now); } return title; } diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 7d5228b60..88847338e 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -703,9 +703,9 @@ StickersListWidget::StickersListWidget( : Inner(parent, controller) , _section(Section::Stickers) , _megagroupSetAbout(st::columnMinimalWidthThird - st::emojiScroll.width - st::emojiPanHeaderLeft) -, _addText(lang(lng_stickers_featured_add).toUpper()) +, _addText(tr::lng_stickers_featured_add(tr::now).toUpper()) , _addWidth(st::stickersTrendingAdd.font->width(_addText)) -, _settings(this, lang(lng_stickers_you_have)) +, _settings(this, tr::lng_stickers_you_have(tr::now)) , _previewTimer([=] { showPreview(); }) , _searchRequestTimer([=] { sendSearchRequest(); }) { setMouseTracking(true); @@ -1241,7 +1241,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) { } } - auto statusText = (size > 0) ? lng_stickers_count(lt_count, size) : lang(lng_contacts_loading); + auto statusText = (size > 0) ? lng_stickers_count(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); @@ -1314,7 +1314,7 @@ void StickersListWidget::paintEmptySearchResults(Painter &p) { const auto iconTop = (height() / 3) - (st::stickersEmpty.height() / 2); st::stickersEmpty.paint(p, iconLeft, iconTop, width()); - const auto text = lang(lng_stickers_nothing_found); + const auto text = tr::lng_stickers_nothing_found(tr::now); const auto textWidth = st::normalFont->width(text); p.setFont(st::normalFont); p.setPen(st::windowSubTextFg); @@ -1937,7 +1937,7 @@ void StickersListWidget::refreshRecentStickers(bool performResize) { Stickers::RecentSetId, (MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special), - lang(lng_recent_stickers), + tr::lng_recent_stickers(tr::now), shortName, thumbnail, externalLayout, @@ -1998,7 +1998,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) { _mySets.emplace_back( Stickers::MegagroupSetId, MTPDstickerSet_ClientFlag::f_special | 0, - lang(lng_group_stickers), + tr::lng_group_stickers(tr::now), shortName, thumbnail, externalLayout, @@ -2036,7 +2036,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) { _mySets.emplace_back( Stickers::MegagroupSetId, MTPDstickerSet_ClientFlag::f_special | 0, - lang(lng_group_stickers), + tr::lng_group_stickers(tr::now), shortName, thumbnail, externalLayout, @@ -2317,8 +2317,8 @@ void StickersListWidget::showMegagroupSet(ChannelData *megagroup) { if (_megagroupSetAbout.isEmpty()) { _megagroupSetAbout.setText( st::stickerGroupCategoryAbout, - lang(lng_group_stickers_description)); - _megagroupSetButtonText = lang(lng_group_stickers_add).toUpper(); + tr::lng_group_stickers_description(tr::now)); + _megagroupSetButtonText = tr::lng_group_stickers_add(tr::now).toUpper(); refreshMegagroupSetGeometry(); } _megagroupSetButtonRipple.reset(); @@ -2415,7 +2415,7 @@ void StickersListWidget::removeMegagroupSet(bool locally) { return; } _removingSetId = Stickers::MegagroupSetId; - Ui::show(Box(lang(lng_stickers_remove_group_set), crl::guard(this, [this, group = _megagroupSet] { + Ui::show(Box(tr::lng_stickers_remove_group_set(tr::now), crl::guard(this, [this, group = _megagroupSet] { Expects(group->mgInfo != nullptr); if (group->mgInfo->stickerSet.type() != mtpc_inputStickerSetEmpty) { @@ -2436,7 +2436,7 @@ void StickersListWidget::removeSet(uint64 setId) { if (it != sets.cend()) { _removingSetId = it->id; auto text = lng_stickers_remove_pack(lt_sticker_pack, it->title); - Ui::show(Box(text, lang(lng_stickers_remove_pack_confirm), crl::guard(this, [=] { + Ui::show(Box(text, tr::lng_stickers_remove_pack_confirm(tr::now), crl::guard(this, [=] { Ui::hideLayer(); auto &sets = Auth().data().stickerSetsRef(); auto it = sets.find(_removingSetId); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 7fb537f03..0ed13b29a 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -663,20 +663,20 @@ void TabbedSelector::setCurrentPeer(PeerData *peer) { void TabbedSelector::checkRestrictedPeer() { if (_currentPeer) { - const auto errorKey = (_currentTabType == SelectorTab::Stickers) - ? Data::RestrictionErrorKey( + const auto error = (_currentTabType == SelectorTab::Stickers) + ? Data::RestrictionError( _currentPeer, ChatRestriction::f_send_stickers) : (_currentTabType == SelectorTab::Gifs) - ? Data::RestrictionErrorKey( + ? Data::RestrictionError( _currentPeer, ChatRestriction::f_send_gifs) : std::nullopt; - if (errorKey) { + if (error) { if (!_restrictedLabel) { _restrictedLabel.create( this, - lang(*errorKey), + *error, st::stickersRestrictedLabel); _restrictedLabel->show(); updateRestrictedLabelGeometry(); @@ -748,9 +748,9 @@ void TabbedSelector::createTabsSlider() { _tabsSlider.create(this, st::emojiTabs); auto sections = QStringList(); - sections.push_back(lang(lng_switch_emoji).toUpper()); - sections.push_back(lang(lng_switch_stickers).toUpper()); - sections.push_back(lang(lng_switch_gifs).toUpper()); + sections.push_back(tr::lng_switch_emoji(tr::now).toUpper()); + sections.push_back(tr::lng_switch_stickers(tr::now).toUpper()); + sections.push_back(tr::lng_switch_gifs(tr::now).toUpper()); _tabsSlider->setSections(sections); _tabsSlider->setActiveSectionFast(static_cast(_currentTabType)); diff --git a/Telegram/SourceFiles/codegen/lang/generator.cpp b/Telegram/SourceFiles/codegen/lang/generator.cpp index 76bc97d8b..75a6e993f 100644 --- a/Telegram/SourceFiles/codegen/lang/generator.cpp +++ b/Telegram/SourceFiles/codegen/lang/generator.cpp @@ -121,8 +121,7 @@ inline constexpr auto kTagsCount = " << langpack_.tags.size() << ";\n\ \n"; header_->popNamespace().newline().stream() << "\ -enum LangKey : int;\n\ -QString lang(LangKey key);\n\n"; +enum LangKey : int;\n\n"; } void Generator::writeHeaderTagTypes() { @@ -170,7 +169,6 @@ void Generator::writeHeaderTaggedMethods() { args.push_back((isPluralTag ? "type" : ("lt_" + tag)) + ", " + tag + "__val"); } if (!entry.tags.empty() && (!isPlural || key == ComputePluralKey(entry.keyBase, 0))) { - auto initialString = isPlural ? ("lang(LangKey(" + key + " + plural.keyShift))") : ("lang(" + getFullKey(entry) + ")"); header_->stream() << "\ inline QString " << (isPlural ? entry.keyBase : key) << "(" << params.join(QString(", ")) << ") {\n\ return tr::" << (isPlural ? entry.keyBase : key) << "(tr::now, " << args.join(QString(", ")) << ");\n\ @@ -207,7 +205,7 @@ inline constexpr ushort TagValue() {\n\ header_->stream() << "template <> struct TagData : std::integral_constant {};\n"; } - header_->popNamespace(); + header_->newline().popNamespace(); } void Generator::writeHeaderReactiveInterface() { @@ -231,14 +229,13 @@ struct Identity {\n\ header_->popNamespace().newline(); header_->stream() << "\ -\n\ struct now_t {\n\ };\n\ \n\ inline constexpr now_t now{};\n\ \n\ template \n\ -struct Producer;\n\ +struct phrase;\n\ \n"; std::set producersDeclared; for (auto &entry : langpack_.entries) { @@ -274,19 +271,19 @@ struct Producer;\n\ } header_->stream() << "\ template <>\n\ -struct Producer<" << tags.join(", ") << "> {\n\ +struct phrase<" << tags.join(", ") << "> {\n\ template <\n\ typename P = details::Identity,\n\ typename T = decltype(std::declval

()(QString()))>\n\ rpl::producer operator()(" << producerArgs.join(", ") << ") const {\n\ - return ::Lang::details::template Producer<" << tags.join(", ") << ">::template Combine(" << values.join(", ") << ");\n\ + return ::Lang::details::Producer<" << tags.join(", ") << ">::template Combine(" << values.join(", ") << ");\n\ }\n\ \n\ template <\n\ typename P = details::Identity,\n\ typename T = decltype(std::declval

()(QString()))>\n\ T operator()(now_t, " << currentArgs.join(", ") << ") const {\n\ - return ::Lang::details::template Producer<" << tags.join(", ") << ">::template Current(" << values.join(", ") << ");\n\ + return ::Lang::details::Producer<" << tags.join(", ") << ">::template Current(" << values.join(", ") << ");\n\ }\n\ \n\ LangKey base;\n\ @@ -307,7 +304,7 @@ void Generator::writeHeaderProducersInstances() { } if (!isPlural || key == ComputePluralKey(entry.keyBase, 0)) { header_->stream() << "\ -inline constexpr Producer<" << tags.join(", ") << "> " << (isPlural ? entry.keyBase : key) << "{ LangKey(" << index << ") };\n"; +inline constexpr phrase<" << tags.join(", ") << "> " << (isPlural ? entry.keyBase : key) << "{ LangKey(" << index << ") };\n"; } ++index; } diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index b7223e3a7..eca9579f9 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -672,7 +672,7 @@ void Application::startLocalStorage() { void Application::forceLogOut(const TextWithEntities &explanation) { const auto box = Ui::show(Box( explanation, - lang(lng_passcode_logout))); + tr::lng_passcode_logout(tr::now))); box->setCloseByEscape(false); box->setCloseByOutsideClick(false); connect(box, &QObject::destroyed, [=] { diff --git a/Telegram/SourceFiles/core/changelogs.cpp b/Telegram/SourceFiles/core/changelogs.cpp index 9b5a2d9a8..9b3b81190 100644 --- a/Telegram/SourceFiles/core/changelogs.cpp +++ b/Telegram/SourceFiles/core/changelogs.cpp @@ -126,7 +126,7 @@ void Changelogs::addLocalLogs() { lt_version, QString::fromLatin1(AppVersionStr), lt_changes, - lang(lng_new_version_minor), + tr::lng_new_version_minor(tr::now), lt_link, qsl("https://desktop.telegram.org/changelog")); addLocalLog(text.trimmed()); diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index e5a60e941..651b9d386 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -100,7 +100,9 @@ UrlClickHandler::UrlClickHandler(const QString &url, bool fullDisplayed) } QString UrlClickHandler::copyToClipboardContextItemText() const { - return lang(isEmail() ? lng_context_copy_email : lng_context_copy_link); + return isEmail() + ? tr::lng_context_copy_email(tr::now) + : tr::lng_context_copy_link(tr::now); } QString UrlClickHandler::url() const { @@ -161,8 +163,8 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) { : url; Ui::show( Box( - lang(lng_open_this_link) + qsl("\n\n") + displayUrl, - lang(lng_open_link), + tr::lng_open_this_link(tr::now) + qsl("\n\n") + displayUrl, + tr::lng_open_link(tr::now), [=] { Ui::hideLayer(); open(); }), LayerOption::KeepOther); } else { @@ -192,7 +194,7 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const { }; Ui::show(Box( lng_allow_bot_pass(lt_bot_name, _bot->name), - lang(lng_allow_bot), + tr::lng_allow_bot(tr::now), callback)); } } @@ -202,7 +204,7 @@ auto HiddenUrlClickHandler::getTextEntity() const -> TextEntity { } QString MentionClickHandler::copyToClipboardContextItemText() const { - return lang(lng_context_copy_mention); + return tr::lng_context_copy_mention(tr::now); } void MentionClickHandler::onClick(ClickContext context) const { @@ -241,7 +243,7 @@ QString MentionNameClickHandler::tooltip() const { } QString HashtagClickHandler::copyToClipboardContextItemText() const { - return lang(lng_context_copy_hashtag); + return tr::lng_context_copy_hashtag(tr::now); } void HashtagClickHandler::onClick(ClickContext context) const { @@ -256,7 +258,7 @@ auto HashtagClickHandler::getTextEntity() const -> TextEntity { } QString CashtagClickHandler::copyToClipboardContextItemText() const { - return lang(lng_context_copy_hashtag); + return tr::lng_context_copy_hashtag(tr::now); } void CashtagClickHandler::onClick(ClickContext context) const { diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 3c644ede0..0fd99d267 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -56,7 +56,7 @@ bool JoinGroupByHash(const Match &match, const QVariant &context) { return; } Core::App().hideMediaView(); - Ui::show(Box(lang(lng_group_invite_bad_link))); + Ui::show(Box(tr::lng_group_invite_bad_link(tr::now))); }); return true; } @@ -246,7 +246,7 @@ bool ResolvePrivatePost(const Match &match, const QVariant &context) { msgId); }; const auto fail = [=] { - Ui::show(Box(lang(lng_error_post_link_invalid))); + Ui::show(Box(tr::lng_error_post_link_invalid(tr::now))); }; const auto auth = &Auth(); if (const auto channel = auth->data().channelLoaded(channelId)) { @@ -292,7 +292,7 @@ bool HandleUnknown(const Match &match, const QVariant &context) { }; *box = Ui::show(Box( text, - lang(lng_menu_update), + tr::lng_menu_update(tr::now), callback)); } else { Ui::show(Box(text)); diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 4877e4da3..df6c3829f 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -101,7 +101,7 @@ void LaunchWithWarning(const QString &name, HistoryItem *item) { lt_extension, rpl::single(Ui::Text::Bold(extension)), Ui::Text::WithEntities), - lang(lng_launch_exe_dont_ask), + tr::lng_launch_exe_dont_ask(tr::now), tr::lng_launch_exe_sure(), callback)); } @@ -262,7 +262,7 @@ QString documentSaveFilename(const DocumentData *data, bool forceSavingAs = fals name = already.isEmpty() ? (mp3 ? qsl(".mp3") : qsl(".ogg")) : already; filter = mp3 ? qsl("MP3 Audio (*.mp3);;") : qsl("OGG Opus Audio (*.ogg);;"); filter += FileDialog::AllFilesFilter(); - caption = lang(lng_save_audio); + caption = tr::lng_save_audio(tr::now); prefix = qsl("audio"); } else if (data->isVideoFile()) { name = already.isEmpty() ? data->filename() : already; @@ -274,7 +274,7 @@ QString documentSaveFilename(const DocumentData *data, bool forceSavingAs = fals } else { filter = mimeType.filterString() + qsl(";;") + FileDialog::AllFilesFilter(); } - caption = lang(lng_save_video); + caption = tr::lng_save_video(tr::now); prefix = qsl("video"); } else { name = already.isEmpty() ? data->filename() : already; @@ -286,7 +286,9 @@ QString documentSaveFilename(const DocumentData *data, bool forceSavingAs = fals } else { filter = mimeType.filterString() + qsl(";;") + FileDialog::AllFilesFilter(); } - caption = lang(data->isAudioFile() ? lng_save_audio_file : lng_save_file); + caption = data->isAudioFile() + ? tr::lng_save_audio_file(tr::now) + : tr::lng_save_file(tr::now); prefix = qsl("doc"); } @@ -1708,9 +1710,9 @@ base::binary_guard ReadImageAsync( // document->owner().message(contextId)); // }; // Ui::show(Box( -// lang(lng_player_cant_stream), -// lang(lng_player_download), -// lang(lng_cancel), +// tr::lng_player_cant_stream(tr::now), +// tr::lng_player_download(tr::now), +// tr::lng_cancel(tr::now), // save)); // } else if (IsValidMediaFile(filepath)) { // File::Launch(filepath); diff --git a/Telegram/SourceFiles/data/data_folder.cpp b/Telegram/SourceFiles/data/data_folder.cpp index c4453a57b..1b08b5a67 100644 --- a/Telegram/SourceFiles/data/data_folder.cpp +++ b/Telegram/SourceFiles/data/data_folder.cpp @@ -54,7 +54,7 @@ Folder::Folder(not_null owner, FolderId id) : Entry(owner, this) , _id(id) , _chatsList(PinnedDialogsInFolderMaxValue()) -, _name(lang(lng_archived_name)) { +, _name(tr::lng_archived_name(tr::now)) { indexNameParts(); Notify::PeerUpdateViewer( diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 3fe8dcfef..8204944cd 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -306,23 +306,23 @@ Image *MediaPhoto::replyPreview() const { QString MediaPhoto::notificationText() const { return WithCaptionNotificationText( - lang(lng_in_dlg_photo), + tr::lng_in_dlg_photo(tr::now), parent()->originalText().text); } QString MediaPhoto::chatListText() const { return WithCaptionDialogsText( - lang(lng_in_dlg_photo), + tr::lng_in_dlg_photo(tr::now), parent()->originalText().text); } QString MediaPhoto::pinnedTextSubstring() const { - return lang(lng_action_pinned_media_photo); + return tr::lng_action_pinned_media_photo(tr::now); } TextForMimeData MediaPhoto::clipboardText() const { return WithCaptionClipboardText( - lang(lng_in_dlg_photo), + tr::lng_in_dlg_photo(tr::now), parent()->clipboardText()); } @@ -335,10 +335,10 @@ bool MediaPhoto::allowsEditMedia() const { } QString MediaPhoto::errorTextForForward(not_null peer) const { - const auto errorKey = Data::RestrictionErrorKey( + return Data::RestrictionError( peer, - ChatRestriction::f_send_media); - return errorKey ? lang(*errorKey) : QString(); + ChatRestriction::f_send_media + ).value_or(QString()); } bool MediaPhoto::updateInlineResultMedia(const MTPMessageMedia &media) { @@ -564,20 +564,20 @@ QString MediaFile::chatListText() const { } const auto type = [&] { if (_document->isVideoMessage()) { - return lang(lng_in_dlg_video_message); + return tr::lng_in_dlg_video_message(tr::now); } else if (_document->isAnimation()) { return qsl("GIF"); } else if (_document->isVideoFile()) { - return lang(lng_in_dlg_video); + return tr::lng_in_dlg_video(tr::now); } else if (_document->isVoiceMessage()) { - return lang(lng_in_dlg_audio); + return tr::lng_in_dlg_audio(tr::now); } else if (const auto name = _document->composeNameString(); !name.isEmpty()) { return name; } else if (_document->isAudioFile()) { - return lang(lng_in_dlg_audio_file); + return tr::lng_in_dlg_audio_file(tr::now); } - return lang(lng_in_dlg_file); + return tr::lng_in_dlg_file(tr::now); }(); return WithCaptionDialogsText(type, parent()->originalText().text); } @@ -585,24 +585,24 @@ QString MediaFile::chatListText() const { QString MediaFile::notificationText() const { if (const auto sticker = _document->sticker()) { return _emoji.isEmpty() - ? lang(lng_in_dlg_sticker) + ? tr::lng_in_dlg_sticker(tr::now) : lng_in_dlg_sticker_emoji(lt_emoji, _emoji); } const auto type = [&] { if (_document->isVideoMessage()) { - return lang(lng_in_dlg_video_message); + return tr::lng_in_dlg_video_message(tr::now); } else if (_document->isAnimation()) { return qsl("GIF"); } else if (_document->isVideoFile()) { - return lang(lng_in_dlg_video); + return tr::lng_in_dlg_video(tr::now); } else if (_document->isVoiceMessage()) { - return lang(lng_in_dlg_audio); + return tr::lng_in_dlg_audio(tr::now); } else if (!_document->filename().isEmpty()) { return _document->filename(); } else if (_document->isAudioFile()) { - return lang(lng_in_dlg_audio_file); + return tr::lng_in_dlg_audio_file(tr::now); } - return lang(lng_in_dlg_file); + return tr::lng_in_dlg_file(tr::now); }(); return WithCaptionNotificationText(type, parent()->originalText().text); } @@ -612,20 +612,20 @@ QString MediaFile::pinnedTextSubstring() const { if (!_emoji.isEmpty()) { return lng_action_pinned_media_emoji_sticker(lt_emoji, _emoji); } - return lang(lng_action_pinned_media_sticker); + return tr::lng_action_pinned_media_sticker(tr::now); } else if (_document->isAnimation()) { if (_document->isVideoMessage()) { - return lang(lng_action_pinned_media_video_message); + return tr::lng_action_pinned_media_video_message(tr::now); } - return lang(lng_action_pinned_media_gif); + return tr::lng_action_pinned_media_gif(tr::now); } else if (_document->isVideoFile()) { - return lang(lng_action_pinned_media_video); + return tr::lng_action_pinned_media_video(tr::now); } else if (_document->isVoiceMessage()) { - return lang(lng_action_pinned_media_voice); + return tr::lng_action_pinned_media_voice(tr::now); } else if (_document->isSong()) { - return lang(lng_action_pinned_media_audio); + return tr::lng_action_pinned_media_audio(tr::now); } - return lang(lng_action_pinned_media_file); + return tr::lng_action_pinned_media_file(tr::now); } TextForMimeData MediaFile::clipboardText() const { @@ -638,20 +638,20 @@ TextForMimeData MediaFile::clipboardText() const { if (!_emoji.isEmpty()) { return lng_in_dlg_sticker_emoji(lt_emoji, _emoji); } - return lang(lng_in_dlg_sticker); + return tr::lng_in_dlg_sticker(tr::now); } else if (_document->isAnimation()) { if (_document->isVideoMessage()) { - return lang(lng_in_dlg_video_message); + return tr::lng_in_dlg_video_message(tr::now); } return qsl("GIF"); } else if (_document->isVideoFile()) { - return lang(lng_in_dlg_video); + return tr::lng_in_dlg_video(tr::now); } else if (_document->isVoiceMessage()) { - return lang(lng_in_dlg_audio) + addName; + return tr::lng_in_dlg_audio(tr::now) + addName; } else if (_document->isSong()) { - return lang(lng_in_dlg_audio_file) + addName; + return tr::lng_in_dlg_audio_file(tr::now) + addName; } - return lang(lng_in_dlg_file) + addName; + return tr::lng_in_dlg_file(tr::now) + addName; }(); return WithCaptionClipboardText( attachType, @@ -676,29 +676,29 @@ bool MediaFile::forwardedBecomesUnread() const { QString MediaFile::errorTextForForward(not_null peer) const { if (const auto sticker = _document->sticker()) { - if (const auto key = Data::RestrictionErrorKey( + if (const auto error = Data::RestrictionError( peer, ChatRestriction::f_send_stickers)) { - return lang(*key); + return *error; } } else if (_document->isAnimation()) { if (_document->isVideoMessage()) { - if (const auto key = Data::RestrictionErrorKey( + if (const auto error = Data::RestrictionError( peer, ChatRestriction::f_send_media)) { - return lang(*key); + return *error; } } else { - if (const auto key = Data::RestrictionErrorKey( + if (const auto error = Data::RestrictionError( peer, ChatRestriction::f_send_gifs)) { - return lang(*key); + return *error; } } - } else if (const auto key = Data::RestrictionErrorKey( + } else if (const auto error = Data::RestrictionError( peer, ChatRestriction::f_send_media)) { - return lang(*key); + return *error; } return QString(); } @@ -807,15 +807,15 @@ const SharedContact *MediaContact::sharedContact() const { } QString MediaContact::notificationText() const { - return lang(lng_in_dlg_contact); + return tr::lng_in_dlg_contact(tr::now); } QString MediaContact::pinnedTextSubstring() const { - return lang(lng_action_pinned_media_contact); + return tr::lng_action_pinned_media_contact(tr::now); } TextForMimeData MediaContact::clipboardText() const { - const auto text = qsl("[ ") + lang(lng_in_dlg_contact) + qsl(" ]\n") + const auto text = qsl("[ ") + tr::lng_in_dlg_contact(tr::now) + qsl(" ]\n") + lng_full_name( lt_first_name, _contact.firstName, @@ -887,20 +887,20 @@ LocationData *MediaLocation::location() const { } QString MediaLocation::chatListText() const { - return WithCaptionDialogsText(lang(lng_maps_point), _title); + return WithCaptionDialogsText(tr::lng_maps_point(tr::now), _title); } QString MediaLocation::notificationText() const { - return WithCaptionNotificationText(lang(lng_maps_point), _title); + return WithCaptionNotificationText(tr::lng_maps_point(tr::now), _title); } QString MediaLocation::pinnedTextSubstring() const { - return lang(lng_action_pinned_media_location); + return tr::lng_action_pinned_media_location(tr::now); } TextForMimeData MediaLocation::clipboardText() const { auto result = TextForMimeData::Simple( - qstr("[ ") + lang(lng_maps_point) + qstr(" ]\n")); + qstr("[ ") + tr::lng_maps_point(tr::now) + qstr(" ]\n")); auto titleResult = TextUtilities::ParseEntities( TextUtilities::Clean(_title), Ui::WebpageTextTitleOptions().flags); @@ -993,15 +993,15 @@ QString MediaCall::Text( not_null item, CallFinishReason reason) { if (item->out()) { - return lang(reason == CallFinishReason::Missed - ? lng_call_cancelled - : lng_call_outgoing); + return (reason == CallFinishReason::Missed) + ? tr::lng_call_cancelled(tr::now) + : tr::lng_call_outgoing(tr::now); } else if (reason == CallFinishReason::Missed) { - return lang(lng_call_missed); + return tr::lng_call_missed(tr::now); } else if (reason == CallFinishReason::Busy) { - return lang(lng_call_declined); + return tr::lng_call_declined(tr::now); } - return lang(lng_call_incoming); + return tr::lng_call_incoming(tr::now); } MediaWebPage::MediaWebPage( @@ -1141,10 +1141,10 @@ TextForMimeData MediaGame::clipboardText() const { } QString MediaGame::errorTextForForward(not_null peer) const { - const auto errorKey = Data::RestrictionErrorKey( + return Data::RestrictionError( peer, - ChatRestriction::f_send_games); - return errorKey ? lang(*errorKey) : QString(); + ChatRestriction::f_send_games + ).value_or(QString()); } bool MediaGame::consumeMessageText(const TextWithEntities &text) { @@ -1265,7 +1265,7 @@ QString MediaPoll::pinnedTextSubstring() const { TextForMimeData MediaPoll::clipboardText() const { const auto text = qstr("[ ") - + lang(lng_in_dlg_poll) + + tr::lng_in_dlg_poll(tr::now) + qstr(" : ") + _poll->question + qstr(" ]") @@ -1280,10 +1280,10 @@ TextForMimeData MediaPoll::clipboardText() const { } QString MediaPoll::errorTextForForward(not_null peer) const { - const auto errorKey = Data::RestrictionErrorKey( + return Data::RestrictionError( peer, - ChatRestriction::f_send_polls); - return errorKey ? lang(*errorKey) : QString(); + ChatRestriction::f_send_polls + ).value_or(QString()); } bool MediaPoll::updateInlineResultMedia(const MTPMessageMedia &media) { diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 6daba8394..3772074cc 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -82,9 +82,9 @@ void PeerClickHandler::onClick(ClickContext context) const { && _peer->isChannel() && controller->activeChatCurrent().peer() != _peer) { if (!_peer->asChannel()->isPublic() && !_peer->asChannel()->amIn()) { - Ui::show(Box(lang(_peer->isMegagroup() - ? lng_group_not_accessible - : lng_channel_not_accessible))); + Ui::show(Box(_peer->isMegagroup() + ? tr::lng_group_not_accessible(tr::now) + : tr::lng_channel_not_accessible(tr::now))); } else { controller->showPeerHistory( _peer, @@ -455,7 +455,7 @@ void PeerData::fillNames() { appendToIndex(user->username); if (isSelf()) { const auto english = qsl("Saved messages"); - const auto localized = lang(lng_saved_messages); + const auto localized = tr::lng_saved_messages(tr::now); appendToIndex(english); if (localized != english) { appendToIndex(localized); @@ -709,7 +709,7 @@ std::vector ListOfRestrictions() { }; } -std::optional RestrictionErrorKey( +std::optional RestrictionError( not_null peer, ChatRestriction restriction) { using Flag = ChatRestriction; @@ -718,29 +718,29 @@ std::optional RestrictionErrorKey( switch (restriction) { case Flag::f_send_polls: return all - ? lng_restricted_send_polls_all - : lng_restricted_send_polls; + ? tr::lng_restricted_send_polls_all(tr::now) + : tr::lng_restricted_send_polls(tr::now); case Flag::f_send_messages: return all - ? lng_restricted_send_message_all - : lng_restricted_send_message; + ? tr::lng_restricted_send_message_all(tr::now) + : tr::lng_restricted_send_message(tr::now); case Flag::f_send_media: return all - ? lng_restricted_send_media_all - : lng_restricted_send_media; + ? tr::lng_restricted_send_media_all(tr::now) + : tr::lng_restricted_send_media(tr::now); case Flag::f_send_stickers: return all - ? lng_restricted_send_stickers_all - : lng_restricted_send_stickers; + ? tr::lng_restricted_send_stickers_all(tr::now) + : tr::lng_restricted_send_stickers(tr::now); case Flag::f_send_gifs: return all - ? lng_restricted_send_gifs_all - : lng_restricted_send_gifs; + ? tr::lng_restricted_send_gifs_all(tr::now) + : tr::lng_restricted_send_gifs(tr::now); case Flag::f_send_inline: case Flag::f_send_games: return all - ? lng_restricted_send_inline_all - : lng_restricted_send_inline; + ? tr::lng_restricted_send_inline_all(tr::now) + : tr::lng_restricted_send_inline(tr::now); } Unexpected("Restriction in Data::RestrictionErrorKey."); } diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 65300c1b0..df8ef0786 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -380,7 +380,7 @@ namespace Data { std::vector ListOfRestrictions(); -std::optional RestrictionErrorKey( +std::optional RestrictionError( not_null peer, ChatRestriction restriction); diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index 0265f3a18..bbc6f3551 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -44,13 +44,13 @@ int OnlinePhraseChangeInSeconds(TimeId online, TimeId now) { std::optional OnlineTextSpecial(not_null user) { if (user->isNotificationsUser()) { - return lang(lng_status_service_notifications); + return tr::lng_status_service_notifications(tr::now); } else if (user->isSupport()) { - return lang(lng_status_support); + return tr::lng_status_support(tr::now); } else if (user->isBot()) { - return lang(lng_status_bot); + return tr::lng_status_bot(tr::now); } else if (user->isServiceUser()) { - return lang(lng_status_support); + return tr::lng_status_support(tr::now); } return std::nullopt; } @@ -59,16 +59,16 @@ std::optional OnlineTextCommon(TimeId online, TimeId now) { if (online <= 0) { switch (online) { case 0: - case -1: return lang(lng_status_offline); - case -2: return lang(lng_status_recently); - case -3: return lang(lng_status_last_week); - case -4: return lang(lng_status_last_month); + case -1: return tr::lng_status_offline(tr::now); + case -2: return tr::lng_status_recently(tr::now); + case -3: return tr::lng_status_last_week(tr::now); + case -4: return tr::lng_status_last_month(tr::now); } return (-online > now) - ? lang(lng_status_online) - : lang(lng_status_recently); + ? tr::lng_status_online(tr::now) + : tr::lng_status_recently(tr::now); } else if (online > now) { - return lang(lng_status_online); + return tr::lng_status_online(tr::now); } return std::nullopt; } @@ -297,7 +297,7 @@ QString OnlineText(TimeId online, TimeId now) { } const auto minutes = (now - online) / 60; if (!minutes) { - return lang(lng_status_lastseen_now); + return tr::lng_status_lastseen_now(tr::now); } else if (minutes < 60) { return lng_status_lastseen_minutes(lt_count, minutes); } diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 3b8f4888f..22635b207 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "passport/passport_form_controller.h" #include "window/themes/window_theme.h" -#include "lang/lang_keys.h" // lang(lng_deleted) in user name +#include "lang/lang_keys.h" // tr::lng_deleted(tr::now) in user name #include "data/data_media_types.h" #include "data/data_folder.h" #include "data/data_channel.h" @@ -298,7 +298,7 @@ not_null Session::processUser(const MTPUser &data) { result->input = MTP_inputPeerUser(data.vid, MTP_long(0)); result->inputUser = MTP_inputUser(data.vid, MTP_long(0)); - result->setName(lang(lng_deleted), QString(), QString(), QString()); + result->setName(tr::lng_deleted(tr::now), QString(), QString(), QString()); result->setPhoto(MTP_userProfilePhotoEmpty()); //result->setFlags(MTPDuser_ClientFlag::f_inaccessible | 0); result->setFlags(MTPDuser::Flag::f_deleted); @@ -342,7 +342,7 @@ not_null Session::processUser(const MTPUser &data) { result->setPhone(QString()); update.flags |= UpdateFlag::UserPhoneChanged; } - result->setName(lang(lng_deleted), QString(), QString(), QString()); + result->setName(tr::lng_deleted(tr::now), QString(), QString(), QString()); result->setPhoto(MTP_userProfilePhotoEmpty()); status = &emptyStatus; } else { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index bf75cb932..d8d5dcde7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -105,7 +105,7 @@ InnerWidget::InnerWidget( , _pinnedShiftAnimation([=](crl::time now) { return pinnedShiftAnimationCallback(now); }) -, _addContactLnk(this, lang(lng_add_contact_button)) +, _addContactLnk(this, tr::lng_add_contact_button(tr::now)) , _cancelSearchInChat(this, st::dialogsCancelSearchInPeer) , _cancelSearchFromUser(this, st::dialogsCancelSearchInPeer) { @@ -478,7 +478,12 @@ void InnerWidget::paintEvent(QPaintEvent *e) { p.fillRect(dialogsClip, st::dialogsBg); p.setFont(st::noContactsFont); p.setPen(st::noContactsColor); - p.drawText(QRect(0, 0, fullWidth, st::noContactsHeight - (session().data().contactsLoaded().current() ? st::noContactsFont->height : 0)), lang(session().data().contactsLoaded().current() ? lng_no_chats : lng_contacts_loading), style::al_center); + p.drawText( + QRect(0, 0, fullWidth, st::noContactsHeight - (session().data().contactsLoaded().current() ? st::noContactsFont->height : 0)), + (session().data().contactsLoaded().current() + ? tr::lng_no_chats + : tr::lng_contacts_loading)(tr::now), + style::al_center); } } else if (_state == WidgetState::Filtered) { if (!_hashtagResults.empty()) { @@ -557,7 +562,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg); p.setFont(st::searchedBarFont); p.setPen(st::searchedBarFg); - p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), lang(lng_search_global_results)); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), tr::lng_search_global_results(tr::now)); p.translate(0, st::searchedBarHeight); auto skip = peerSearchOffset(); @@ -598,7 +603,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), - lang(lng_dlg_search_for_messages)); + tr::lng_dlg_search_for_messages(tr::now)); p.translate(0, st::searchedBarHeight); } } @@ -606,7 +611,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { const auto showUnreadInSearchResults = uniqueSearchResults(); if (!_waitingForSearch || !_searchResults.empty()) { const auto text = _searchResults.empty() - ? lang(lng_search_no_results) + ? tr::lng_search_no_results(tr::now) : showUnreadInSearchResults ? qsl("Search results") : lng_search_found_results( @@ -676,8 +681,8 @@ void InnerWidget::paintCollapsedRow( const auto text = row->folder ? row->folder->chatListName() : (_mode == Dialogs::Mode::Important) - ? (narrow ? "Show" : lang(lng_dialogs_show_all_chats)) - : (narrow ? "Hide" : lang(lng_dialogs_hide_muted_chats)); + ? (narrow ? "Show" : tr::lng_dialogs_show_all_chats(tr::now)) + : (narrow ? "Hide" : tr::lng_dialogs_hide_muted_chats(tr::now)); const auto unread = row->folder ? row->folder->chatListUnreadCount() : (_mode == Dialogs::Mode::Important) @@ -768,7 +773,7 @@ void InnerWidget::paintSearchInChat(Painter &p) const { p.fillRect(0, 0, width(), top, st::searchedBarBg); p.setFont(st::searchedBarFont); p.setPen(st::searchedBarFg); - p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), lang(lng_dlg_search_in)); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), tr::lng_dlg_search_in(tr::now)); auto fullRect = QRect(0, top, width(), height - top); p.fillRect(fullRect, st::dialogsBg); @@ -1699,9 +1704,9 @@ void InnerWidget::fillArchiveSearchMenu(not_null menu) { return; } const auto skip = session().settings().skipArchiveInSearch(); - const auto text = lang(skip - ? lng_dialogs_show_archive_in_search - : lng_dialogs_skip_archive_in_search); + const auto text = skip + ? tr::lng_dialogs_show_archive_in_search(tr::now) + : tr::lng_dialogs_skip_archive_in_search(tr::now); menu->addAction(text, [=] { session().settings().setSkipArchiveInSearch(!skip); session().saveSettingsDelayed(); @@ -2225,7 +2230,7 @@ void InnerWidget::refreshSearchInChatLabel() { const auto dialog = [&] { if (const auto peer = _searchInChat.peer()) { if (peer->isSelf()) { - return lang(lng_saved_messages); + return tr::lng_saved_messages(tr::now); } return peer->name; //} else if (const auto feed = _searchInChat.feed()) { // #feed diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index 1bae8fcf8..b68fd1e03 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -295,7 +295,7 @@ void paintRow( const auto promoted = (history && history->useProxyPromotion()) && !(flags & (Flag::SearchResult/* | Flag::FeedSearchResult*/)); // #feed if (promoted) { - const auto text = lang(lng_proxy_sponsor); + const auto text = tr::lng_proxy_sponsor(tr::now); PaintRowTopRight(p, text, rectForName, active, selected); } else if (from/* && !(flags & Flag::FeedSearchResult)*/) { // #feed if (const auto chatTypeIcon = ChatTypeIcon(from, active, selected)) { @@ -329,7 +329,7 @@ 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, lang(lng_from_draft))); + auto draftWrapped = textcmdLink(1, lng_dialogs_text_from_wrapped(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)); @@ -414,7 +414,7 @@ void paintRow( p.setPen(nameFg); if (flags & Flag::SavedMessages) { p.setFont(st::msgNameFont); - auto text = lang(lng_saved_messages); + auto text = tr::lng_saved_messages(tr::now); auto textWidth = st::msgNameFont->width(text); if (textWidth > rectForName.width()) { text = st::msgNameFont->elided(text, rectForName.width()); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 22b8c2697..9be9921e9 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -476,7 +476,7 @@ void Widget::checkUpdateStatus() { if (_updateTelegram) return; _updateTelegram.create( this, - lang(lng_update_telegram), + tr::lng_update_telegram(tr::now), st::dialogsUpdateButton, st::dialogsInstallUpdate, st::dialogsInstallUpdateOver); @@ -1563,7 +1563,7 @@ void Widget::paintEvent(QPaintEvent *e) { p.fillRect(0, aboveTop, width(), st::dialogsForwardHeight, st::dialogsForwardBg); p.setPen(st::dialogsForwardFg); p.setFont(st::dialogsForwardFont); - p.drawTextLeft(st::dialogsForwardTextLeft, st::dialogsForwardTextTop, width(), lang(lng_forward_choose)); + p.drawTextLeft(st::dialogsForwardTextLeft, st::dialogsForwardTextTop, width(), tr::lng_forward_choose(tr::now)); aboveTop += st::dialogsForwardHeight; } auto above = QRect(0, aboveTop, width(), _scroll->y() - aboveTop); diff --git a/Telegram/SourceFiles/export/view/export_view_content.cpp b/Telegram/SourceFiles/export/view/export_view_content.cpp index ef4116957..d76d51126 100644 --- a/Telegram/SourceFiles/export/view/export_view_content.cpp +++ b/Telegram/SourceFiles/export/view/export_view_content.cpp @@ -65,38 +65,38 @@ Content ContentFromState(const ProcessingState &state) { }; switch (state.step) { case Step::Initializing: - pushMain(lang(lng_export_state_initializing)); + pushMain(tr::lng_export_state_initializing(tr::now)); break; case Step::DialogsList: - pushMain(lang(lng_export_state_chats_list)); + pushMain(tr::lng_export_state_chats_list(tr::now)); break; case Step::PersonalInfo: - pushMain(lang(lng_export_option_info)); + pushMain(tr::lng_export_option_info(tr::now)); break; case Step::Userpics: - pushMain(lang(lng_export_state_userpics)); + pushMain(tr::lng_export_state_userpics(tr::now)); pushBytes( "userpic" + QString::number(state.entityIndex), state.bytesName); break; case Step::Contacts: - pushMain(lang(lng_export_option_contacts)); + pushMain(tr::lng_export_option_contacts(tr::now)); break; case Step::Sessions: - pushMain(lang(lng_export_option_sessions)); + pushMain(tr::lng_export_option_sessions(tr::now)); break; case Step::OtherData: - pushMain(lang(lng_export_option_other)); + pushMain(tr::lng_export_option_other(tr::now)); break; case Step::Dialogs: - pushMain(lang(lng_export_state_chats)); + pushMain(tr::lng_export_state_chats(tr::now)); push( "chat" + QString::number(state.entityIndex), (state.entityName.isEmpty() - ? lang(lng_deleted) + ? tr::lng_deleted(tr::now) : (state.entityType == ProcessingState::EntityType::Chat) ? state.entityName - : lang(lng_saved_messages)), + : tr::lng_saved_messages(tr::now)), (state.itemCount > 0 ? (QString::number(state.itemIndex) + " / " diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index fdd4d6007..a333e29fb 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -52,7 +52,7 @@ void SuggestBox::prepare() { const auto content = Ui::CreateChild( this, - lang(lng_export_suggest_text), + tr::lng_export_suggest_text(tr::now), st::boxLabel); widthValue( ) | rpl::start_with_next([=](int width) { @@ -72,17 +72,14 @@ void SuggestBox::prepare() { Environment PrepareEnvironment() { auto result = Environment(); - const auto utfLang = [](LangKey key) { - return lang(key).toUtf8(); - }; result.internalLinksDomain = Global::InternalLinksDomain(); - result.aboutTelegram = utfLang(lng_export_about_telegram); - result.aboutContacts = utfLang(lng_export_about_contacts); - result.aboutFrequent = utfLang(lng_export_about_frequent); - result.aboutSessions = utfLang(lng_export_about_sessions); - result.aboutWebSessions = utfLang(lng_export_about_web_sessions); - result.aboutChats = utfLang(lng_export_about_chats); - result.aboutLeftChats = utfLang(lng_export_about_left_chats); + result.aboutTelegram = tr::lng_export_about_telegram(tr::now).toUtf8(); + result.aboutContacts = tr::lng_export_about_contacts(tr::now).toUtf8(); + result.aboutFrequent = tr::lng_export_about_frequent(tr::now).toUtf8(); + result.aboutSessions = tr::lng_export_about_sessions(tr::now).toUtf8(); + result.aboutWebSessions = tr::lng_export_about_web_sessions(tr::now).toUtf8(); + result.aboutChats = tr::lng_export_about_chats(tr::now).toUtf8(); + result.aboutLeftChats = tr::lng_export_about_left_chats(tr::now).toUtf8(); return result; } @@ -191,7 +188,7 @@ void PanelController::showError(const ApiErrorState &error) { LOG(("Export Info: API Error '%1'.").arg(error.data.type())); if (error.data.type() == qstr("TAKEOUT_INVALID")) { - showError(lang(lng_export_invalid)); + showError(tr::lng_export_invalid(tr::now)); } else if (error.data.type().startsWith(qstr("TAKEOUT_INIT_DELAY_"))) { const auto seconds = std::max(error.data.type().mid( qstr("TAKEOUT_INIT_DELAY_").size()).toInt(), 1); @@ -200,7 +197,7 @@ void PanelController::showError(const ApiErrorState &error) { const auto hours = seconds / 3600; const auto hoursText = [&] { if (hours <= 0) { - return lang(lng_export_delay_less_than_hour); + return tr::lng_export_delay_less_than_hour(tr::now); } return lng_export_delay_hours(lt_count, hours); }(); @@ -316,8 +313,8 @@ void PanelController::stopWithConfirmation(FnMut callback) { const auto hidden = _panel->isHidden(); const auto old = _confirmStopBox; auto box = Box( - lang(lng_export_sure_stop), - lang(lng_export_stop), + tr::lng_export_sure_stop(tr::now), + tr::lng_export_stop(tr::now), st::attentionBoxButton, std::move(stop)); _confirmStopBox = box.data(); diff --git a/Telegram/SourceFiles/export/view/export_view_progress.cpp b/Telegram/SourceFiles/export/view/export_view_progress.cpp index 14a034f59..ff028cd27 100644 --- a/Telegram/SourceFiles/export/view/export_view_progress.cpp +++ b/Telegram/SourceFiles/export/view/export_view_progress.cpp @@ -245,7 +245,7 @@ ProgressWidget::ProgressWidget( _about = _body->add( object_ptr( this, - lang(lng_export_progress), + tr::lng_export_progress(tr::now), st::exportAboutLabel), st::exportAboutPadding); @@ -307,13 +307,13 @@ void ProgressWidget::updateState(Content &&content) { void ProgressWidget::showDone() { _cancel = nullptr; - _about->setText(lang(lng_export_about_done)); + _about->setText(tr::lng_export_about_done(tr::now)); _done = base::make_unique_q( this, tr::lng_export_done(), st::exportDoneButton); const auto desired = std::min( - st::exportDoneButton.font->width(lang(lng_export_done).toUpper()) + st::exportDoneButton.font->width(tr::lng_export_done(tr::now).toUpper()) + st::exportDoneButton.height - st::exportDoneButton.font->height, st::exportPanelSize.width() - 2 * st::exportCancelBottom); diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index f70001a43..6b6c78ad5 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -135,35 +135,38 @@ void SettingsWidget::setupFullExportOptions( not_null container) { addOptionWithAbout( container, - lng_export_option_info, + tr::lng_export_option_info(tr::now), Type::PersonalInfo | Type::Userpics, - lng_export_option_info_about); + tr::lng_export_option_info_about(tr::now)); addOptionWithAbout( container, - lng_export_option_contacts, + tr::lng_export_option_contacts(tr::now), Type::Contacts, - lng_export_option_contacts_about); - addHeader(container, lng_export_header_chats); + tr::lng_export_option_contacts_about(tr::now)); + addHeader(container, tr::lng_export_header_chats(tr::now)); addOption( container, - lng_export_option_personal_chats, + tr::lng_export_option_personal_chats(tr::now), Type::PersonalChats); - addOption(container, lng_export_option_bot_chats, Type::BotChats); + addOption( + container, + tr::lng_export_option_bot_chats(tr::now), + Type::BotChats); addChatOption( container, - lng_export_option_private_groups, + tr::lng_export_option_private_groups(tr::now), Type::PrivateGroups); addChatOption( container, - lng_export_option_private_channels, + tr::lng_export_option_private_channels(tr::now), Type::PrivateChannels); addChatOption( container, - lng_export_option_public_groups, + tr::lng_export_option_public_groups(tr::now), Type::PublicGroups); addChatOption( container, - lng_export_option_public_channels, + tr::lng_export_option_public_channels(tr::now), Type::PublicChannels); } @@ -178,7 +181,7 @@ void SettingsWidget::setupMediaOptions( container, object_ptr(container))); const auto media = mediaWrap->entity(); - addHeader(media, lng_export_header_media); + addHeader(media, tr::lng_export_header_media(tr::now)); addMediaOptions(media); value() | rpl::map([](const Settings &data) { @@ -201,17 +204,17 @@ void SettingsWidget::setupMediaOptions( void SettingsWidget::setupOtherOptions( not_null container) { - addHeader(container, lng_export_header_other); + addHeader(container, tr::lng_export_header_other(tr::now)); addOptionWithAbout( container, - lng_export_option_sessions, + tr::lng_export_option_sessions(tr::now), Type::Sessions, - lng_export_option_sessions_about); + tr::lng_export_option_sessions_about(tr::now)); addOptionWithAbout( container, - lng_export_option_other, + tr::lng_export_option_other(tr::now), Type::OtherData, - lng_export_option_other_about); + tr::lng_export_option_other_about(tr::now)); } void SettingsWidget::setupPathAndFormat( @@ -228,20 +231,20 @@ void SettingsWidget::setupPathAndFormat( data.format = format; }); }); - const auto addFormatOption = [&](LangKey key, Format format) { + const auto addFormatOption = [&](QString label, Format format) { const auto radio = container->add( object_ptr>( container, formatGroup, format, - lang(key), + label, st::defaultBoxCheckbox), st::exportSettingPadding); }; - addHeader(container, lng_export_header_format); + addHeader(container, tr::lng_export_header_format(tr::now)); addLocationLabel(container); - addFormatOption(lng_export_option_html, Format::Html); - addFormatOption(lng_export_option_json, Format::Json); + addFormatOption(tr::lng_export_option_html(tr::now), Format::Html); + addFormatOption(tr::lng_export_option_json(tr::now), Format::Json); } void SettingsWidget::addLocationLabel( @@ -444,23 +447,23 @@ not_null SettingsWidget::setupButtons( void SettingsWidget::addHeader( not_null container, - LangKey key) { + const QString &text) { container->add( object_ptr( container, - lang(key), + text, st::exportHeaderLabel), st::exportHeaderPadding); } not_null SettingsWidget::addOption( not_null container, - LangKey key, + const QString &text, Types types) { const auto checkbox = container->add( object_ptr( container, - lang(key), + text, ((readData().types & types) == types), st::defaultBoxCheckbox), st::exportSettingPadding); @@ -479,14 +482,14 @@ not_null SettingsWidget::addOption( not_null SettingsWidget::addOptionWithAbout( not_null container, - LangKey key, + const QString &text, Types types, - LangKey about) { - const auto result = addOption(container, key, types); + const QString &about) { + const auto result = addOption(container, text, types); const auto label = container->add( object_ptr( container, - lang(about), + about, st::exportAboutOptionLabel), st::exportAboutOptionPadding); return result; @@ -494,15 +497,15 @@ not_null SettingsWidget::addOptionWithAbout( void SettingsWidget::addChatOption( not_null container, - LangKey key, + const QString &text, Types types) { - const auto checkbox = addOption(container, key, types); + const auto checkbox = addOption(container, text, types); const auto onlyMy = container->add( object_ptr>( container, object_ptr( container, - lang(lng_export_option_only_my), + tr::lng_export_option_only_my(tr::now), ((readData().fullChats & types) != types), st::defaultBoxCheckbox), st::exportSubSettingPadding)); @@ -528,36 +531,45 @@ void SettingsWidget::addChatOption( void SettingsWidget::addMediaOptions( not_null container) { - addMediaOption(container, lng_export_option_photos, MediaType::Photo); addMediaOption( container, - lng_export_option_video_files, + tr::lng_export_option_photos(tr::now), + MediaType::Photo); + addMediaOption( + container, + tr::lng_export_option_video_files(tr::now), MediaType::Video); addMediaOption( container, - lng_export_option_voice_messages, + tr::lng_export_option_voice_messages(tr::now), MediaType::VoiceMessage); addMediaOption( container, - lng_export_option_video_messages, + tr::lng_export_option_video_messages(tr::now), MediaType::VideoMessage); addMediaOption( container, - lng_export_option_stickers, + tr::lng_export_option_stickers(tr::now), MediaType::Sticker); - addMediaOption(container, lng_export_option_gifs, MediaType::GIF); - addMediaOption(container, lng_export_option_files, MediaType::File); + addMediaOption( + container, + tr::lng_export_option_gifs(tr::now), + MediaType::GIF); + addMediaOption( + container, + tr::lng_export_option_files(tr::now), + MediaType::File); addSizeSlider(container); } void SettingsWidget::addMediaOption( not_null container, - LangKey key, + const QString &text, MediaType type) { const auto checkbox = container->add( object_ptr( container, - lang(key), + text, ((readData().media.types & type) == type), st::defaultBoxCheckbox), st::exportSettingPadding); @@ -675,7 +687,7 @@ void SettingsWidget::chooseFolder() { }; FileDialog::GetFolder( this, - lang(lng_export_folder), + tr::lng_export_folder(tr::now), readData().path, callback); } diff --git a/Telegram/SourceFiles/export/view/export_view_settings.h b/Telegram/SourceFiles/export/view/export_view_settings.h index d3656ff57..afedfc3d7 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.h +++ b/Telegram/SourceFiles/export/view/export_view_settings.h @@ -10,8 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "export/export_settings.h" #include "ui/rp_widget.h" -enum LangKey : int; - namespace Ui { class VerticalLayout; class Checkbox; @@ -55,24 +53,24 @@ private: void setupPathAndFormat(not_null container); void addHeader( not_null container, - LangKey key); + const QString &text); not_null addOption( not_null container, - LangKey key, + const QString &text, Types types); not_null addOptionWithAbout( not_null container, - LangKey key, + const QString &text, Types types, - LangKey about); + const QString &about); void addChatOption( not_null container, - LangKey key, + const QString &text, Types types); void addMediaOptions(not_null container); void addMediaOption( not_null container, - LangKey key, + const QString &text, MediaType type); void addSizeSlider(not_null container); void addLocationLabel( diff --git a/Telegram/SourceFiles/export/view/export_view_top_bar.cpp b/Telegram/SourceFiles/export/view/export_view_top_bar.cpp index 925a40acc..6294b699c 100644 --- a/Telegram/SourceFiles/export/view/export_view_top_bar.cpp +++ b/Telegram/SourceFiles/export/view/export_view_top_bar.cpp @@ -41,7 +41,7 @@ void TopBar::updateData(Content &&content) { const auto &row = content.rows[0]; const auto clean = &TextUtilities::Clean; _info->setRichText(textcmdStartSemibold() - + clean(lang(lng_export_progress_title)) + + clean(tr::lng_export_progress_title(tr::now)) + textcmdStopSemibold() + QString::fromUtf8(" \xe2\x80\x93 ") + clean(row.label) diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index e084b70bd..ffe98386a 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -84,7 +84,7 @@ void activateBotCommand( } break; case ButtonType::Buy: { - Ui::show(Box(lang(lng_payments_not_supported))); + Ui::show(Box(tr::lng_payments_not_supported(tr::now))); } break; case ButtonType::Url: { @@ -104,14 +104,14 @@ void activateBotCommand( case ButtonType::RequestLocation: { hideSingleUseKeyboard(msg); - Ui::show(Box(lang(lng_bot_share_location_unavailable))); + Ui::show(Box(tr::lng_bot_share_location_unavailable(tr::now))); } break; case ButtonType::RequestPhone: { hideSingleUseKeyboard(msg); const auto msgId = msg->id; const auto history = msg->history(); - Ui::show(Box(lang(lng_bot_share_phone), lang(lng_bot_share_phone_confirm), [=] { + Ui::show(Box(tr::lng_bot_share_phone(tr::now), tr::lng_bot_share_phone_confirm(tr::now), [=] { Ui::showPeerHistory(history, ShowAtTheEndMsgId); auto options = ApiWrap::SendOptions(history); options.replyTo = msgId; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp index 52d60339b..3aad8d5df 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp @@ -223,7 +223,7 @@ void FilterBox::Inner::createControls(const std::vector> &ad void FilterBox::Inner::createAllActionsCheckbox(const FilterValue &filter) { auto checked = (filter.flags == 0); - _allFlags = addRow(object_ptr(this, lang(lng_admin_log_filter_all_actions), checked, st::adminLogFilterCheckbox), st::adminLogFilterCheckbox.margin.top()); + _allFlags = addRow(object_ptr(this, tr::lng_admin_log_filter_all_actions(tr::now), checked, st::adminLogFilterCheckbox), st::adminLogFilterCheckbox.margin.top()); _allFlags->checkedChanges( ) | rpl::start_with_next([=](bool checked) { if (!std::exchange(_restoringInvariant, true)) { @@ -266,21 +266,21 @@ void FilterBox::Inner::createActionsCheckboxes(const FilterValue &filter) { }; auto isGroup = _channel->isMegagroup(); if (isGroup) { - addFlag(Flag::f_ban | Flag::f_unban | Flag::f_kick | Flag::f_unkick, lang(lng_admin_log_filter_restrictions)); + addFlag(Flag::f_ban | Flag::f_unban | Flag::f_kick | Flag::f_unkick, tr::lng_admin_log_filter_restrictions(tr::now)); } - addFlag(Flag::f_promote | Flag::f_demote, lang(lng_admin_log_filter_admins_new)); - addFlag(Flag::f_join | Flag::f_invite, lang(lng_admin_log_filter_members_new)); - addFlag(Flag::f_info | Flag::f_settings, lang(_channel->isMegagroup() ? lng_admin_log_filter_info_group : lng_admin_log_filter_info_channel)); - addFlag(Flag::f_delete, lang(lng_admin_log_filter_messages_deleted)); - addFlag(Flag::f_edit, lang(lng_admin_log_filter_messages_edited)); + addFlag(Flag::f_promote | Flag::f_demote, tr::lng_admin_log_filter_admins_new(tr::now)); + addFlag(Flag::f_join | Flag::f_invite, tr::lng_admin_log_filter_members_new(tr::now)); + addFlag(Flag::f_info | Flag::f_settings, _channel->isMegagroup() ? tr::lng_admin_log_filter_info_group(tr::now) : tr::lng_admin_log_filter_info_channel(tr::now)); + addFlag(Flag::f_delete, tr::lng_admin_log_filter_messages_deleted(tr::now)); + addFlag(Flag::f_edit, tr::lng_admin_log_filter_messages_edited(tr::now)); if (isGroup) { - addFlag(Flag::f_pinned, lang(lng_admin_log_filter_messages_pinned)); + addFlag(Flag::f_pinned, tr::lng_admin_log_filter_messages_pinned(tr::now)); } - addFlag(Flag::f_leave, lang(lng_admin_log_filter_members_removed)); + addFlag(Flag::f_leave, tr::lng_admin_log_filter_members_removed(tr::now)); } void FilterBox::Inner::createAllUsersCheckbox(const FilterValue &filter) { - _allUsers = addRow(object_ptr(this, lang(lng_admin_log_filter_all_admins), filter.allUsers, st::adminLogFilterCheckbox), st::adminLogFilterSkip); + _allUsers = addRow(object_ptr(this, tr::lng_admin_log_filter_all_admins(tr::now), filter.allUsers, st::adminLogFilterCheckbox), st::adminLogFilterSkip); _allUsers->checkedChanges( ) | rpl::start_with_next([=](bool checked) { if (checked && !std::exchange(_restoringInvariant, true)) { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 377f13dea..af74feccf 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "auth_session.h" #include "ui/widgets/popup_menu.h" #include "ui/image/image.h" +#include "ui/text/text_utilities.h" #include "core/file_utilities.h" #include "lang/lang_keys.h" #include "boxes/peers/edit_participant_box.h" @@ -451,11 +452,17 @@ void InnerWidget::updateEmptyText() { options.flags |= TextParseMarkdown; auto hasSearch = !_searchQuery.isEmpty(); auto hasFilter = (_filter.flags != 0) || !_filter.allUsers; - auto text = TextWithEntities { lang((hasSearch || hasFilter) ? lng_admin_log_no_results_title : lng_admin_log_no_events_title) }; - text.entities.append(EntityInText(EntityType::Bold, 0, text.text.size())); + auto text = Ui::Text::Bold((hasSearch || hasFilter) + ? tr::lng_admin_log_no_results_title(tr::now) + : tr::lng_admin_log_no_events_title(tr::now)); auto description = hasSearch - ? lng_admin_log_no_results_search_text(lt_query, TextUtilities::Clean(_searchQuery)) - : lang(hasFilter ? lng_admin_log_no_results_text : lng_admin_log_no_events_text); + ? tr::lng_admin_log_no_results_search_text( + tr::now, + lt_query, + TextUtilities::Clean(_searchQuery)) + : hasFilter + ? tr::lng_admin_log_no_results_text(tr::now) + : tr::lng_admin_log_no_events_text(tr::now); text.text.append(qstr("\n\n") + description); _emptyText.setMarkedText(st::defaultTextStyle, text, options); } @@ -994,22 +1001,22 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { auto lnkIsAudio = lnkDocument ? lnkDocument->document()->isAudioFile() : false; if (lnkPhoto || lnkDocument) { if (isUponSelected > 0) { - _menu->addAction(lang(lng_context_copy_selected), [=] { + _menu->addAction(tr::lng_context_copy_selected(tr::now), [=] { copySelectedText(); }); } if (lnkPhoto) { const auto photo = lnkPhoto->photo(); - _menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { + _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { savePhotoToFile(photo); })); - _menu->addAction(lang(lng_context_copy_image), [=] { + _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { copyContextImage(photo); }); } else { auto document = lnkDocument->document(); if (document->loading()) { - _menu->addAction(lang(lng_context_cancel_download), [=] { + _menu->addAction(tr::lng_context_cancel_download(tr::now), [=] { cancelContextDownload(document); }); } else { @@ -1018,17 +1025,17 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto itemId = view ? view->data()->fullId() : FullMsgId(); - _menu->addAction(lang(lng_context_open_gif), [=] { + _menu->addAction(tr::lng_context_open_gif(tr::now), [=] { openContextGif(itemId); }); } } if (!document->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) { - _menu->addAction(lang(Platform::IsMac() ? lng_context_show_in_finder : lng_context_show_in_folder), [=] { + _menu->addAction(Platform::IsMac() ? tr::lng_context_show_in_finder(tr::now) : tr::lng_context_show_in_folder(tr::now), [=] { showContextInFolder(document); }); } - _menu->addAction(lang(lnkIsVideo ? lng_context_save_video : (lnkIsVoice ? lng_context_save_audio : (lnkIsAudio ? lng_context_save_audio_file : lng_context_save_file))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] { + _menu->addAction(lnkIsVideo ? tr::lng_context_save_video(tr::now) : (lnkIsVoice ? tr::lng_context_save_audio(tr::now) : (lnkIsAudio ? tr::lng_context_save_audio_file(tr::now) : tr::lng_context_save_file(tr::now))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] { saveDocumentToFile(document); })); } @@ -1045,20 +1052,20 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { auto msg = dynamic_cast(item); if (isUponSelected > 0) { - _menu->addAction(lang(lng_context_copy_selected), [this] { copySelectedText(); }); + _menu->addAction(tr::lng_context_copy_selected(tr::now), [this] { copySelectedText(); }); } else { if (item && !isUponSelected) { const auto media = view->media(); const auto mediaHasTextForCopy = media && media->hasTextForCopy(); if (const auto document = media ? media->getDocument() : nullptr) { if (document->sticker()) { - _menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] { + _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] { saveDocumentToFile(document); })); } } if (msg && !link && (view->hasVisibleText() || mediaHasTextForCopy)) { - _menu->addAction(lang(lng_context_copy_text), [=] { + _menu->addAction(tr::lng_context_copy_text(tr::now), [=] { copyContextText(itemId); }); } @@ -1093,7 +1100,7 @@ void InnerWidget::savePhotoToFile(PhotoData *photo) { auto filter = qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter(); FileDialog::GetWritePath( this, - lang(lng_save_photo), + tr::lng_save_photo(tr::now), filter, filedialogDefaultName(qsl("photo"), qsl(".jpg")), crl::guard(this, [=](const QString &result) { @@ -1163,7 +1170,7 @@ void InnerWidget::suggestRestrictUser(not_null user) { return; } } - _menu->addAction(lang(lng_context_restrict_user), [=] { + _menu->addAction(tr::lng_context_restrict_user(tr::now), [=] { auto editRestrictions = [=](bool hasAdminRights, const MTPChatBannedRights ¤tRights) { auto weak = QPointer(this); auto weakBox = std::make_shared>(); 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 ffd8798d1..76fd76baf 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -113,7 +113,7 @@ const auto CollectChanges = [](auto &phraseMap, auto plusFlags, auto minusFlags) auto result = QString(); for (auto &phrase : phraseMap) { if (flags & phrase.first) { - result.append('\n' + (prefix + lang(phrase.second))); + result.append('\n' + (prefix + phrase.second(tr::now))); } } return result; @@ -138,16 +138,18 @@ TextWithEntities GenerateAdminChangeText( auto result = tr::lng_admin_log_promoted(tr::now, lt_user, user, Ui::Text::WithEntities); auto useInviteLinkPhrase = channel->isMegagroup() && channel->anyoneCanAddMembers(); - auto invitePhrase = (useInviteLinkPhrase ? lng_admin_log_admin_invite_link : lng_admin_log_admin_invite_users); - static auto phraseMap = std::map { - { Flag::f_change_info, lng_admin_log_admin_change_info }, - { Flag::f_post_messages, lng_admin_log_admin_post_messages }, - { Flag::f_edit_messages, lng_admin_log_admin_edit_messages }, - { Flag::f_delete_messages, lng_admin_log_admin_delete_messages }, - { Flag::f_ban_users, lng_admin_log_admin_ban_users }, + auto invitePhrase = useInviteLinkPhrase + ? tr::lng_admin_log_admin_invite_link + : tr::lng_admin_log_admin_invite_users; + static auto phraseMap = std::map> { + { Flag::f_change_info, tr::lng_admin_log_admin_change_info }, + { Flag::f_post_messages, tr::lng_admin_log_admin_post_messages }, + { Flag::f_edit_messages, tr::lng_admin_log_admin_edit_messages }, + { Flag::f_delete_messages, tr::lng_admin_log_admin_delete_messages }, + { Flag::f_ban_users, tr::lng_admin_log_admin_ban_users }, { Flag::f_invite_users, invitePhrase }, - { Flag::f_pin_messages, lng_admin_log_admin_pin_messages }, - { Flag::f_add_admins, lng_admin_log_admin_add_admins }, + { Flag::f_pin_messages, tr::lng_admin_log_admin_pin_messages }, + { Flag::f_add_admins, tr::lng_admin_log_admin_add_admins }, }; phraseMap[Flag::f_invite_users] = invitePhrase; @@ -176,16 +178,16 @@ QString GenerateBannedChangeText( auto newFlags = newRights ? newRights->c_chatBannedRights().vflags.v : Flags(0); auto prevFlags = prevRights ? prevRights->c_chatBannedRights().vflags.v : Flags(0); - static auto phraseMap = std::map{ - { Flag::f_view_messages, lng_admin_log_banned_view_messages }, - { Flag::f_send_messages, lng_admin_log_banned_send_messages }, - { Flag::f_send_media, lng_admin_log_banned_send_media }, - { Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_inline | Flag::f_send_games, lng_admin_log_banned_send_stickers }, - { Flag::f_embed_links, lng_admin_log_banned_embed_links }, - { Flag::f_send_polls, lng_admin_log_banned_send_polls }, - { Flag::f_change_info, lng_admin_log_admin_change_info }, - { Flag::f_invite_users, lng_admin_log_admin_invite_users }, - { Flag::f_pin_messages, lng_admin_log_admin_pin_messages }, + static auto phraseMap = std::map>{ + { Flag::f_view_messages, tr::lng_admin_log_banned_view_messages }, + { Flag::f_send_messages, tr::lng_admin_log_banned_send_messages }, + { Flag::f_send_media, tr::lng_admin_log_banned_send_media }, + { Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_inline | Flag::f_send_games, tr::lng_admin_log_banned_send_stickers }, + { Flag::f_embed_links, tr::lng_admin_log_banned_embed_links }, + { Flag::f_send_polls, tr::lng_admin_log_banned_send_polls }, + { Flag::f_change_info, tr::lng_admin_log_admin_change_info }, + { Flag::f_invite_users, tr::lng_admin_log_admin_invite_users }, + { Flag::f_pin_messages, tr::lng_admin_log_admin_pin_messages }, }; return CollectChanges(phraseMap, prevFlags, newFlags); } @@ -309,7 +311,7 @@ TextWithEntities GenerateParticipantChangeText(not_null channel, c } TextWithEntities GenerateDefaultBannedRightsChangeText(not_null channel, const MTPChatBannedRights &rights, const MTPChatBannedRights &oldRights) { - auto result = TextWithEntities{ lang(lng_admin_log_changed_default_permissions) }; + auto result = TextWithEntities{ tr::lng_admin_log_changed_default_permissions(tr::now) }; const auto changes = GenerateBannedChangeText(&rights, &oldRights); if (!changes.isEmpty()) { result.text.append('\n' + changes); @@ -402,7 +404,7 @@ void GenerateItems( auto body = history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), newDescription); if (!oldValue.isEmpty()) { auto oldDescription = PrepareText(oldValue, QString()); - body->addLogEntryOriginal(id, lang(lng_admin_log_previous_description), oldDescription); + body->addLogEntryOriginal(id, tr::lng_admin_log_previous_description(tr::now), oldDescription); } addPart(body); }; @@ -423,7 +425,7 @@ void GenerateItems( auto body = history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), newLink); if (!oldValue.isEmpty()) { auto oldLink = PrepareText(Core::App().createInternalLinkFull(oldValue), QString()); - body->addLogEntryOriginal(id, lang(lng_admin_log_previous_link), oldLink); + body->addLogEntryOriginal(id, tr::lng_admin_log_previous_link(tr::now), oldLink); } addPart(body); }; @@ -491,9 +493,15 @@ void GenerateItems( date), detachExistingItem); if (oldValue.text.isEmpty()) { - oldValue = PrepareText(QString(), lang(lng_admin_log_empty_text)); + oldValue = PrepareText(QString(), tr::lng_admin_log_empty_text(tr::now)); } - body->addLogEntryOriginal(id, lang(canHaveCaption ? lng_admin_log_previous_caption : lng_admin_log_previous_message), oldValue); + + body->addLogEntryOriginal( + id, + (canHaveCaption + ? tr::lng_admin_log_previous_caption + : tr::lng_admin_log_previous_message)(tr::now), + oldValue); addPart(body); }; @@ -556,7 +564,7 @@ void GenerateItems( lt_from, fromLinkText, lt_sticker_set, - textcmdLink(2, lang(lng_admin_log_changed_stickers_set))); + textcmdLink(2, tr::lng_admin_log_changed_stickers_set(tr::now))); auto setLink = std::make_shared([set] { Ui::show(Box(set)); }); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp index 9129712ef..6f9dacb1e 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp @@ -105,7 +105,7 @@ FixedBar::FixedBar( , _controller(controller) , _channel(channel) , _field(this, st::historyAdminLogSearchField, tr::lng_dlg_filter()) -, _backButton(this, lang(lng_admin_log_title_all)) +, _backButton(this, tr::lng_admin_log_title_all(tr::now)) , _search(this, st::topBarSearch) , _cancel(this, st::historyAdminLogCancelSearch) , _filter(this, tr::lng_admin_log_filter(), st::topBarButton) { @@ -125,9 +125,9 @@ FixedBar::FixedBar( void FixedBar::applyFilter(const FilterValue &value) { auto hasFilter = (value.flags != 0) || !value.allUsers; - _backButton->setText(lang(hasFilter - ? lng_admin_log_title_selected - : lng_admin_log_title_all)); + _backButton->setText(hasFilter + ? tr::lng_admin_log_title_selected(tr::now) + : tr::lng_admin_log_title_all(tr::now)); } void FixedBar::goBack() { @@ -254,7 +254,7 @@ Widget::Widget(QWidget *parent, not_null controller, , _scroll(this, st::historyScroll, false) , _fixedBar(this, controller, channel) , _fixedBarShadow(this) -, _whatIsThis(this, lang(lng_admin_log_about).toUpper(), st::historyComposeButton) { +, _whatIsThis(this, tr::lng_admin_log_about(tr::now).toUpper(), st::historyComposeButton) { _fixedBar->move(0, 0); _fixedBar->resizeToWidth(width()); subscribe(_fixedBar->showFilterSignal, [this] { showFilter(); }); @@ -275,7 +275,7 @@ Widget::Widget(QWidget *parent, not_null controller, connect(_scroll, &Ui::ScrollArea::scrolled, this, [this] { onScroll(); }); - _whatIsThis->setClickedCallback([=] { Ui::show(Box(lang(lng_admin_log_about_text))); }); + _whatIsThis->setClickedCallback([=] { Ui::show(Box(tr::lng_admin_log_about_text(tr::now))); }); setupShortcuts(); } diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index d3a6f5a32..21b050abd 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -488,7 +488,7 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { (end(_typing) - 1)->first->firstName); } else if (typingCount) { newTypingString = peer->isUser() - ? lang(lng_typing) + ? tr::lng_typing(tr::now) : lng_user_typing( lt_user, begin(_typing)->first->firstName); @@ -497,16 +497,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() ? lang(lng_send_action_record_video) : lng_user_action_record_video(lt_user, name); - case Type::UploadVideo: return name.isEmpty() ? lang(lng_send_action_upload_video) : lng_user_action_upload_video(lt_user, name); - case Type::RecordVoice: return name.isEmpty() ? lang(lng_send_action_record_audio) : lng_user_action_record_audio(lt_user, name); - case Type::UploadVoice: return name.isEmpty() ? lang(lng_send_action_upload_audio) : lng_user_action_upload_audio(lt_user, name); - case Type::RecordRound: return name.isEmpty() ? lang(lng_send_action_record_round) : lng_user_action_record_round(lt_user, name); - case Type::UploadRound: return name.isEmpty() ? lang(lng_send_action_upload_round) : lng_user_action_upload_round(lt_user, name); - case Type::UploadPhoto: return name.isEmpty() ? lang(lng_send_action_upload_photo) : lng_user_action_upload_photo(lt_user, name); - case Type::UploadFile: return name.isEmpty() ? lang(lng_send_action_upload_file) : lng_user_action_upload_file(lt_user, name); + 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::ChooseLocation: - case Type::ChooseContact: return name.isEmpty() ? lang(lng_typing) : lng_user_typing(lt_user, name); + case Type::ChooseContact: return name.isEmpty() ? tr::lng_typing(tr::now) : lng_user_typing(lt_user, name); default: break; }; return QString(); @@ -536,7 +536,7 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) { (end(_sendActions) - 1)->first->firstName); } else { newTypingString = peer->isUser() - ? lang(lng_playing_game) + ? tr::lng_playing_game(tr::now) : lng_user_playing_game( 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 483fce13a..f09f4d7f1 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -560,7 +560,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) { p.setFont(st::msgNameFont); p.setPen(st::dialogsNameFg); - p.drawText(_botAbout->rect.left() + st::msgPadding.left(), _botAbout->rect.top() + st::msgPadding.top() + st::msgNameFont->ascent, lang(lng_bot_description)); + p.drawText(_botAbout->rect.left() + st::msgPadding.left(), _botAbout->rect.top() + st::msgPadding.top() + st::msgNameFont->ascent, tr::lng_bot_description(tr::now)); p.setPen(st::historyTextInFg); _botAbout->info->text.draw(p, _botAbout->rect.left() + st::msgPadding.left(), _botAbout->rect.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip, _botAbout->width); @@ -1503,18 +1503,18 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } const auto itemId = item->fullId(); if (canSendMessages) { - _menu->addAction(lang(lng_context_reply_msg), [=] { + _menu->addAction(tr::lng_context_reply_msg(tr::now), [=] { _widget->replyToMessage(itemId); }); } if (item->allowsEdit(unixtime())) { - _menu->addAction(lang(lng_context_edit_msg), [=] { + _menu->addAction(tr::lng_context_edit_msg(tr::now), [=] { _widget->editMessage(itemId); }); } if (item->canPin()) { const auto isPinned = item->isPinned(); - _menu->addAction(lang(isPinned ? lng_context_unpin_msg : lng_context_pin_msg), [=] { + _menu->addAction(isPinned ? tr::lng_context_unpin_msg(tr::now) : tr::lng_context_pin_msg(tr::now), [=] { if (isPinned) { _widget->unpinMessage(itemId); } else { @@ -1524,21 +1524,21 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } }; const auto addPhotoActions = [&](not_null photo) { - _menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { + _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { savePhotoToFile(photo); })); - _menu->addAction(lang(lng_context_copy_image), [=] { + _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { copyContextImage(photo); }); if (photo->hasSticker) { - _menu->addAction(lang(lng_context_attached_stickers), [=] { + _menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] { Auth().api().requestAttachedStickerSets(photo); }); } }; const auto addDocumentActions = [&](not_null document) { if (document->loading()) { - _menu->addAction(lang(lng_context_cancel_download), [=] { + _menu->addAction(tr::lng_context_cancel_download(tr::now), [=] { cancelContextDownload(document); }); return; @@ -1550,20 +1550,20 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto lnkIsAudio = document->isAudioFile(); if (document->loaded() && document->isGifv()) { if (!cAutoPlayGif()) { - _menu->addAction(lang(lng_context_open_gif), [=] { + _menu->addAction(tr::lng_context_open_gif(tr::now), [=] { openContextGif(itemId); }); } - _menu->addAction(lang(lng_context_save_gif), [=] { + _menu->addAction(tr::lng_context_save_gif(tr::now), [=] { saveContextGif(itemId); }); } if (!document->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) { - _menu->addAction(lang(Platform::IsMac() ? lng_context_show_in_finder : lng_context_show_in_folder), [=] { + _menu->addAction(Platform::IsMac() ? tr::lng_context_show_in_finder(tr::now) : tr::lng_context_show_in_folder(tr::now), [=] { showContextInFolder(document); }); } - _menu->addAction(lang(lnkIsVideo ? lng_context_save_video : (lnkIsVoice ? lng_context_save_audio : (lnkIsAudio ? lng_context_save_audio_file : lng_context_save_file))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { + _menu->addAction(lnkIsVideo ? tr::lng_context_save_video(tr::now) : (lnkIsVoice ? tr::lng_context_save_audio(tr::now) : (lnkIsAudio ? tr::lng_context_save_audio_file(tr::now) : tr::lng_context_save_file(tr::now))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { saveDocumentToFile(itemId, document); })); }; @@ -1575,9 +1575,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto itemId = item ? item->fullId() : FullMsgId(); if (isUponSelected > 0) { _menu->addAction( - lang((isUponSelected > 1) - ? lng_context_copy_selected_items - : lng_context_copy_selected), + (isUponSelected > 1 + ? tr::lng_context_copy_selected_items(tr::now) + : tr::lng_context_copy_selected(tr::now)), [=] { copySelectedText(); }); } addItemActions(item); @@ -1587,45 +1587,45 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { addDocumentActions(lnkDocument->document()); } if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) { - _menu->addAction(lang(item->history()->peer->isMegagroup() ? lng_context_copy_link : lng_context_copy_post_link), [=] { + _menu->addAction(item->history()->peer->isMegagroup() ? tr::lng_context_copy_link(tr::now) : tr::lng_context_copy_post_link(tr::now), [=] { HistoryView::CopyPostLink(itemId); }); } if (isUponSelected > 1) { if (selectedState.count > 0 && selectedState.canForwardCount == selectedState.count) { - _menu->addAction(lang(lng_context_forward_selected), [=] { + _menu->addAction(tr::lng_context_forward_selected(tr::now), [=] { _widget->forwardSelected(); }); } if (selectedState.count > 0 && selectedState.canDeleteCount == selectedState.count) { - _menu->addAction(lang(lng_context_delete_selected), [=] { + _menu->addAction(tr::lng_context_delete_selected(tr::now), [=] { _widget->confirmDeleteSelected(); }); } - _menu->addAction(lang(lng_context_clear_selection), [=] { + _menu->addAction(tr::lng_context_clear_selection(tr::now), [=] { _widget->clearSelected(); }); } else if (item) { const auto itemId = item->fullId(); if (isUponSelected != -2) { if (item->allowsForward()) { - _menu->addAction(lang(lng_context_forward_msg), [=] { + _menu->addAction(tr::lng_context_forward_msg(tr::now), [=] { forwardItem(itemId); }); } if (item->canDelete()) { - _menu->addAction(lang(lng_context_delete_msg), [=] { + _menu->addAction(tr::lng_context_delete_msg(tr::now), [=] { deleteItem(itemId); }); } if (item->suggestReport()) { - _menu->addAction(lang(lng_context_report_msg), [=] { + _menu->addAction(tr::lng_context_report_msg(tr::now), [=] { reportItem(itemId); }); } } if (IsServerMsgId(item->id) && !item->serviceMsg()) { - _menu->addAction(lang(lng_context_select_msg), [=] { + _menu->addAction(tr::lng_context_select_msg(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { if (const auto view = item->mainView()) { changeSelection(&_selected, item, SelectAction::Select); @@ -1661,9 +1661,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto msg = dynamic_cast(item); if (isUponSelected > 0) { _menu->addAction( - lang((isUponSelected > 1) - ? lng_context_copy_selected_items - : lng_context_copy_selected), + ((isUponSelected > 1) + ? tr::lng_context_copy_selected_items(tr::now) + : tr::lng_context_copy_selected(tr::now)), [=] { copySelectedText(); }); addItemActions(item); } else { @@ -1674,17 +1674,17 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { if (const auto document = media ? media->getDocument() : nullptr) { if (document->sticker()) { if (document->sticker()->set.type() != mtpc_inputStickerSetEmpty) { - _menu->addAction(lang(document->isStickerSetInstalled() ? lng_context_pack_info : lng_context_pack_add), [=] { + _menu->addAction(document->isStickerSetInstalled() ? tr::lng_context_pack_info(tr::now) : tr::lng_context_pack_add(tr::now), [=] { showStickerPackInfo(document); }); - _menu->addAction(lang(Stickers::IsFaved(document) ? lng_faved_stickers_remove : lng_faved_stickers_add), [=] { + _menu->addAction(Stickers::IsFaved(document) ? tr::lng_faved_stickers_remove(tr::now) : tr::lng_faved_stickers_add(tr::now), [=] { Auth().api().toggleFavedSticker( document, itemId, !Stickers::IsFaved(document)); }); } - _menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { + _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { saveDocumentToFile(itemId, document); })); } @@ -1693,12 +1693,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { if (const auto poll = media->poll()) { if (!poll->closed) { if (poll->voted()) { - _menu->addAction(lang(lng_polls_retract), [=] { + _menu->addAction(tr::lng_polls_retract(tr::now), [=] { Auth().api().sendPollVotes(itemId, {}); }); } if (item->canStopPoll()) { - _menu->addAction(lang(lng_polls_stop), [=] { + _menu->addAction(tr::lng_polls_stop(tr::now), [=] { HistoryView::StopPoll(itemId); }); } @@ -1706,7 +1706,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } if (msg && view && !link && (view->hasVisibleText() || mediaHasTextForCopy)) { - _menu->addAction(lang(lng_context_copy_text), [=] { + _menu->addAction(tr::lng_context_copy_text(tr::now), [=] { copyContextText(itemId); }); } @@ -1723,44 +1723,44 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { QApplication::clipboard()->setText(text); }); } else if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) { - _menu->addAction(lang(item->history()->peer->isMegagroup() ? lng_context_copy_link : lng_context_copy_post_link), [=] { + _menu->addAction(item->history()->peer->isMegagroup() ? tr::lng_context_copy_link(tr::now) : tr::lng_context_copy_post_link(tr::now), [=] { HistoryView::CopyPostLink(itemId); }); } if (isUponSelected > 1) { if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) { - _menu->addAction(lang(lng_context_forward_selected), [=] { + _menu->addAction(tr::lng_context_forward_selected(tr::now), [=] { _widget->forwardSelected(); }); } if (selectedState.count > 0 && selectedState.count == selectedState.canDeleteCount) { - _menu->addAction(lang(lng_context_delete_selected), [=] { + _menu->addAction(tr::lng_context_delete_selected(tr::now), [=] { _widget->confirmDeleteSelected(); }); } - _menu->addAction(lang(lng_context_clear_selection), [=] { + _menu->addAction(tr::lng_context_clear_selection(tr::now), [=] { _widget->clearSelected(); }); } else if (item && ((isUponSelected != -2 && (canForward || canDelete)) || item->id > 0)) { if (isUponSelected != -2) { if (canForward) { - _menu->addAction(lang(lng_context_forward_msg), [=] { + _menu->addAction(tr::lng_context_forward_msg(tr::now), [=] { forwardAsGroup(itemId); }); } if (canDelete) { - _menu->addAction(lang((msg && msg->uploading()) ? lng_context_cancel_upload : lng_context_delete_msg), [=] { + _menu->addAction((msg && msg->uploading()) ? tr::lng_context_cancel_upload(tr::now) : tr::lng_context_delete_msg(tr::now), [=] { deleteAsGroup(itemId); }); } if (canReport) { - _menu->addAction(lang(lng_context_report_msg), [=] { + _menu->addAction(tr::lng_context_report_msg(tr::now), [=] { reportAsGroup(itemId); }); } } if (item->id > 0 && !item->serviceMsg()) { - _menu->addAction(lang(lng_context_select_msg), [=] { + _menu->addAction(tr::lng_context_select_msg(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { if (const auto view = item->mainView()) { changeSelectionAsGroup(&_selected, item, SelectAction::Select); @@ -1775,7 +1775,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { && IsServerMsgId(App::mousedItem()->data()->id) && !App::mousedItem()->data()->serviceMsg()) { const auto itemId = App::mousedItem()->data()->fullId(); - _menu->addAction(lang(lng_context_select_msg), [=] { + _menu->addAction(tr::lng_context_select_msg(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { if (const auto view = item->mainView()) { changeSelectionAsGroup(&_selected, item, SelectAction::Select); @@ -1806,7 +1806,7 @@ void HistoryInner::savePhotoToFile(not_null photo) { auto filter = qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter(); FileDialog::GetWritePath( this, - lang(lng_save_photo), + tr::lng_save_photo(tr::now), filter, filedialogDefaultName( qsl("photo"), @@ -2015,7 +2015,7 @@ void HistoryInner::recountHistoryGeometry() { int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right(); if (tw > st::msgMaxWidth) tw = st::msgMaxWidth; tw -= st::msgPadding.left() + st::msgPadding.right(); - int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description))); + int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(tr::lng_bot_description(tr::now))); if (tw > mw) tw = mw; _botAbout->width = tw; @@ -2062,7 +2062,7 @@ void HistoryInner::updateBotInfo(bool recount) { int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right(); if (tw > st::msgMaxWidth) tw = st::msgMaxWidth; tw -= st::msgPadding.left() + st::msgPadding.right(); - int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description))); + int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(tr::lng_bot_description(tr::now))); if (tw > mw) tw = mw; _botAbout->width = tw; @@ -2723,7 +2723,7 @@ void HistoryInner::mouseActionUpdate() { ClickHandlerPtr HistoryInner::hiddenUserpicLink(FullMsgId id) { static const auto result = std::make_shared([] { - Ui::Toast::Show(lang(lng_forwarded_hidden)); + Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now)); }); return result; } diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 8556d7a4d..cbe76d251 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -727,7 +727,7 @@ QString HistoryItem::inDialogsText(DrawInDialog way) const { auto getText = [this]() { if (_media) { if (_groupId) { - return textcmdLink(1, TextUtilities::Clean(lang(lng_in_dlg_album))); + return textcmdLink(1, TextUtilities::Clean(tr::lng_in_dlg_album(tr::now))); } return _media->chatListText(); } else if (!emptyText()) { @@ -747,7 +747,7 @@ QString HistoryItem::inDialogsText(DrawInDialog way) const { return nullptr; }(); if (sender) { - auto fromText = sender->isSelf() ? lang(lng_from_you) : sender->shortName(); + 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); } @@ -828,7 +828,7 @@ not_null HistoryItem::Create( data.vfrom_id.v); } else if (checked == MediaCheckResult::Empty) { const auto text = HistoryService::PreparedText { - lang(lng_message_empty) + tr::lng_message_empty(tr::now) }; return history->owner().makeServiceMessage( history, @@ -848,7 +848,7 @@ not_null HistoryItem::Create( return history->owner().makeServiceMessage(history, data); }, [&](const MTPDmessageEmpty &data) -> HistoryItem* { const auto text = HistoryService::PreparedText{ - lang(lng_message_empty) + tr::lng_message_empty(tr::now) }; return history->owner().makeServiceMessage(history, data.vid.v, TimeId(0), text); }); diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index b95e882a4..3ef8eba6f 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -70,7 +70,7 @@ int HistoryMessageSigned::maxWidth() const { } void HistoryMessageEdited::refresh(const QString &date, bool displayed) { - const auto prefix = displayed ? (lang(lng_edited) + ' ') : QString(); + const auto prefix = displayed ? (tr::lng_edited(tr::now) + ' ') : QString(); text.setText(st::msgDateTextStyle, prefix + date, Ui::NameTextOptions()); } @@ -143,7 +143,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { }; text.setText(st::fwdTextStyle, phrase, opts); static const auto hidden = std::make_shared([] { - Ui::Toast::Show(lang(lng_forwarded_hidden)); + Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now)); }); text.setLink(1, fromChannel @@ -256,7 +256,7 @@ void HistoryMessageReply::updateName() const { maxReplyWidth = previewSkip + qMax(w, qMin(replyToText.maxWidth(), int32(st::maxSignatureSize))); } else { - maxReplyWidth = st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message)); + maxReplyWidth = st::msgDateFont->width(replyToMsgId ? tr::lng_profile_loading(tr::now) : tr::lng_deleted_message(tr::now)); } maxReplyWidth = st::msgReplyPadding.left() + st::msgReplyBarSkip + maxReplyWidth + st::msgReplyPadding.right(); } @@ -336,7 +336,7 @@ void HistoryMessageReply::paint( p.setFont(st::msgDateFont); auto &date = outbg ? (selected ? st::msgOutDateFgSelected : st::msgOutDateFg) : (selected ? st::msgInDateFgSelected : st::msgInDateFg); p.setPen((flags & PaintFlag::InBubble) ? date : st::msgDateImgFg); - p.drawTextLeft(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2, w + 2 * x, st::msgDateFont->elided(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message), w - st::msgReplyBarSkip)); + p.drawTextLeft(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2, w + 2 * x, st::msgDateFont->elided(replyToMsgId ? tr::lng_profile_loading(tr::now) : tr::lng_deleted_message(tr::now), w - st::msgReplyBarSkip)); } } } @@ -365,7 +365,7 @@ QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const { if (const auto button = getButton()) { using Type = HistoryMessageMarkupButton::Type; if (button->type == Type::Url || button->type == Type::Auth) { - return lang(lng_context_copy_link); + return tr::lng_context_copy_link(tr::now); } } return QString(); diff --git a/Telegram/SourceFiles/history/history_item_text.cpp b/Telegram/SourceFiles/history/history_item_text.cpp index 715306e9e..a21fb3460 100644 --- a/Telegram/SourceFiles/history/history_item_text.cpp +++ b/Telegram/SourceFiles/history/history_item_text.cpp @@ -22,12 +22,12 @@ TextForMimeData WrapAsReply( const auto name = to->author()->name; auto result = TextForMimeData(); result.reserve( - lang(lng_in_reply_to).size() + tr::lng_in_reply_to(tr::now).size() + name.size() + 4 + text.expanded.size()); return result.append('[' - ).append(lang(lng_in_reply_to) + ).append(tr::lng_in_reply_to(tr::now) ).append(' ' ).append(name ).append(qstr("]\n") @@ -123,6 +123,6 @@ TextForMimeData HistoryGroupText(not_null group) { return (++first == end) ? result : TextForMimeData(); }(); return WrapAsItem(group->items.back(), Data::WithCaptionClipboardText( - lang(lng_in_dlg_album), + tr::lng_in_dlg_album(tr::now), std::move(caption))); } diff --git a/Telegram/SourceFiles/history/history_location_manager.cpp b/Telegram/SourceFiles/history/history_location_manager.cpp index 7fc45011d..9b04fc3a0 100644 --- a/Telegram/SourceFiles/history/history_location_manager.cpp +++ b/Telegram/SourceFiles/history/history_location_manager.cpp @@ -42,7 +42,7 @@ QString LocationClickHandler::copyToClipboardText() const { } QString LocationClickHandler::copyToClipboardContextItemText() const { - return lang(lng_context_copy_link); + return tr::lng_context_copy_link(tr::now); } void LocationClickHandler::onClick(ClickContext context) const { diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 4dbf01a10..d2ae90cef 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -141,7 +141,7 @@ void FastShareMessage(not_null item) { QApplication::clipboard()->setText(link); - Ui::Toast::Show(lang(lng_share_game_link_copied)); + Ui::Toast::Show(tr::lng_share_game_link_copied(tr::now)); } } } @@ -183,7 +183,7 @@ void FastShareMessage(not_null item) { history->session().api().applyUpdates(updates); data->requests.remove(requestId); if (data->requests.empty()) { - Ui::Toast::Show(lang(lng_share_done)); + Ui::Toast::Show(tr::lng_share_done(tr::now)); Ui::hideLayer(); } }; @@ -276,7 +276,7 @@ QString GetErrorTextForForward( not_null peer, const HistoryItemsList &items) { if (!peer->canWrite()) { - return lang(lng_forward_cant); + return tr::lng_forward_cant(tr::now); } for (const auto item : items) { @@ -287,12 +287,10 @@ QString GetErrorTextForForward( } } } - const auto errorKey = Data::RestrictionErrorKey( + const auto error = Data::RestrictionError( peer, ChatRestriction::f_send_inline); - return (errorKey && HasInlineItems(items)) - ? lang(*errorKey) - : QString(); + return (error && HasInlineItems(items)) ? *error : QString(); } struct HistoryMessage::CreateConfig { @@ -893,7 +891,7 @@ void HistoryMessage::replaceBuyWithReceiptInMarkup() { for (auto &row : markup->rows) { for (auto &button : row) { if (button.type == HistoryMessageMarkupButton::Type::Buy) { - button.text = lang(lng_payments_receipt_button); + button.text = tr::lng_payments_receipt_button(tr::now); } } } diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 91538b46a..e384ee24c 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -88,7 +88,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareChannelCreate = [this](const MTPDmessageActionChannelCreate &action) { auto result = PreparedText {}; if (isPost()) { - result.text = lang(lng_action_created_channel); + 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))); @@ -99,7 +99,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareChatDeletePhoto = [this] { auto result = PreparedText{}; if (isPost()) { - result.text = lang(lng_action_removed_photo_channel); + 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()); @@ -124,7 +124,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareChatEditPhoto = [this](const MTPDmessageActionChatEditPhoto &action) { auto result = PreparedText{}; if (isPost()) { - result.text = lang(lng_action_changed_photo_channel); + 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()); @@ -146,7 +146,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { auto prepareScreenshotTaken = [this] { auto result = PreparedText{}; if (out()) { - result.text = lang(lng_action_you_took_screenshot); + 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()); @@ -176,24 +176,24 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { documents.push_back([&] { switch (type.type()) { case mtpc_secureValueTypePersonalDetails: - return lang(lng_action_secure_personal_details); + return tr::lng_action_secure_personal_details(tr::now); case mtpc_secureValueTypePassport: case mtpc_secureValueTypeDriverLicense: case mtpc_secureValueTypeIdentityCard: case mtpc_secureValueTypeInternalPassport: - return lang(lng_action_secure_proof_of_identity); + return tr::lng_action_secure_proof_of_identity(tr::now); case mtpc_secureValueTypeAddress: - return lang(lng_action_secure_address); + return tr::lng_action_secure_address(tr::now); case mtpc_secureValueTypeUtilityBill: case mtpc_secureValueTypeBankStatement: case mtpc_secureValueTypeRentalAgreement: case mtpc_secureValueTypePassportRegistration: case mtpc_secureValueTypeTemporaryRegistration: - return lang(lng_action_secure_proof_of_address); + return tr::lng_action_secure_proof_of_address(tr::now); case mtpc_secureValueTypePhone: - return lang(lng_action_secure_phone); + return tr::lng_action_secure_phone(tr::now); case mtpc_secureValueTypeEmail: - return lang(lng_action_secure_email); + return tr::lng_action_secure_email(tr::now); } Unexpected("Type in prepareSecureValuesSent."); }()); @@ -257,12 +257,12 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { return prepareContactSignUp(); }, [](const MTPDmessageActionPaymentSentMe &) { LOG(("API Error: messageActionPaymentSentMe received.")); - return PreparedText{ lang(lng_message_empty) }; + return PreparedText{ tr::lng_message_empty(tr::now) }; }, [](const MTPDmessageActionSecureValuesSentMe &) { LOG(("API Error: messageActionSecureValuesSentMe received.")); - return PreparedText{ lang(lng_message_empty) }; + return PreparedText{ tr::lng_message_empty(tr::now) }; }, [](const MTPDmessageActionEmpty &) { - return PreparedText{ lang(lng_message_empty) }; + return PreparedText{ tr::lng_message_empty(tr::now) }; }); setServiceText(messageText); @@ -393,10 +393,10 @@ HistoryService::PreparedText HistoryService::preparePinnedText() { } 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, lang(lng_contacts_loading))); + result.text = lng_action_pinned_media(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, lang(lng_deleted_message)); + result.text = lng_action_pinned_media(lt_from, fromLinkText(), lt_media, tr::lng_deleted_message(tr::now)); } return result; } @@ -420,9 +420,9 @@ HistoryService::PreparedText HistoryService::prepareGameScoreText() { return textcmdLink(result.links.size(), titleText); } } - return lang(lng_deleted_message); + return tr::lng_deleted_message(tr::now); } else if (gamescore && gamescore->msgId) { - return lang(lng_contacts_loading); + return tr::lng_contacts_loading(tr::now); } return QString(); }; @@ -474,9 +474,9 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() { return invoice->title; } } - return lang(lng_deleted_message); + return tr::lng_deleted_message(tr::now); } else if (payment && payment->msgId) { - return lang(lng_contacts_loading); + return tr::lng_contacts_loading(tr::now); } return QString(); }(); @@ -592,8 +592,8 @@ crl::time HistoryService::getSelfDestructIn(crl::time now) { if (selfdestruct->destructAt <= now) { auto text = [selfdestruct] { switch (selfdestruct->type) { - case HistoryServiceSelfDestruct::Type::Photo: return lang(lng_ttl_photo_expired); - case HistoryServiceSelfDestruct::Type::Video: return lang(lng_ttl_video_expired); + case HistoryServiceSelfDestruct::Type::Photo: return tr::lng_ttl_photo_expired(tr::now); + case HistoryServiceSelfDestruct::Type::Video: return tr::lng_ttl_video_expired(tr::now); } Unexpected("Type in HistoryServiceSelfDestruct::Type"); }; @@ -615,7 +615,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { Assert(photo.has_ttl_seconds()); setSelfDestruct(HistoryServiceSelfDestruct::Type::Photo, photo.vttl_seconds.v); if (out()) { - setServiceText({ lang(lng_ttl_photo_sent) }); + setServiceText({ tr::lng_ttl_photo_sent(tr::now) }); } else { auto result = PreparedText(); result.links.push_back(fromLink()); @@ -623,7 +623,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { setServiceText(std::move(result)); } } else { - setServiceText({ lang(lng_ttl_photo_expired) }); + setServiceText({ tr::lng_ttl_photo_expired(tr::now) }); } } break; case mtpc_messageMediaDocument: { @@ -632,7 +632,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { Assert(document.has_ttl_seconds()); setSelfDestruct(HistoryServiceSelfDestruct::Type::Video, document.vttl_seconds.v); if (out()) { - setServiceText({ lang(lng_ttl_video_sent) }); + setServiceText({ tr::lng_ttl_video_sent(tr::now) }); } else { auto result = PreparedText(); result.links.push_back(fromLink()); @@ -640,7 +640,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { setServiceText(std::move(result)); } } else { - setServiceText({ lang(lng_ttl_video_expired) }); + setServiceText({ tr::lng_ttl_video_expired(tr::now) }); } } break; @@ -767,7 +767,7 @@ HistoryService::PreparedText GenerateJoinedText( textcmdLink(1, self->name)); return result; } - return { lang(lng_action_you_joined) }; + return { tr::lng_action_you_joined(tr::now) }; } HistoryService *GenerateJoinedMessage( diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 48c29bf9f..d348852ca 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -252,15 +252,15 @@ HistoryWidget::HistoryWidget( ? object_ptr(this, &session()) : nullptr) , _send(this) -, _unblock(this, lang(lng_unblock_button).toUpper(), st::historyUnblock) -, _botStart(this, lang(lng_bot_start).toUpper(), st::historyComposeButton) +, _unblock(this, tr::lng_unblock_button(tr::now).toUpper(), st::historyUnblock) +, _botStart(this, tr::lng_bot_start(tr::now).toUpper(), st::historyComposeButton) , _joinChannel( this, - lang(lng_profile_join_channel).toUpper(), + tr::lng_profile_join_channel(tr::now).toUpper(), st::historyComposeButton) , _muteUnmute( this, - lang(lng_channel_mute).toUpper(), + tr::lng_channel_mute(tr::now).toUpper(), st::historyComposeButton) , _discuss(SetupDiscussButton(this, controller)) , _attachToggle(this, st::historyAttach) @@ -273,7 +273,7 @@ HistoryWidget::HistoryWidget( st::historyComposeField, Ui::InputField::Mode::MultiLine, tr::lng_message_ph()) -, _recordCancelWidth(st::historyRecordFont->width(lang(lng_record_cancel))) +, _recordCancelWidth(st::historyRecordFont->width(tr::lng_record_cancel(tr::now))) , _recordingAnimation([=](crl::time now) { return recordingAnimationCallback(now); }) @@ -1693,16 +1693,16 @@ void HistoryWidget::showHistory( } if (_peer) { - _unblock->setText(lang((_peer->isUser() + _unblock->setText(((_peer->isUser() && _peer->asUser()->isBot() && !_peer->asUser()->isSupport()) - ? lng_restart_button - : lng_unblock_button).toUpper()); + ? tr::lng_restart_button(tr::now) + : tr::lng_unblock_button(tr::now)).toUpper()); if (const auto channel = _peer->asChannel()) { channel->updateFull(); - _joinChannel->setText(lang(channel->isMegagroup() - ? lng_profile_join_group - : lng_profile_join_channel).toUpper()); + _joinChannel->setText((channel->isMegagroup() + ? tr::lng_profile_join_group(tr::now) + : tr::lng_profile_join_channel(tr::now)).toUpper()); } } @@ -1841,9 +1841,9 @@ void HistoryWidget::updateFieldSubmitSettings() { void HistoryWidget::updateNotifyControls() { if (!_peer || !_peer->isChannel()) return; - _muteUnmute->setText(lang(_history->mute() - ? lng_channel_unmute - : lng_channel_mute).toUpper()); + _muteUnmute->setText((_history->mute() + ? tr::lng_channel_unmute(tr::now) + : tr::lng_channel_mute(tr::now)).toUpper()); if (!session().data().notifySilentPostsUnknown(_peer)) { if (_silent) { _silent->setChecked(session().data().notifySilentPosts(_peer)); @@ -1878,9 +1878,9 @@ bool HistoryWidget::canWriteMessage() const { return true; } -std::optional HistoryWidget::writeRestrictionKey() const { +std::optional HistoryWidget::writeRestriction() const { return _peer - ? Data::RestrictionErrorKey(_peer, ChatRestriction::f_send_messages) + ? Data::RestrictionError(_peer, ChatRestriction::f_send_messages) : std::nullopt; } @@ -2096,7 +2096,7 @@ void HistoryWidget::refreshAboutProxyPromotion() { this, object_ptr( this, - lang(lng_proxy_sponsor_about), + tr::lng_proxy_sponsor_about(tr::now), st::historyAboutProxy), st::historyAboutProxyPadding); } @@ -2178,7 +2178,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId || error.type() == qstr("USER_BANNED_IN_CHANNEL")) { auto was = _peer; controller()->showBackFromStack(); - Ui::show(Box(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); + Ui::show(Box((was && was->isMegagroup()) ? tr::lng_group_not_accessible(tr::now) : tr::lng_channel_not_accessible(tr::now))); return true; } @@ -2714,7 +2714,7 @@ void HistoryWidget::saveEditMsg() { } return; } else if (!left.text.isEmpty()) { - Ui::show(Box(lang(lng_edit_too_long))); + Ui::show(Box(tr::lng_edit_too_long(tr::now))); return; } @@ -2768,14 +2768,14 @@ bool HistoryWidget::saveEditMsgFail(History *history, const RPCError &error, mtp const auto &err = error.type(); if (err == qstr("MESSAGE_ID_INVALID") || err == qstr("CHAT_ADMIN_REQUIRED") || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) { - Ui::show(Box(lang(lng_edit_error))); + Ui::show(Box(tr::lng_edit_error(tr::now))); } else if (err == qstr("MESSAGE_NOT_MODIFIED")) { cancelEdit(); } else if (err == qstr("MESSAGE_EMPTY")) { _field->selectAll(); _field->setFocus(); } else { - Ui::show(Box(lang(lng_edit_error))); + Ui::show(Box(tr::lng_edit_error(tr::now))); } update(); return true; @@ -3005,16 +3005,16 @@ bool HistoryWidget::recordingAnimationCallback(crl::time now) { void HistoryWidget::chooseAttach() { if (!_peer || !_peer->canWrite()) { return; - } else if (const auto key = Data::RestrictionErrorKey( + } else if (const auto error = Data::RestrictionError( _peer, ChatRestriction::f_send_media)) { - Ui::show(Box(lang(*key))); + Ui::show(Box(*error)); return; } auto filter = FileDialog::AllFilesFilter() + qsl(";;Image files (*") + cImgExtensions().join(qsl(" *")) + qsl(")"); - FileDialog::GetOpenPaths(this, lang(lng_choose_files), filter, crl::guard(this, [this](FileDialog::OpenResult &&result) { + FileDialog::GetOpenPaths(this, tr::lng_choose_files(tr::now), filter, crl::guard(this, [this](FileDialog::OpenResult &&result) { if (result.paths.isEmpty() && result.remoteContent.isEmpty()) { return; } @@ -3114,11 +3114,11 @@ void HistoryWidget::leaveToChildEvent(QEvent *e, QWidget *child) { // e -- from } void HistoryWidget::recordStartCallback() { - const auto errorKey = _peer - ? Data::RestrictionErrorKey(_peer, ChatRestriction::f_send_media) + const auto error = _peer + ? Data::RestrictionError(_peer, ChatRestriction::f_send_media) : std::nullopt; - if (errorKey) { - Ui::show(Box(lang(*errorKey))); + if (error) { + Ui::show(Box(*error)); return; } else if (!Media::Capture::instance()->available()) { return; @@ -3400,18 +3400,18 @@ void HistoryWidget::updateDragAreas() { _attachDragPhoto->otherLeave(); break; case DragState::Files: - _attachDragDocument->setText(lang(lng_drag_files_here), lang(lng_drag_to_send_files)); + _attachDragDocument->setText(tr::lng_drag_files_here(tr::now), tr::lng_drag_to_send_files(tr::now)); _attachDragDocument->otherEnter(); _attachDragPhoto->hideFast(); break; case DragState::PhotoFiles: - _attachDragDocument->setText(lang(lng_drag_images_here), lang(lng_drag_to_send_no_compression)); - _attachDragPhoto->setText(lang(lng_drag_photos_here), lang(lng_drag_to_send_quick)); + _attachDragDocument->setText(tr::lng_drag_images_here(tr::now), tr::lng_drag_to_send_no_compression(tr::now)); + _attachDragPhoto->setText(tr::lng_drag_photos_here(tr::now), tr::lng_drag_to_send_quick(tr::now)); _attachDragDocument->otherEnter(); _attachDragPhoto->otherEnter(); break; case DragState::Image: - _attachDragPhoto->setText(lang(lng_drag_images_here), lang(lng_drag_to_send_quick)); + _attachDragPhoto->setText(tr::lng_drag_images_here(tr::now), tr::lng_drag_to_send_quick(tr::now)); _attachDragDocument->hideFast(); _attachDragPhoto->otherEnter(); break; @@ -3921,15 +3921,15 @@ void HistoryWidget::updateFieldPlaceholder() { bool HistoryWidget::showSendingFilesError( const Storage::PreparedList &list) const { const auto text = [&] { - const auto errorKey = _peer - ? Data::RestrictionErrorKey( + const auto error = _peer + ? Data::RestrictionError( _peer, ChatRestriction::f_send_media) : std::nullopt; - if (errorKey) { - return lang(*errorKey); + if (error) { + return *error; } else if (!canWriteMessage()) { - return lang(lng_forward_send_files_cant); + return tr::lng_forward_send_files_cant(tr::now); } using Error = Storage::PreparedList::Error; switch (list.error) { @@ -3943,7 +3943,7 @@ bool HistoryWidget::showSendingFilesError( lt_name, list.errorData); } - return lang(lng_forward_send_files_cant); + return tr::lng_forward_send_files_cant(tr::now); }(); if (text.isEmpty()) { return false; @@ -4743,7 +4743,7 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S } else { if (editingMessage() || _canSendMessages) { newScrollHeight -= (_field->height() + 2 * st::historySendPadding); - } else if (writeRestrictionKey().has_value()) { + } else if (writeRestriction().has_value()) { newScrollHeight -= _unblock->height(); } if (_editMsgId || replyToId() || readyToForward() || (_previewData && _previewData->pendingTill >= 0)) { @@ -5400,11 +5400,11 @@ void HistoryWidget::destroyPinnedBar() { bool HistoryWidget::sendExistingDocument( not_null document, TextWithEntities caption) { - const auto errorKey = _peer - ? Data::RestrictionErrorKey(_peer, ChatRestriction::f_send_stickers) + const auto error = _peer + ? Data::RestrictionError(_peer, ChatRestriction::f_send_stickers) : std::nullopt; - if (errorKey) { - Ui::show(Box(lang(*errorKey)), LayerOption::KeepOther); + if (error) { + Ui::show(Box(*error), LayerOption::KeepOther); return false; } else if (!_peer || !_peer->canWrite()) { return false; @@ -5435,11 +5435,11 @@ bool HistoryWidget::sendExistingDocument( bool HistoryWidget::sendExistingPhoto( not_null photo, TextWithEntities caption) { - const auto errorKey = _peer - ? Data::RestrictionErrorKey(_peer, ChatRestriction::f_send_media) + const auto error = _peer + ? Data::RestrictionError(_peer, ChatRestriction::f_send_media) : std::nullopt; - if (errorKey) { - Ui::show(Box(lang(*errorKey)), LayerOption::KeepOther); + if (error) { + Ui::show(Box(*error), LayerOption::KeepOther); return false; } else if (!_peer || !_peer->canWrite()) { return false; @@ -5562,10 +5562,10 @@ void HistoryWidget::replyToMessage(not_null item) { } if (item->history() == _migrated) { if (item->serviceMsg()) { - Ui::show(Box(lang(lng_reply_cant))); + Ui::show(Box(tr::lng_reply_cant(tr::now))); } else { const auto itemId = item->fullId(); - Ui::show(Box(lang(lng_reply_cant_forward), lang(lng_selected_forward), crl::guard(this, [=] { + Ui::show(Box(tr::lng_reply_cant_forward(tr::now), tr::lng_selected_forward(tr::now), crl::guard(this, [=] { App::main()->setForwardDraft( _peer->id, { 1, itemId }); @@ -5683,7 +5683,7 @@ void HistoryWidget::unpinMessage(FullMsgId itemId) { return; } - Ui::show(Box(lang(lng_pinned_unpin_sure), lang(lng_pinned_unpin), crl::guard(this, [=] { + Ui::show(Box(tr::lng_pinned_unpin_sure(tr::now), tr::lng_pinned_unpin(tr::now), crl::guard(this, [=] { peer->clearPinnedMessage(); Ui::hideLayer(); @@ -5944,7 +5944,7 @@ void HistoryWidget::updatePreview() { if (_previewData->pendingTill) { _previewTitle.setText( st::msgNameStyle, - lang(lng_preview_loading), + tr::lng_preview_loading(tr::now), Ui::NameTextOptions()); #ifndef OS_MAC_OLD auto linkText = _previewLinks.splitRef(' ').at(0).toString(); @@ -5979,9 +5979,9 @@ void HistoryWidget::updatePreview() { } if (title.isEmpty()) { if (_previewData->document) { - title = lang(lng_attach_file); + title = tr::lng_attach_file(tr::now); } else if (_previewData->photo) { - title = lang(lng_attach_photo); + title = tr::lng_attach_photo(tr::now); } } _previewTitle.setText( @@ -6103,9 +6103,9 @@ void HistoryWidget::escape() { if (_replyEditMsg && PrepareEditText(_replyEditMsg) != _field->getTextWithTags()) { Ui::show(Box( - lang(lng_cancel_edit_post_sure), - lang(lng_cancel_edit_post_yes), - lang(lng_cancel_edit_post_no), + tr::lng_cancel_edit_post_sure(tr::now), + tr::lng_cancel_edit_post_yes(tr::now), + tr::lng_cancel_edit_post_no(tr::now), crl::guard(this, [this] { if (_editMsgId) { cancelEdit(); @@ -6362,7 +6362,7 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) { } else { p.setFont(st::msgDateFont); p.setPen(st::historyComposeAreaFgService); - p.drawText(replyLeft, backy + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(lang(lng_profile_loading), width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right())); + p.drawText(replyLeft, backy + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(tr::lng_profile_loading(tr::now), width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right())); } } } else if (hasForward) { @@ -6435,7 +6435,7 @@ void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int } p.setFont(st::msgServiceNameFont); - p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), lang(lng_edit_message)); + p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), tr::lng_edit_message(tr::now)); if (!_replyEditMsg || _replyEditMsg->history()->peer->isSelf()) return; @@ -6466,7 +6466,7 @@ void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int if (!editTimeLeftText.isEmpty()) { p.setFont(st::normalFont); p.setPen(st::historyComposeAreaFgService); - p.drawText(left + st::msgServiceNameFont->width(lang(lng_edit_message)) + st::normalFont->spacew, top + st::msgReplyPadding.top() + st::msgServiceNameFont->ascent, editTimeLeftText); + p.drawText(left + st::msgServiceNameFont->width(tr::lng_edit_message(tr::now)) + st::normalFont->spacew, top + st::msgReplyPadding.top() + st::msgServiceNameFont->ascent, editTimeLeftText); } } @@ -6491,7 +6491,7 @@ void HistoryWidget::drawRecording(Painter &p, float64 recordActive) { int32 right = width() - _send->width(); p.setPen(anim::pen(st::historyRecordCancel, st::historyRecordCancelActive, 1. - recordActive)); - p.drawText(left + (right - left - _recordCancelWidth) / 2, _attachToggle->y() + st::historyRecordTextTop + st::historyRecordFont->ascent, lang(lng_record_cancel)); + p.drawText(left + (right - left - _recordCancelWidth) / 2, _attachToggle->y() + st::historyRecordTextTop + st::historyRecordFont->ascent, tr::lng_record_cancel(tr::now)); } void HistoryWidget::drawPinnedBar(Painter &p) { @@ -6518,7 +6518,7 @@ void HistoryWidget::drawPinnedBar(Painter &p) { } p.setPen(st::historyReplyNameFg); p.setFont(st::msgServiceNameFont); - p.drawText(left, top + st::msgServiceNameFont->ascent, lang((media && media->poll()) ? lng_pinned_poll : lng_pinned_message)); + p.drawText(left, top + st::msgServiceNameFont->ascent, (media && media->poll()) ? tr::lng_pinned_poll(tr::now) : tr::lng_pinned_message(tr::now)); p.setPen(st::historyComposeAreaFg); p.setTextPalette(st::historyComposeAreaPalette); @@ -6527,7 +6527,7 @@ void HistoryWidget::drawPinnedBar(Painter &p) { } else { p.setFont(st::msgDateFont); p.setPen(st::historyComposeAreaFgService); - p.drawText(left, top + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(lang(lng_profile_loading), width() - left - _pinnedBar->cancel->width() - st::msgReplyPadding.right())); + p.drawText(left, top + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(tr::lng_profile_loading(tr::now), width() - left - _pinnedBar->cancel->width() - st::msgReplyPadding.right())); } } @@ -6577,8 +6577,8 @@ void HistoryWidget::paintEvent(QPaintEvent *e) { if (!_send->isHidden() && _recording) { drawRecording(p, _send->recordActiveRatio()); } - } else if (const auto errorKey = writeRestrictionKey()) { - drawRestrictedWrite(p, lang(*errorKey)); + } else if (const auto error = writeRestriction()) { + drawRestrictedWrite(p, *error); } if (_aboutProxyPromotion) { p.fillRect(_aboutProxyPromotion->geometry(), st::historyReplyBg); @@ -6587,7 +6587,7 @@ void HistoryWidget::paintEvent(QPaintEvent *e) { drawPinnedBar(p); } } else { - const auto w = st::msgServiceFont->width(lang(lng_willbe_history)) + const auto w = st::msgServiceFont->width(tr::lng_willbe_history(tr::now)) + st::msgPadding.left() + st::msgPadding.right(); const auto h = st::msgServiceFont->height @@ -6607,7 +6607,7 @@ void HistoryWidget::paintEvent(QPaintEvent *e) { p.setPen(st::msgServiceFg); p.setFont(st::msgServiceFont->f); - p.drawTextLeft(tr.left() + st::msgPadding.left(), tr.top() + st::msgServicePadding.top(), width(), lang(lng_willbe_history)); + p.drawTextLeft(tr.left() + st::msgPadding.left(), tr.top() + st::msgServicePadding.top(), width(), tr::lng_willbe_history(tr::now)); } } diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 65b787619..960fdf455 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -453,7 +453,7 @@ private: void checkTabbedSelectorToggleTooltip(); bool canWriteMessage() const; - std::optional writeRestrictionKey() const; + std::optional writeRestriction() const; void orderWidgets(); void clearInlineBot(); diff --git a/Telegram/SourceFiles/history/media/history_media_contact.cpp b/Telegram/SourceFiles/history/media/history_media_contact.cpp index 3a271f32d..b60c4b955 100644 --- a/Telegram/SourceFiles/history/media/history_media_contact.cpp +++ b/Telegram/SourceFiles/history/media/history_media_contact.cpp @@ -109,10 +109,10 @@ QSize HistoryContact::countOptimalSize() { } if (_contact && _contact->isContact()) { _linkl = sendMessageClickHandler(_contact); - _link = lang(lng_profile_send_message).toUpper(); + _link = tr::lng_profile_send_message(tr::now).toUpper(); } else if (_userId) { _linkl = addContactClickHandler(_parent->data()); - _link = lang(lng_profile_add_contact).toUpper(); + _link = tr::lng_profile_add_contact(tr::now).toUpper(); } _linkw = _link.isEmpty() ? 0 : st::semiboldFont->width(_link); diff --git a/Telegram/SourceFiles/history/media/history_media_document.cpp b/Telegram/SourceFiles/history/media/history_media_document.cpp index 313d10015..751fd1673 100644 --- a/Telegram/SourceFiles/history/media/history_media_document.cpp +++ b/Telegram/SourceFiles/history/media/history_media_document.cpp @@ -672,15 +672,15 @@ void HistoryDocument::setStatusSize(int newSize, qint64 realDuration) const { HistoryFileMedia::setStatusSize(newSize, _data->size, duration, realDuration); if (auto thumbed = Get()) { if (_statusSize == FileStatusSizeReady) { - thumbed->_link = lang(lng_media_download).toUpper(); + thumbed->_link = tr::lng_media_download(tr::now).toUpper(); } else if (_statusSize == FileStatusSizeLoaded) { - thumbed->_link = lang(lng_media_open_with).toUpper(); + thumbed->_link = tr::lng_media_open_with(tr::now).toUpper(); } else if (_statusSize == FileStatusSizeFailed) { - thumbed->_link = lang(lng_media_download).toUpper(); + thumbed->_link = tr::lng_media_download(tr::now).toUpper(); } else if (_statusSize >= 0) { - thumbed->_link = lang(lng_media_cancel).toUpper(); + thumbed->_link = tr::lng_media_cancel(tr::now).toUpper(); } else { - thumbed->_link = lang(lng_media_open_with).toUpper(); + thumbed->_link = tr::lng_media_open_with(tr::now).toUpper(); } thumbed->_linkw = st::semiboldFont->width(thumbed->_link); } diff --git a/Telegram/SourceFiles/history/media/history_media_file.cpp b/Telegram/SourceFiles/history/media/history_media_file.cpp index 8c06f09d6..1739e8b20 100644 --- a/Telegram/SourceFiles/history/media/history_media_file.cpp +++ b/Telegram/SourceFiles/history/media/history_media_file.cpp @@ -59,7 +59,7 @@ void HistoryFileMedia::setStatusSize(int newSize, int fullSize, int duration, qi } else if (_statusSize == FileStatusSizeLoaded) { _statusText = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize)); } else if (_statusSize == FileStatusSizeFailed) { - _statusText = lang(lng_attach_failed); + _statusText = tr::lng_attach_failed(tr::now); } else if (_statusSize >= 0) { _statusText = formatDownloadText(_statusSize, fullSize); } else { diff --git a/Telegram/SourceFiles/history/media/history_media_game.cpp b/Telegram/SourceFiles/history/media/history_media_game.cpp index 19a1554cb..70a601da3 100644 --- a/Telegram/SourceFiles/history/media/history_media_game.cpp +++ b/Telegram/SourceFiles/history/media/history_media_game.cpp @@ -123,7 +123,7 @@ QSize HistoryGame::countOptimalSize() { minHeight += padding.top() + padding.bottom(); if (!_gameTagWidth) { - _gameTagWidth = st::msgDateFont->width(lang(lng_game_tag).toUpper()); + _gameTagWidth = st::msgDateFont->width(tr::lng_game_tag(tr::now).toUpper()); } return { maxWidth, minHeight }; } @@ -262,7 +262,7 @@ void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, crl: p.setFont(st::msgDateFont); p.setPen(st::msgDateImgFg); - p.drawTextLeft(gameX + st::msgDateImgPadding.x(), gameY + st::msgDateImgPadding.y(), pixwidth, lang(lng_game_tag).toUpper()); + p.drawTextLeft(gameX + st::msgDateImgPadding.x(), gameY + st::msgDateImgPadding.y(), pixwidth, tr::lng_game_tag(tr::now).toUpper()); p.translate(-attachLeft, -attachTop); } diff --git a/Telegram/SourceFiles/history/media/history_media_gif.cpp b/Telegram/SourceFiles/history/media/history_media_gif.cpp index 5115f43c1..cbac34066 100644 --- a/Telegram/SourceFiles/history/media/history_media_gif.cpp +++ b/Telegram/SourceFiles/history/media/history_media_gif.cpp @@ -71,7 +71,7 @@ QSize HistoryGif::countOptimalSize() { } if (_gif && _gif->state() == Media::Clip::State::Error) { if (!_gif->autoplay()) { - Ui::show(Box(lang(lng_gif_error))); + Ui::show(Box(tr::lng_gif_error(tr::now))); } setClipReader(Media::Clip::ReaderPointer::Bad()); } @@ -713,7 +713,7 @@ int HistoryGif::additionalWidth() const { QString HistoryGif::mediaTypeString() const { return _data->isVideoMessage() - ? lang(lng_in_dlg_video_message) + ? tr::lng_in_dlg_video_message(tr::now) : qsl("GIF"); } diff --git a/Telegram/SourceFiles/history/media/history_media_invoice.cpp b/Telegram/SourceFiles/history/media/history_media_invoice.cpp index b3a164952..f334215ac 100644 --- a/Telegram/SourceFiles/history/media/history_media_invoice.cpp +++ b/Telegram/SourceFiles/history/media/history_media_invoice.cpp @@ -45,13 +45,13 @@ void HistoryInvoice::fillFromData(not_null invoice) { auto labelText = [&] { if (invoice->receiptMsgId) { if (invoice->isTest) { - return lang(lng_payments_receipt_label_test); + return tr::lng_payments_receipt_label_test(tr::now); } - return lang(lng_payments_receipt_label); + return tr::lng_payments_receipt_label(tr::now); } else if (invoice->isTest) { - return lang(lng_payments_invoice_label_test); + return tr::lng_payments_invoice_label_test(tr::now); } - return lang(lng_payments_invoice_label); + return tr::lng_payments_invoice_label(tr::now); }; auto statusText = TextWithEntities { FillAmountAndCurrency(invoice->amount, invoice->currency), diff --git a/Telegram/SourceFiles/history/media/history_media_poll.cpp b/Telegram/SourceFiles/history/media/history_media_poll.cpp index 4d7f8cc5b..f4f3dca92 100644 --- a/Telegram/SourceFiles/history/media/history_media_poll.cpp +++ b/Telegram/SourceFiles/history/media/history_media_poll.cpp @@ -304,7 +304,7 @@ void HistoryPoll::updateTexts() { _closed = _poll->closed; _subtitle.setText( st::msgDateTextStyle, - lang(_closed ? lng_polls_closed : lng_polls_anonymous)); + _closed ? tr::lng_polls_closed(tr::now) : tr::lng_polls_anonymous(tr::now)); } updateAnswers(); @@ -386,8 +386,8 @@ void HistoryPoll::updateTotalVotes() { } _totalVotes = _poll->totalVoters; const auto string = !_totalVotes - ? lang(lng_polls_votes_none) - : lng_polls_votes_count(lt_count_short, _totalVotes); + ? tr::lng_polls_votes_none(tr::now) + : tr::lng_polls_votes_count(tr::now, lt_count_short, _totalVotes); _totalVotesLabel.setText(st::msgDateTextStyle, string); } @@ -811,7 +811,7 @@ TextState HistoryPoll::textState(QPoint point, StateRequest request) const { if (request.flags & Flag::LookupCustomTooltip) { result.customTooltipText = answer.votes ? lng_polls_votes_count(lt_count_decimal, answer.votes) - : lang(lng_polls_votes_none); + : tr::lng_polls_votes_none(tr::now); } } return result; diff --git a/Telegram/SourceFiles/history/media/history_media_web_page.cpp b/Telegram/SourceFiles/history/media/history_media_web_page.cpp index ceed5bb7e..e428cb6ff 100644 --- a/Telegram/SourceFiles/history/media/history_media_web_page.cpp +++ b/Telegram/SourceFiles/history/media/history_media_web_page.cpp @@ -726,7 +726,7 @@ int HistoryWebPage::bottomInfoPadding() const { QString HistoryWebPage::displayedSiteName() const { return (_data->document && _data->document->isWallPaper()) - ? lang(lng_media_chat_background) + ? tr::lng_media_chat_background(tr::now) : _data->siteName; } diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 4951b3d7b..e3b19472e 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -66,15 +66,15 @@ ContactStatus::Bar::Bar(QWidget *parent, const QString &name) st::historyContactStatusButton) , _block( this, - lang(lng_new_contact_block).toUpper(), + tr::lng_new_contact_block(tr::now).toUpper(), st::historyContactStatusBlock) , _share( this, - lang(lng_new_contact_share).toUpper(), + tr::lng_new_contact_share(tr::now).toUpper(), st::historyContactStatusButton) , _report( this, - lang(lng_report_spam_and_leave).toUpper(), + tr::lng_report_spam_and_leave(tr::now).toUpper(), st::historyContactStatusBlock) , _close(this, st::historyReplyCancel) { resize(_close->size()); @@ -87,7 +87,7 @@ void ContactStatus::Bar::showState(State state) { _report->setVisible(state == State::ReportSpam); _add->setText((state == State::Add) ? lng_new_contact_add_name(lt_user, _name).toUpper() - : lang(lng_new_contact_add).toUpper()); + : tr::lng_new_contact_add(tr::now).toUpper()); updateButtonsGeometry(); } @@ -344,7 +344,7 @@ void ContactStatus::setupReportHandler(not_null peer) { peer->session().api().deleteConversation(peer, false); }); - Ui::Toast::Show(lang(lng_report_spam_done)); + Ui::Toast::Show(tr::lng_report_spam_done(tr::now)); // Destroys _bar. _window->sessionController()->showBackFromStack(); @@ -352,12 +352,12 @@ void ContactStatus::setupReportHandler(not_null peer) { if (const auto user = peer->asUser()) { peer->session().api().blockUser(user); } - const auto text = lang((peer->isChat() || peer->isMegagroup()) - ? lng_report_spam_sure_group - : lng_report_spam_sure_channel); + const auto text = ((peer->isChat() || peer->isMegagroup()) + ? tr::lng_report_spam_sure_group + : tr::lng_report_spam_sure_channel)(tr::now); _window->show(Box( text, - lang(lng_report_spam_ok), + tr::lng_report_spam_ok(tr::now), st::attentionBoxButton, callback)); }, _bar.lifetime()); diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index db9efbde5..6549381d9 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -48,7 +48,7 @@ constexpr auto kExportLocalTimeout = crl::time(1000); // if (const auto channel = peer->asChannel()) { // const auto grouped = (channel->feed() != nullptr); // menu->addAction( // #feed -// lang(grouped ? lng_feed_ungroup : lng_feed_group), +// grouped ? tr::lng_feed_ungroup(tr::now) : tr::lng_feed_group(tr::now), // [=] { Window::ToggleChannelGrouping(channel, !grouped); }); // } //} @@ -60,7 +60,7 @@ void SavePhotoToFile(not_null photo) { FileDialog::GetWritePath( Core::App().getFileDialogParent(), - lang(lng_save_photo), + tr::lng_save_photo(tr::now), qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter(), filedialogDefaultName(qsl("photo"), qsl(".jpg")), crl::guard(&Auth(), [=](const QString &result) { @@ -95,12 +95,12 @@ void AddPhotoActions( not_null menu, not_null photo) { menu->addAction( - lang(lng_context_save_image), + tr::lng_context_save_image(tr::now), App::LambdaDelayed( st::defaultDropdownMenu.menu.ripple.hideDuration, &Auth(), [=] { SavePhotoToFile(photo); })); - menu->addAction(lang(lng_context_copy_image), [=] { + menu->addAction(tr::lng_context_copy_image(tr::now), [=] { CopyImage(photo); }); } @@ -133,16 +133,17 @@ void AddSaveDocumentAction( document, DocumentSaveClickHandler::Mode::ToNewFile); }; + menu->addAction( - lang(document->isVideoFile() - ? lng_context_save_video + (document->isVideoFile() + ? tr::lng_context_save_video(tr::now) : (document->isVoiceMessage() - ? lng_context_save_audio + ? tr::lng_context_save_audio(tr::now) : (document->isAudioFile() - ? lng_context_save_audio_file + ? tr::lng_context_save_audio_file(tr::now) : (document->sticker() - ? lng_context_save_image - : lng_context_save_file)))), + ? tr::lng_context_save_image(tr::now) + : tr::lng_context_save_file(tr::now))))), App::LambdaDelayed( st::defaultDropdownMenu.menu.ripple.hideDuration, &Auth(), @@ -154,14 +155,14 @@ void AddDocumentActions( not_null document, FullMsgId contextId) { if (document->loading()) { - menu->addAction(lang(lng_context_cancel_download), [=] { + menu->addAction(tr::lng_context_cancel_download(tr::now), [=] { document->cancel(); }); return; } if (document->loaded() && document->isGifv()) { if (!cAutoPlayGif()) { - menu->addAction(lang(lng_context_open_gif), [=] { + menu->addAction(tr::lng_context_open_gif(tr::now), [=] { OpenGif(contextId); }); } @@ -169,22 +170,22 @@ void AddDocumentActions( if (document->sticker() && document->sticker()->set.type() != mtpc_inputStickerSetEmpty) { menu->addAction( - lang(document->isStickerSetInstalled() - ? lng_context_pack_info - : lng_context_pack_add), + (document->isStickerSetInstalled() + ? tr::lng_context_pack_info(tr::now) + : tr::lng_context_pack_add(tr::now)), [=] { ShowStickerPackInfo(document); }); menu->addAction( - lang(Stickers::IsFaved(document) - ? lng_faved_stickers_remove - : lng_faved_stickers_add), + (Stickers::IsFaved(document) + ? tr::lng_faved_stickers_remove(tr::now) + : tr::lng_faved_stickers_add(tr::now)), [=] { ToggleFavedSticker(document, contextId); }); } if (!document->filepath( DocumentData::FilePathResolve::Checked).isEmpty()) { menu->addAction( - lang(Platform::IsMac() - ? lng_context_show_in_finder - : lng_context_show_in_folder), + (Platform::IsMac() + ? tr::lng_context_show_in_finder(tr::now) + : tr::lng_context_show_in_folder(tr::now)), [=] { ShowInFolder(document); }); } AddSaveDocumentAction(menu, contextId, document); @@ -204,9 +205,9 @@ void AddPostLinkAction( } const auto itemId = item->fullId(); menu->addAction( - lang(item->history()->peer->isMegagroup() - ? lng_context_copy_link - : lng_context_copy_post_link), + (item->history()->peer->isMegagroup() + ? tr::lng_context_copy_link + : tr::lng_context_copy_post_link)(tr::now), [=] { CopyPostLink(itemId); }); } @@ -231,7 +232,7 @@ bool AddForwardSelectedAction( return false; } - menu->addAction(lang(lng_context_forward_selected), [=] { + menu->addAction(tr::lng_context_forward_selected(tr::now), [=] { const auto weak = make_weak(list); auto items = ExtractIdsList(request.selectedItems); Window::ShowForwardMessagesBox(std::move(items), [=] { @@ -264,7 +265,7 @@ bool AddForwardMessageAction( } } const auto itemId = item->fullId(); - menu->addAction(lang(lng_context_forward_msg), [=] { + menu->addAction(tr::lng_context_forward_msg(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { Window::ShowForwardMessagesBox(asGroup ? Auth().data().itemOrItsGroup(item) @@ -295,7 +296,7 @@ bool AddDeleteSelectedAction( return false; } - menu->addAction(lang(lng_context_delete_selected), [=] { + menu->addAction(tr::lng_context_delete_selected(tr::now), [=] { const auto weak = make_weak(list); auto items = ExtractIdsList(request.selectedItems); const auto box = Ui::show(Box(std::move(items))); @@ -329,7 +330,7 @@ bool AddDeleteMessageAction( } } const auto itemId = item->fullId(); - menu->addAction(lang(lng_context_delete_msg), [=] { + menu->addAction(tr::lng_context_delete_msg(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { if (asGroup) { if (const auto group = Auth().data().groups().find(item)) { @@ -367,7 +368,7 @@ bool AddClearSelectionAction( if (!request.overSelection || request.selectedItems.empty()) { return false; } - menu->addAction(lang(lng_context_clear_selection), [=] { + menu->addAction(tr::lng_context_clear_selection(tr::now), [=] { list->cancelSelection(); }); return true; @@ -385,7 +386,7 @@ bool AddSelectMessageAction( } const auto itemId = item->fullId(); const auto asGroup = (request.pointState != PointState::GroupPart); - menu->addAction(lang(lng_context_select_msg), [=] { + menu->addAction(tr::lng_context_select_msg(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { if (asGroup) { list->selectItemAsGroup(item); @@ -458,9 +459,9 @@ base::unique_qptr FillContextMenu( || !request.selectedText.empty(); if (request.overSelection) { - const auto text = lang(request.selectedItems.empty() - ? lng_context_copy_selected - : lng_context_copy_selected_items); + const auto text = request.selectedItems.empty() + ? tr::lng_context_copy_selected(tr::now) + : tr::lng_context_copy_selected_items(tr::now); result->addAction(text, [=] { SetClipboardText(list->getSelectedText()); }); @@ -490,7 +491,7 @@ base::unique_qptr FillContextMenu( } if (!link && (view->hasVisibleText() || mediaHasTextForCopy)) { const auto asGroup = (request.pointState != PointState::GroupPart); - result->addAction(lang(lng_context_copy_text), [=] { + result->addAction(tr::lng_context_copy_text(tr::now), [=] { if (const auto item = Auth().data().message(itemId)) { if (asGroup) { if (const auto group = Auth().data().groups().find(item)) { @@ -520,9 +521,9 @@ void CopyPostLink(FullMsgId itemId) { const auto channel = item->history()->peer->asChannel(); Assert(channel != nullptr); - Ui::Toast::Show(lang(channel->isPublic() - ? lng_channel_public_link_copied - : lng_context_about_private_link)); + Ui::Toast::Show(channel->isPublic() + ? tr::lng_channel_public_link_copied(tr::now) + : tr::lng_context_about_private_link(tr::now)); } void StopPoll(FullMsgId itemId) { @@ -533,9 +534,9 @@ void StopPoll(FullMsgId itemId) { } }; Ui::show(Box( - lang(lng_polls_stop_warning), - lang(lng_polls_stop_sure), - lang(lng_cancel), + tr::lng_polls_stop_warning(tr::now), + tr::lng_polls_stop_sure(tr::now), + tr::lng_cancel(tr::now), stop)); } diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 5b77f1bb9..51342c6d8 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -118,7 +118,7 @@ void UnreadBar::init(int newCount) { } count = newCount; text = /*(count == kCountUnknown) // #feed - ? lang(lng_unread_bar_some) + ? tr::lng_unread_bar_some(tr::now) : */lng_unread_bar(lt_count, count); width = st::semiboldFont->width(text); } diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 09d6fbd5a..1599ab3c4 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2248,7 +2248,7 @@ void ListWidget::mouseActionUpdate() { ClickHandlerPtr ListWidget::hiddenUserpicLink(FullMsgId id) { static const auto result = std::make_shared([] { - Ui::Toast::Show(lang(lng_forwarded_hidden)); + Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now)); }); return result; } diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 4d1b39371..21ed2c749 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -124,13 +124,13 @@ int KeyboardStyle::minButtonWidth( } QString MessageBadgeText(not_null message) { - return lang(message->hasAdminBadge() - ? lng_admin_badge - : lng_channel_badge); + return message->hasAdminBadge() + ? tr::lng_admin_badge(tr::now) + : tr::lng_channel_badge(tr::now); } QString FastReplyText() { - return lang(lng_fast_reply); + return tr::lng_fast_reply(tr::now); } void PaintBubble(Painter &p, QRect rect, int outerWidth, bool selected, bool outbg, RectPart tailSide) { @@ -899,7 +899,7 @@ bool Message::getStateFromName( && point.x() < availableLeft + availableWidth && point.x() < availableLeft + nameText->maxWidth()) { static const auto hidden = std::make_shared([] { - Ui::Toast::Show(lang(lng_forwarded_hidden)); + Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now)); }); outResult->link = from ? from->openLink() : hidden; return true; diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index dadfa2da6..de729b8b4 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -548,10 +548,10 @@ EmptyPainter::EmptyPainter(not_null history) : _history(history) { void EmptyPainter::fillAboutGroup() { const auto phrases = { - lang(lng_group_about1), - lang(lng_group_about2), - lang(lng_group_about3), - lang(lng_group_about4), + tr::lng_group_about1(tr::now), + tr::lng_group_about2(tr::now), + tr::lng_group_about3(tr::now), + tr::lng_group_about4(tr::now), }; const auto setText = [](Ui::Text::String &text, const QString &content) { text.setText( @@ -559,8 +559,8 @@ void EmptyPainter::fillAboutGroup() { content, Ui::NameTextOptions()); }; - setText(_header, lang(lng_group_about_header)); - setText(_text, lang(lng_group_about_text)); + setText(_header, tr::lng_group_about_header(tr::now)); + setText(_text, tr::lng_group_about_text(tr::now)); for (const auto &text : phrases) { _phrases.emplace_back(st::msgMinWidth); setText(_phrases.back(), 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 05821cb37..6f602e7e5 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -322,7 +322,7 @@ void TopBarWidget::paintTopBar(Painter &p) { width(), text); } else if (_activeChat.peer()->isSelf()) { - auto text = lang(lng_saved_messages); + auto text = tr::lng_saved_messages(tr::now); auto textWidth = st::historySavedFont->width(text); if (namewidth < textWidth) { text = st::historySavedFont->elided(text, namewidth); @@ -373,7 +373,7 @@ bool TopBarWidget::paintConnectingState( + st::topBarConnectingAnimation.size.width() + st::topBarConnectingSkip; p.setPen(st::historyStatusFg); - p.drawTextLeft(left, top, outerWidth, lang(lng_status_connecting)); + p.drawTextLeft(left, top, outerWidth, tr::lng_status_connecting(tr::now)); return true; } @@ -764,12 +764,12 @@ void TopBarWidget::updateOnlineDisplay() { } } else if (const auto chat = _activeChat.peer()->asChat()) { if (!chat->amIn()) { - text = lang(lng_chat_status_unaccessible); + text = tr::lng_chat_status_unaccessible(tr::now); } else if (chat->participants.empty()) { if (!_titlePeerText.isEmpty()) { text = _titlePeerText.toString(); } else if (chat->count <= 0) { - text = lang(lng_group_status); + text = tr::lng_group_status(tr::now); } else { text = lng_chat_status_members(lt_count_decimal, chat->count); } @@ -790,7 +790,7 @@ void TopBarWidget::updateOnlineDisplay() { } else if (chat->participants.size() > 0) { text = lng_chat_status_members(lt_count_decimal, chat->participants.size()); } else { - text = lang(lng_group_status); + text = tr::lng_group_status(tr::now); } } } else if (const auto channel = _activeChat.peer()->asChannel()) { @@ -816,12 +816,13 @@ void TopBarWidget::updateOnlineDisplay() { } else if (channel->membersCount() > 0) { text = lng_chat_status_members(lt_count_decimal, channel->membersCount()); } else { - text = lang(lng_group_status); + text = tr::lng_group_status(tr::now); } } else if (channel->membersCount() > 0) { text = lng_chat_status_members(lt_count_decimal, channel->membersCount()); + } else { - text = lang(channel->isMegagroup() ? lng_group_status : lng_channel_status); + text = channel->isMegagroup() ? tr::lng_group_status(tr::now) : tr::lng_channel_status(tr::now); } } if (_titlePeerText.toString() != text) { diff --git a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp index 4e76e2a3f..402d1eb06 100644 --- a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp +++ b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp @@ -81,7 +81,7 @@ std::unique_ptr ListController::createRow( } void ListController::prepare() { - setSearchNoResultsText(lang(lng_bot_groups_not_found)); + setSearchNoResultsText(tr::lng_bot_groups_not_found(tr::now)); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); delegate()->peerListSetTitle(tr::lng_profile_common_groups_section()); } diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 810b4d6f7..b0dd056f9 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -227,8 +227,8 @@ Dialogs::RowDescriptor WrapWidget::activeChat() const { //void WrapWidget::createTabs() { // _topTabs.create(this, st::infoTabs); // auto sections = QStringList(); -// sections.push_back(lang(lng_profile_info_section).toUpper()); -// sections.push_back(lang(lng_info_tab_media).toUpper()); +// sections.push_back(tr::lng_profile_info_section(tr::now).toUpper()); +// sections.push_back(tr::lng_info_tab_media(tr::now).toUpper()); // _topTabs->setSections(sections); // _topTabs->setActiveSection(static_cast(_tab)); // _topTabs->finishAnimating(); @@ -424,8 +424,8 @@ void WrapWidget::checkBeforeClose(Fn close) { }; if (_controller->canSaveChangesNow()) { Ui::show(Box( - lang(lng_settings_close_sure), - lang(lng_close), + tr::lng_settings_close_sure(tr::now), + tr::lng_close(tr::now), confirmed)); } else { confirmed(); diff --git a/Telegram/SourceFiles/info/media/info_media_empty_widget.cpp b/Telegram/SourceFiles/info/media/info_media_empty_widget.cpp index 9867c5b34..cee74a857 100644 --- a/Telegram/SourceFiles/info/media/info_media_empty_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_empty_widget.cpp @@ -49,30 +49,29 @@ void EmptyWidget::setType(Type type) { } void EmptyWidget::setSearchQuery(const QString &query) { - auto key = [&] { + _text->setText([&] { switch (_type) { case Type::Photo: - return lng_media_photo_empty; + return tr::lng_media_photo_empty(tr::now); case Type::Video: - return lng_media_video_empty; + return tr::lng_media_video_empty(tr::now); case Type::MusicFile: return query.isEmpty() - ? lng_media_song_empty - : lng_media_song_empty_search; + ? tr::lng_media_song_empty(tr::now) + : tr::lng_media_song_empty_search(tr::now); case Type::File: return query.isEmpty() - ? lng_media_file_empty - : lng_media_file_empty_search; + ? tr::lng_media_file_empty(tr::now) + : tr::lng_media_file_empty_search(tr::now); case Type::Link: return query.isEmpty() - ? lng_media_link_empty - : lng_media_link_empty_search; + ? tr::lng_media_link_empty(tr::now) + : tr::lng_media_link_empty_search(tr::now); case Type::RoundVoiceFile: - return lng_media_audio_empty; + return tr::lng_media_audio_empty(tr::now); } Unexpected("Bad type in EmptyWidget::setSearchQuery()"); - }(); - _text->setText(lang(key)); + }()); resizeToWidth(width()); } diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp index daf1c1a9b..0ccd361aa 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp @@ -140,9 +140,9 @@ void InnerWidget::createTypeButtons() { // this, // st::infoTabs)); // auto sections = QStringList(); -// sections.push_back(lang(lng_media_type_photos).toUpper()); -// sections.push_back(lang(lng_media_type_videos).toUpper()); -// sections.push_back(lang(lng_media_type_files).toUpper()); +// sections.push_back(tr::lng_media_type_photos(tr::now).toUpper()); +// sections.push_back(tr::lng_media_type_videos(tr::now).toUpper()); +// sections.push_back(tr::lng_media_type_files(tr::now).toUpper()); // _otherTabs->setSections(sections); // _otherTabs->setActiveSection(*TypeToTabIndex(type())); // _otherTabs->finishAnimating(); diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index 64eb48d15..70c61a949 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -1227,7 +1227,7 @@ void ListWidget::showContextMenu( const auto itemFullId = item->fullId(); _contextMenu = base::make_unique_q(this); _contextMenu->addAction( - lang(lng_context_to_msg), + tr::lng_context_to_msg(tr::now), [itemFullId] { if (auto item = Auth().data().message(itemFullId)) { Ui::showPeerHistoryAtItem(item); @@ -1254,7 +1254,7 @@ void ListWidget::showContextMenu( if (auto document = fileLink->document()) { if (document->loading()) { _contextMenu->addAction( - lang(lng_context_cancel_download), + tr::lng_context_cancel_download(tr::now), [document] { document->cancel(); }); @@ -1268,9 +1268,9 @@ void ListWidget::showContextMenu( File::ShowInFolder(filepath); }); _contextMenu->addAction( - lang(Platform::IsMac() - ? lng_context_show_in_finder - : lng_context_show_in_folder), + (Platform::IsMac() + ? tr::lng_context_show_in_finder(tr::now) + : tr::lng_context_show_in_folder(tr::now)), std::move(handler)); } auto handler = App::LambdaDelayed( @@ -1283,13 +1283,13 @@ void ListWidget::showContextMenu( DocumentSaveClickHandler::Mode::ToNewFile); }); _contextMenu->addAction( - lang(isVideo - ? lng_context_save_video + (isVideo + ? tr::lng_context_save_video(tr::now) : isVoice - ? lng_context_save_audio + ? tr::lng_context_save_audio(tr::now) : isAudio - ? lng_context_save_audio_file - : lng_context_save_file), + ? tr::lng_context_save_audio_file(tr::now) + : tr::lng_context_save_file(tr::now)), std::move(handler)); } } @@ -1307,20 +1307,20 @@ void ListWidget::showContextMenu( if (overSelected == SelectionState::OverSelectedItems) { if (canForwardAll()) { _contextMenu->addAction( - lang(lng_context_forward_selected), + tr::lng_context_forward_selected(tr::now), crl::guard(this, [this] { forwardSelected(); })); } if (canDeleteAll()) { _contextMenu->addAction( - lang(lng_context_delete_selected), + tr::lng_context_delete_selected(tr::now), crl::guard(this, [this] { deleteSelected(); })); } _contextMenu->addAction( - lang(lng_context_clear_selection), + tr::lng_context_clear_selection(tr::now), crl::guard(this, [this] { clearSelected(); })); @@ -1328,21 +1328,21 @@ void ListWidget::showContextMenu( if (overSelected != SelectionState::NotOverSelectedItems) { if (item->allowsForward()) { _contextMenu->addAction( - lang(lng_context_forward_msg), + tr::lng_context_forward_msg(tr::now), crl::guard(this, [this, universalId] { forwardItem(universalId); })); } if (item->canDelete()) { _contextMenu->addAction( - lang(lng_context_delete_msg), + tr::lng_context_delete_msg(tr::now), crl::guard(this, [this, universalId] { deleteItem(universalId); })); } } _contextMenu->addAction( - lang(lng_context_select_msg), + tr::lng_context_select_msg(tr::now), crl::guard(this, [this, universalId] { if (hasSelectedText()) { clearSelected(); diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 5cacb0188..df073ef4e 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -259,7 +259,7 @@ object_ptr DetailsFiller::setupInfo() { addInfoOneLine( tr::lng_info_mobile_label(), PhoneValue(user), - lang(lng_profile_copy_phone)); + tr::lng_profile_copy_phone(tr::now)); if (user->botInfo) { addInfoLine(tr::lng_info_about_label(), AboutValue(user)); } else { @@ -268,7 +268,7 @@ object_ptr DetailsFiller::setupInfo() { addInfoOneLine( tr::lng_info_username_label(), UsernameValue(user), - lang(lng_context_copy_mention)); + tr::lng_context_copy_mention(tr::now)); } else { auto linkText = LinkValue( _peer @@ -296,7 +296,7 @@ object_ptr DetailsFiller::setupInfo() { peer->userName()); if (!link.isEmpty()) { QApplication::clipboard()->setText(link); - Ui::Toast::Show(lang(lng_username_copied)); + Ui::Toast::Show(tr::lng_username_copied(tr::now)); } return false; }); diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index 16519ae19..157801fdf 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -136,15 +136,21 @@ auto OnlineStatusText(int count) { auto ChatStatusText(int fullCount, int onlineCount, bool isGroup) { if (onlineCount > 1 && onlineCount <= fullCount) { - return lng_chat_status_members_online( - lt_members_count, MembersStatusText(fullCount), - lt_online_count, OnlineStatusText(onlineCount)); + return tr::lng_chat_status_members_online( + tr::now, + lt_members_count, + MembersStatusText(fullCount), + lt_online_count, + OnlineStatusText(onlineCount)); } else if (fullCount > 0) { - return lng_chat_status_members(lt_count_decimal, fullCount); + return tr::lng_chat_status_members( + tr::now, + lt_count_decimal, + fullCount); } - return lang(isGroup - ? lng_group_status - : lng_channel_status); + return isGroup + ? tr::lng_group_status(tr::now) + : tr::lng_channel_status(tr::now); }; } // namespace @@ -247,7 +253,7 @@ Cover::Cover( _peer->updateFull(); _name->setSelectable(true); - _name->setContextCopyText(lang(lng_profile_copy_fullname)); + _name->setContextCopyText(tr::lng_profile_copy_fullname(tr::now)); if (!_peer->isMegagroup()) { _status->setAttribute(Qt::WA_TransparentForMouseEvents); @@ -366,7 +372,7 @@ void Cover::refreshStatusText() { : result; } else if (auto chat = _peer->asChat()) { if (!chat->amIn()) { - return lang(lng_chat_status_unaccessible); + return tr::lng_chat_status_unaccessible(tr::now); } auto fullCount = std::max( chat->count, @@ -380,7 +386,7 @@ void Cover::refreshStatusText() { channel->isMegagroup()); return hasMembersLink ? textcmdLink(1, result) : result; } - return lang(lng_chat_status_unaccessible); + return tr::lng_chat_status_unaccessible(tr::now); }(); _status->setRichText(statusText); if (hasMembersLink) { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index 5927a9c98..d59171352 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -608,7 +608,7 @@ void Video::initDimensions() { TextParseOptions titleOpts = { 0, _maxw, 2 * st::semiboldFont->height, Qt::LayoutDirectionAuto }; auto title = TextUtilities::SingleLine(_result->getLayoutTitle()); if (title.isEmpty()) { - title = lang(lng_media_video); + title = tr::lng_media_video(tr::now); } _title.setText(st::semiboldTextStyle, title, titleOpts); int32 titleHeight = qMin(_title.countHeight(_maxw), 2 * st::semiboldFont->height); @@ -926,7 +926,7 @@ void File::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 r } else if (_statusSize == FileStatusSizeLoaded) { _statusText = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize)); } else if (_statusSize == FileStatusSizeFailed) { - _statusText = lang(lng_attach_failed); + _statusText = tr::lng_attach_failed(tr::now); } else if (_statusSize >= 0) { _statusText = formatDownloadText(_statusSize, fullSize); } else { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_send_data.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_send_data.cpp index b4977fc9e..d258882a1 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_send_data.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_send_data.cpp @@ -64,10 +64,10 @@ void SendDataCommon::addToHistory( QString SendDataCommon::getErrorOnSend( const Result *owner, not_null history) const { - const auto errorKey = Data::RestrictionErrorKey( + const auto error = Data::RestrictionError( history->peer, ChatRestriction::f_send_messages); - return errorKey ? lang(*errorKey) : QString(); + return error.value_or(QString()); } SendDataCommon::SentMTPMessageFields SendText::getSentMessageFields() const { @@ -144,10 +144,10 @@ void SendPhoto::addToHistory( QString SendPhoto::getErrorOnSend( const Result *owner, not_null history) const { - const auto errorKey = Data::RestrictionErrorKey( + const auto error = Data::RestrictionError( history->peer, ChatRestriction::f_send_media); - return errorKey ? lang(*errorKey) : QString(); + return error.value_or(QString()); } void SendFile::addToHistory( @@ -177,23 +177,23 @@ void SendFile::addToHistory( QString SendFile::getErrorOnSend( const Result *owner, not_null history) const { - const auto errorMedia = Data::RestrictionErrorKey( + const auto errorMedia = Data::RestrictionError( history->peer, ChatRestriction::f_send_media); - const auto errorStickers = Data::RestrictionErrorKey( + const auto errorStickers = Data::RestrictionError( history->peer, ChatRestriction::f_send_stickers); - const auto errorGifs = Data::RestrictionErrorKey( + const auto errorGifs = Data::RestrictionError( history->peer, ChatRestriction::f_send_gifs); return errorMedia - ? lang(*errorMedia) + ? *errorMedia : (errorStickers && (_document->sticker() != nullptr)) - ? lang(*errorStickers) + ? *errorStickers : (errorGifs && _document->isAnimation() && !_document->isVideoMessage()) - ? lang(*errorGifs) + ? *errorGifs : QString(); } @@ -223,10 +223,10 @@ void SendGame::addToHistory( QString SendGame::getErrorOnSend( const Result *owner, not_null history) const { - const auto errorKey = Data::RestrictionErrorKey( + const auto error = Data::RestrictionError( history->peer, ChatRestriction::f_send_games); - return errorKey ? lang(*errorKey) : QString(); + return error.value_or(QString()); } } // namespace internal diff --git a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp index b4bb5c6a2..9b5ae28fb 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp @@ -85,12 +85,12 @@ void Inner::visibleTopBottomUpdated( void Inner::checkRestrictedPeer() { if (_inlineQueryPeer) { - const auto errorKey = Data::RestrictionErrorKey( + const auto error = Data::RestrictionError( _inlineQueryPeer, ChatRestriction::f_send_inline); - if (errorKey) { + if (error) { if (!_restrictedLabel) { - _restrictedLabel.create(this, lang(*errorKey), st::stickersRestrictedLabel); + _restrictedLabel.create(this, *error, st::stickersRestrictedLabel); _restrictedLabel->show(); _restrictedLabel->move(st::inlineResultsLeft - st::buttonRadius, st::stickerPanPadding); if (_switchPmButton) { @@ -151,7 +151,7 @@ void Inner::paintInlineItems(Painter &p, const QRect &r) { if (_rows.isEmpty() && !_switchPmButton) { p.setFont(st::normalFont); p.setPen(st::noContactsColor); - p.drawText(QRect(0, 0, width(), (height() / 3) * 2 + st::normalFont->height), lang(lng_inline_bot_no_results), style::al_center); + p.drawText(QRect(0, 0, width(), (height() / 3) * 2 + st::normalFont->height), tr::lng_inline_bot_no_results(tr::now), style::al_center); return; } auto gifPaused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults); diff --git a/Telegram/SourceFiles/intro/introcode.cpp b/Telegram/SourceFiles/intro/introcode.cpp index 3a7dafb7f..11295acac 100644 --- a/Telegram/SourceFiles/intro/introcode.cpp +++ b/Telegram/SourceFiles/intro/introcode.cpp @@ -74,7 +74,7 @@ void CodeInput::correctValue(const QString &was, int wasCursor, QString &now, in } CodeWidget::CodeWidget(QWidget *parent, Widget::Data *data) : Step(parent, data) -, _noTelegramCode(this, lang(lng_code_no_telegram), st::introLink) +, _noTelegramCode(this, tr::lng_code_no_telegram(tr::now), st::introLink) , _code(this, st::introCode, tr::lng_code_ph()) , _callTimer(this) , _callStatus(getData()->callStatus) @@ -96,7 +96,7 @@ CodeWidget::CodeWidget(QWidget *parent, Widget::Data *data) : Step(parent, data) } void CodeWidget::refreshLang() { - if (_noTelegramCode) _noTelegramCode->setText(lang(lng_code_no_telegram)); + if (_noTelegramCode) _noTelegramCode->setText(tr::lng_code_no_telegram(tr::now)); updateDescText(); updateControlsGeometry(); } @@ -133,8 +133,8 @@ void CodeWidget::updateCallText() { return lng_code_call(lt_minutes, QString::number(_callTimeout / 60), lt_seconds, qsl("%1").arg(_callTimeout % 60, 2, 10, QChar('0'))); } } break; - case Widget::Data::CallStatus::Calling: return lang(lng_code_calling); - case Widget::Data::CallStatus::Called: return lang(lng_code_called); + 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(); })(); @@ -311,8 +311,8 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) { if (*box) (*box)->closeBox(); }; *box = Ui::show(Box( - lang(lng_passport_app_out_of_date), - lang(lng_menu_update), + tr::lng_passport_app_out_of_date(tr::now), + tr::lng_menu_update(tr::now), callback)); return; } diff --git a/Telegram/SourceFiles/intro/introphone.cpp b/Telegram/SourceFiles/intro/introphone.cpp index 40de7214d..6b3122cb0 100644 --- a/Telegram/SourceFiles/intro/introphone.cpp +++ b/Telegram/SourceFiles/intro/introphone.cpp @@ -178,7 +178,7 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) { _sentRequest = 0; auto &err = error.type(); if (err == qstr("PHONE_NUMBER_FLOOD")) { - Ui::show(Box(lang(lng_error_phone_flood))); + Ui::show(Box(tr::lng_error_phone_flood(tr::now))); return true; } else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error showPhoneError(tr::lng_bad_phone()); diff --git a/Telegram/SourceFiles/intro/intropwdcheck.cpp b/Telegram/SourceFiles/intro/intropwdcheck.cpp index 03bd3691a..7d997263f 100644 --- a/Telegram/SourceFiles/intro/intropwdcheck.cpp +++ b/Telegram/SourceFiles/intro/intropwdcheck.cpp @@ -32,8 +32,8 @@ PwdCheckWidget::PwdCheckWidget( , _pwdField(this, st::introPassword, tr::lng_signin_password()) , _pwdHint(this, st::introPasswordHint) , _codeField(this, st::introPassword, tr::lng_signin_code()) -, _toRecover(this, lang(lng_signin_recover)) -, _toPassword(this, lang(lng_signin_try_password)) +, _toRecover(this, tr::lng_signin_recover(tr::now)) +, _toPassword(this, tr::lng_signin_try_password(tr::now)) , _checkRequest(this) { Expects(!!_request); @@ -61,8 +61,8 @@ PwdCheckWidget::PwdCheckWidget( } void PwdCheckWidget::refreshLang() { - if (_toRecover) _toRecover->setText(lang(lng_signin_recover)); - if (_toPassword) _toPassword->setText(lang(lng_signin_try_password)); + 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)); } @@ -297,12 +297,12 @@ void PwdCheckWidget::onToRecover() { }).send(); } } else { - Ui::show(Box(lang(lng_signin_no_email_forgot), [this] { showReset(); })); + Ui::show(Box(tr::lng_signin_no_email_forgot(tr::now), [this] { showReset(); })); } } void PwdCheckWidget::onToPassword() { - Ui::show(Box(lang(lng_signin_cant_email_forgot), [this] { showReset(); })); + Ui::show(Box(tr::lng_signin_cant_email_forgot(tr::now), [this] { showReset(); })); } void PwdCheckWidget::showReset() { @@ -360,8 +360,8 @@ void PwdCheckWidget::submit() { } }; *box = Ui::show(Box( - lang(lng_cloud_password_passport_losing), - lang(lng_continue), + tr::lng_cloud_password_passport_losing(tr::now), + tr::lng_continue(tr::now), confirmed)); } else { send(); diff --git a/Telegram/SourceFiles/intro/introsignup.cpp b/Telegram/SourceFiles/intro/introsignup.cpp index 4ea860528..2c63db461 100644 --- a/Telegram/SourceFiles/intro/introsignup.cpp +++ b/Telegram/SourceFiles/intro/introsignup.cpp @@ -23,7 +23,7 @@ namespace Intro { SignupWidget::SignupWidget(QWidget *parent, Widget::Data *data) : Step(parent, data) , _photo( this, - lang(lng_settings_crop_profile), + tr::lng_settings_crop_profile(tr::now), Ui::UserpicButton::Role::ChangePhoto, st::defaultUserpicButton) , _first(this, st::introName, tr::lng_signup_firstname()) @@ -144,7 +144,7 @@ bool SignupWidget::nameSubmitFail(const RPCError &error) { stopCheck(); auto &err = error.type(); if (err == qstr("PHONE_NUMBER_FLOOD")) { - Ui::show(Box(lang(lng_error_phone_flood))); + Ui::show(Box(tr::lng_error_phone_flood(tr::now))); return true; } else if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_NUMBER_BANNED") diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index 46f6759c6..30054cf3b 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -359,7 +359,7 @@ void Widget::acceptTerms(Fn callback) { void Widget::resetAccount() { if (_resetRequest) return; - Ui::show(Box(lang(lng_signin_sure_reset), lang(lng_signin_reset), st::attentionBoxButton, crl::guard(this, [this] { + Ui::show(Box(tr::lng_signin_sure_reset(tr::now), tr::lng_signin_reset(tr::now), st::attentionBoxButton, crl::guard(this, [this] { if (_resetRequest) return; _resetRequest = request(MTPaccount_DeleteAccount(MTP_string("Forgot password"))).done([this](const MTPBool &result) { _resetRequest = 0; @@ -386,7 +386,7 @@ void Widget::resetAccount() { } Ui::show(Box(lng_signin_reset_wait(lt_phone_number, App::formatPhone(getData()->phone), lt_when, when))); } else if (type == qstr("2FA_RECENT_CONFIRM")) { - Ui::show(Box(lang(lng_signin_reset_cancelled))); + Ui::show(Box(tr::lng_signin_reset_cancelled(tr::now))); } else { Ui::hideLayer(); getStep()->showError(rpl::single(Lang::Hard::ServerError())); @@ -442,7 +442,7 @@ void Widget::showTerms(Fn callback) { box->cancelClicks( ) | rpl::start_with_next([=] { const auto box = Ui::show(Box( - TextWithEntities{ lang(lng_terms_signup_sorry) }, + TextWithEntities{ tr::lng_terms_signup_sorry(tr::now) }, tr::lng_intro_finish(), tr::lng_terms_decline())); box->agreeClicks( diff --git a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp index b23e497d0..d7ef7005c 100644 --- a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp +++ b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp @@ -358,7 +358,7 @@ bool CloudManager::showOfferSwitchBox() { + language.nativeName + "? You can always change your language in Settings.", "Change", - lang(lng_cancel), + tr::lng_cancel(tr::now), confirm, cancel), LayerOption::KeepOther); @@ -407,7 +407,7 @@ void CloudManager::requestLanguageAndSwitch( Expects(!id.isEmpty()); if (LanguageIdOrDefault(_langpack.id()) == id) { - Ui::show(Box(lang(lng_language_already))); + Ui::show(Box(tr::lng_language_already(tr::now))); return; } else if (id == qstr("#custom")) { performSwitchToCustom(); @@ -442,7 +442,7 @@ void CloudManager::requestLanguageAndSwitch( }).fail([=](const RPCError &error) { _switchingToLanguageRequest = 0; if (error.type() == "LANG_CODE_NOT_SUPPORTED") { - Ui::show(Box(lang(lng_language_not_found))); + Ui::show(Box(tr::lng_language_not_found(tr::now))); } }).send(); } @@ -474,14 +474,14 @@ void CloudManager::switchToLanguage(const Language &data) { ? GetOriginalValue(key) : it->second; }; - const auto text = lang(lng_sure_save_language) + const auto text = tr::lng_sure_save_language(tr::now) + "\n\n" + getValue(lng_sure_save_language); Ui::show( Box( text, - lang(lng_box_ok), - lang(lng_cancel), + tr::lng_box_ok(tr::now), + tr::lng_cancel(tr::now), [=] { performSwitchAndRestart(data); }), LayerOption::KeepOther); }).fail([=](const RPCError &error) { @@ -512,7 +512,7 @@ void CloudManager::performSwitchToCustom() { ? GetOriginalValue(key) : it.value(); }; - const auto text = lang(lng_sure_save_language) + const auto text = tr::lng_sure_save_language(tr::now) + "\n\n" + getValue(lng_sure_save_language); const auto change = [=] { @@ -522,8 +522,8 @@ void CloudManager::performSwitchToCustom() { Ui::show( Box( text, - lang(lng_box_ok), - lang(lng_cancel), + tr::lng_box_ok(tr::now), + tr::lng_cancel(tr::now), change), LayerOption::KeepOther); } diff --git a/Telegram/SourceFiles/lang/lang_keys.cpp b/Telegram/SourceFiles/lang/lang_keys.cpp index c7220e350..0cc69c259 100644 --- a/Telegram/SourceFiles/lang/lang_keys.cpp +++ b/Telegram/SourceFiles/lang/lang_keys.cpp @@ -9,18 +9,159 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_file_parser.h" -bool langFirstNameGoesSecond() { - auto fullname = lang(lng_full_name__tagged); - for (auto begin = fullname.constData(), ch = begin, end = ch + fullname.size(); ch != end; ++ch) { - if (*ch == TextCommand) { - if (ch + 3 < end && (ch + 1)->unicode() == TextCommandLangTag && *(ch + 3) == TextCommand) { - if ((ch + 2)->unicode() == 0x0020 + lt_last_name) { - return true; - } else if ((ch + 2)->unicode() == 0x0020 + lt_first_name) { - break; - } - } +namespace { + +template +inline QString langDateMaybeWithYear(QDate date, WithYear withYear, WithoutYear withoutYear) { + 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(); + if (year != currentYear) { + auto yearIsMuchGreater = [](int year, int otherYear) { + return (year > otherYear + 1); + }; + auto monthIsMuchGreater = [](int year, int month, int otherYear, int otherMonth) { + return (year == otherYear + 1) && (month + 12 > otherMonth + 3); + }; + if (false + || yearIsMuchGreater(year, currentYear) + || yearIsMuchGreater(currentYear, year) + || monthIsMuchGreater(year, month, currentYear, currentMonth) + || monthIsMuchGreater(currentYear, currentMonth, year, month)) { + return withYear(month, year); } } - return false; + return withoutYear(month, year); +} + +tr::phrase<> Month(int index) { + switch (index) { + case 1: return tr::lng_month1; + case 2: return tr::lng_month2; + case 3: return tr::lng_month3; + case 4: return tr::lng_month4; + case 5: return tr::lng_month5; + case 6: return tr::lng_month6; + case 7: return tr::lng_month7; + case 8: return tr::lng_month8; + case 9: return tr::lng_month9; + case 10: return tr::lng_month10; + case 11: return tr::lng_month11; + case 12: return tr::lng_month12; + } + Unexpected("Index in MonthSmall."); +} + +tr::phrase<> MonthSmall(int index) { + switch (index) { + case 1: return tr::lng_month1_small; + case 2: return tr::lng_month2_small; + case 3: return tr::lng_month3_small; + case 4: return tr::lng_month4_small; + case 5: return tr::lng_month5_small; + case 6: return tr::lng_month6_small; + case 7: return tr::lng_month7_small; + case 8: return tr::lng_month8_small; + case 9: return tr::lng_month9_small; + case 10: return tr::lng_month10_small; + case 11: return tr::lng_month11_small; + case 12: return tr::lng_month12_small; + } + Unexpected("Index in MonthSmall."); +} + +tr::phrase<> MonthDay(int index) { + switch (index) { + case 1: return tr::lng_month_day1; + case 2: return tr::lng_month_day2; + case 3: return tr::lng_month_day3; + case 4: return tr::lng_month_day4; + case 5: return tr::lng_month_day5; + case 6: return tr::lng_month_day6; + case 7: return tr::lng_month_day7; + case 8: return tr::lng_month_day8; + case 9: return tr::lng_month_day9; + case 10: return tr::lng_month_day10; + case 11: return tr::lng_month_day11; + case 12: return tr::lng_month_day12; + } + Unexpected("Index in MonthDay."); +} + +tr::phrase<> Weekday(int index) { + switch (index) { + case 1: return tr::lng_weekday1; + case 2: return tr::lng_weekday2; + case 3: return tr::lng_weekday3; + case 4: return tr::lng_weekday4; + case 5: return tr::lng_weekday5; + case 6: return tr::lng_weekday6; + case 7: return tr::lng_weekday7; + } + Unexpected("Index in Weekday."); +} + +} // namespace + +bool langFirstNameGoesSecond() { + const auto kFirstName = QChar(0x0001); + const auto kLastName = QChar(0x0002); + const auto fullname = tr::lng_full_name( + tr::now, + lt_first_name, + QString(1, kFirstName), + lt_last_name, + QString(1, kLastName)); + return fullname.indexOf(kLastName) < fullname.indexOf(kFirstName); +} + +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)); + }, [day](int month, int year) { + return lng_month_day(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)); + }, [day](int month, int year) { + return lng_month_day(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"); +} + +QString langMonth(const QDate &date) { + return langDateMaybeWithYear(date, [](int month, int year) { + return langMonthOfYear(month, year); + }, [](int month, int year) { + return MonthSmall(month)(tr::now); + }); +} + +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"); +} + +QString langMonthFull(const QDate &date) { + return langDateMaybeWithYear(date, [](int month, int year) { + return langMonthOfYearFull(month, year); + }, [](int month, int year) { + return Month(month)(tr::now); + }); +} + +QString langDayOfWeek(int index) { + return (index > 0 && index <= 7) ? Weekday(index)(tr::now) : qsl("DAY_ERR"); } diff --git a/Telegram/SourceFiles/lang/lang_keys.h b/Telegram/SourceFiles/lang/lang_keys.h index e33e97379..8726f17b7 100644 --- a/Telegram/SourceFiles/lang/lang_keys.h +++ b/Telegram/SourceFiles/lang/lang_keys.h @@ -10,83 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_instance.h" #include "lang/lang_hardcoded.h" -inline QString lang(LangKey key) { - return Lang::Current().getValue(key); -} - -template -inline QString langDateMaybeWithYear(QDate date, WithYear withYear, WithoutYear withoutYear) { - 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(); - if (year != currentYear) { - auto yearIsMuchGreater = [](int year, int otherYear) { - return (year > otherYear + 1); - }; - auto monthIsMuchGreater = [](int year, int month, int otherYear, int otherMonth) { - return (year == otherYear + 1) && (month + 12 > otherMonth + 3); - }; - if (false - || yearIsMuchGreater(year, currentYear) - || yearIsMuchGreater(currentYear, year) - || monthIsMuchGreater(year, month, currentYear, currentMonth) - || monthIsMuchGreater(currentYear, currentMonth, year, month)) { - return withYear(month, year); - } - } - return withoutYear(month, year); -} - -inline QString langDayOfMonth(const QDate &date) { - auto day = date.day(); - return langDateMaybeWithYear(date, [day](int month, int year) { - return lng_month_day_year(lt_month, lang(LangKey(lng_month1_small + month - 1)), lt_day, QString::number(day), lt_year, QString::number(year)); - }, [day](int month, int year) { - return lng_month_day(lt_month, lang(LangKey(lng_month1_small + month - 1)), lt_day, QString::number(day)); - }); -} - -inline QString langDayOfMonthFull(const QDate &date) { - auto day = date.day(); - return langDateMaybeWithYear(date, [day](int month, int year) { - return lng_month_day_year(lt_month, lang(LangKey(lng_month_day1 + month - 1)), lt_day, QString::number(day), lt_year, QString::number(year)); - }, [day](int month, int year) { - return lng_month_day(lt_month, lang(LangKey(lng_month_day1 + month - 1)), lt_day, QString::number(day)); - }); -} - -inline QString langMonthOfYear(int month, int year) { - return (month > 0 && month <= 12) ? lng_month_year(lt_month, lang(LangKey(lng_month1_small + month - 1)), lt_year, QString::number(year)) : qsl("MONTH_ERR"); -} - -inline QString langMonth(const QDate &date) { - return langDateMaybeWithYear(date, [](int month, int year) { - return langMonthOfYear(month, year); - }, [](int month, int year) { - return lang(LangKey(lng_month1_small + month - 1)); - }); -} - -inline QString langMonthOfYearFull(int month, int year) { - return (month > 0 && month <= 12) ? lng_month_year(lt_month, lang(LangKey(lng_month1 + month - 1)), lt_year, QString::number(year)) : qsl("MONTH_ERR"); -} - -inline QString langMonthFull(const QDate &date) { - return langDateMaybeWithYear(date, [](int month, int year) { - return langMonthOfYearFull(month, year); - }, [](int month, int year) { - return lang(LangKey(lng_month1 + month - 1)); - }); -} - -inline QString langDayOfWeek(int index) { - return (index > 0 && index <= 7) ? lang(LangKey(lng_weekday1 + index - 1)) : qsl("DAY_ERR"); -} +QString langDayOfMonth(const QDate &date); +QString langDayOfMonthFull(const QDate &date); +QString langMonthOfYear(int month, int year); +QString langMonth(const QDate &date); +QString langMonthOfYearFull(int month, int year); +QString langMonthFull(const QDate &date); +QString langDayOfWeek(int index); inline QString langDayOfWeek(const QDate &date) { return langDayOfWeek(date.dayOfWeek()); diff --git a/Telegram/SourceFiles/lang/lang_translator.cpp b/Telegram/SourceFiles/lang/lang_translator.cpp index f15468957..926489c1a 100644 --- a/Telegram/SourceFiles/lang/lang_translator.cpp +++ b/Telegram/SourceFiles/lang/lang_translator.cpp @@ -14,27 +14,27 @@ namespace Lang { QString Translator::translate(const char *context, const char *sourceText, const char *disambiguation, int n) const { if (qstr("QMenuBar") == context) { - if (qstr("Services") == sourceText) return lang(lng_mac_menu_services); - if (qstr("Hide %1") == sourceText) return lng_mac_menu_hide_telegram(lt_telegram, qsl("%1")); - if (qstr("Hide Others") == sourceText) return lang(lng_mac_menu_hide_others); - if (qstr("Show All") == sourceText) return lang(lng_mac_menu_show_all); - if (qstr("Preferences...") == sourceText) return lang(lng_mac_menu_preferences); - if (qstr("Quit %1") == sourceText) return lng_mac_menu_quit_telegram(lt_telegram, qsl("%1")); - if (qstr("About %1") == sourceText) return lng_mac_menu_about_telegram(lt_telegram, qsl("%1")); + if (qstr("Services") == sourceText) return tr::lng_mac_menu_services(tr::now); + if (qstr("Hide %1") == sourceText) return tr::lng_mac_menu_hide_telegram(tr::now, lt_telegram, qsl("%1")); + if (qstr("Hide Others") == sourceText) return tr::lng_mac_menu_hide_others(tr::now); + if (qstr("Show All") == sourceText) return tr::lng_mac_menu_show_all(tr::now); + if (qstr("Preferences...") == sourceText) return tr::lng_mac_menu_preferences(tr::now); + if (qstr("Quit %1") == sourceText) return tr::lng_mac_menu_quit_telegram(tr::now, lt_telegram, qsl("%1")); + if (qstr("About %1") == sourceText) return tr::lng_mac_menu_about_telegram(tr::now, lt_telegram, qsl("%1")); return QString(); } if (qstr("QWidgetTextControl") == context || qstr("QLineEdit") == context) { - if (qstr("&Undo") == sourceText) return lang(Platform::IsWindows() ? lng_wnd_menu_undo : (Platform::IsMac() ? lng_mac_menu_undo : lng_linux_menu_undo)); - if (qstr("&Redo") == sourceText) return lang(Platform::IsWindows() ? lng_wnd_menu_redo : (Platform::IsMac() ? lng_mac_menu_redo : lng_linux_menu_redo)); - if (qstr("Cu&t") == sourceText) return lang(lng_mac_menu_cut); - if (qstr("&Copy") == sourceText) return lang(lng_mac_menu_copy); - if (qstr("&Paste") == sourceText) return lang(lng_mac_menu_paste); - if (qstr("Delete") == sourceText) return lang(lng_mac_menu_delete); - if (qstr("Select All") == sourceText) return lang(lng_mac_menu_select_all); + if (qstr("&Undo") == sourceText) return Platform::IsWindows() ? tr::lng_wnd_menu_undo(tr::now) : Platform::IsMac() ? tr::lng_mac_menu_undo(tr::now) : tr::lng_linux_menu_undo(tr::now); + if (qstr("&Redo") == sourceText) return Platform::IsWindows() ? tr::lng_wnd_menu_redo(tr::now) : Platform::IsMac() ? tr::lng_mac_menu_redo(tr::now) : tr::lng_linux_menu_redo(tr::now); + if (qstr("Cu&t") == sourceText) return tr::lng_mac_menu_cut(tr::now); + if (qstr("&Copy") == sourceText) return tr::lng_mac_menu_copy(tr::now); + if (qstr("&Paste") == sourceText) return tr::lng_mac_menu_paste(tr::now); + if (qstr("Delete") == sourceText) return tr::lng_mac_menu_delete(tr::now); + if (qstr("Select All") == sourceText) return tr::lng_mac_menu_select_all(tr::now); return QString(); } if (qstr("QUnicodeControlCharacterMenu") == context) { - if (qstr("Insert Unicode control character") == sourceText) return lang(lng_menu_insert_unicode); + if (qstr("Insert Unicode control character") == sourceText) return tr::lng_menu_insert_unicode(tr::now); return QString(); } return QString(); diff --git a/Telegram/SourceFiles/layout.cpp b/Telegram/SourceFiles/layout.cpp index 06808805a..e96e140a2 100644 --- a/Telegram/SourceFiles/layout.cpp +++ b/Telegram/SourceFiles/layout.cpp @@ -85,10 +85,10 @@ int32 documentColorIndex(DocumentData *document, QString &ext) { auto name = document ? (document->filename().isEmpty() ? (document->sticker() - ? lang(lng_in_dlg_sticker) + ? tr::lng_in_dlg_sticker(tr::now) : qsl("Unknown File")) : document->filename()) - : lang(lng_message_empty); + : tr::lng_message_empty(tr::now); name = name.toLower(); auto lastDot = name.lastIndexOf('.'); auto mime = document diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index e41bec7e6..c56cf42d1 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -612,7 +612,7 @@ bool MainWidget::shareUrl( const auto peer = session().data().peer(peerId); if (!peer->canWrite()) { - Ui::show(Box(lang(lng_share_cant))); + Ui::show(Box(tr::lng_share_cant(tr::now))); return false; } TextWithTags textWithTags = { @@ -648,7 +648,7 @@ bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) { const auto peer = session().data().peer(peerId); if (!peer->canWrite()) { - Ui::show(Box(lang(lng_inline_switch_cant))); + Ui::show(Box(tr::lng_inline_switch_cant(tr::now))); return false; } const auto h = peer->owner().history(peer); @@ -688,12 +688,12 @@ bool MainWidget::sendPaths(PeerId peerId) { auto peer = session().data().peer(peerId); if (!peer->canWrite()) { - Ui::show(Box(lang(lng_forward_send_files_cant))); + Ui::show(Box(tr::lng_forward_send_files_cant(tr::now))); return false; - } else if (const auto key = Data::RestrictionErrorKey( + } else if (const auto error = Data::RestrictionError( peer, ChatRestriction::f_send_media)) { - Ui::show(Box(lang(*key))); + Ui::show(Box(*error)); return false; } Ui::showPeerHistory(peer, ShowAtTheEndMsgId); @@ -716,7 +716,7 @@ void MainWidget::onFilesOrForwardDrop( } else { auto peer = session().data().peer(peerId); if (!peer->canWrite()) { - Ui::show(Box(lang(lng_forward_send_files_cant))); + Ui::show(Box(tr::lng_forward_send_files_cant(tr::now))); return; } Ui::showPeerHistory(peer, ShowAtTheEndMsgId); @@ -825,14 +825,14 @@ void MainWidget::showForwardLayer(MessageIdsList &&items) { }; hiderLayer(base::make_unique_q( this, - lang(lng_forward_choose), + tr::lng_forward_choose(tr::now), std::move(callback))); } void MainWidget::showSendPathsLayer() { hiderLayer(base::make_unique_q( this, - lang(lng_forward_choose), + tr::lng_forward_choose(tr::now), [=](PeerId peer) { return sendPaths(peer); })); if (_hider) { connect(_hider, &QObject::destroyed, [] { @@ -863,16 +863,16 @@ void MainWidget::cancelUploadLayer(not_null item) { session().uploader().unpause(); }; Ui::show(Box( - lang(lng_selected_cancel_sure_this), - lang(lng_selected_upload_stop), - lang(lng_continue), + tr::lng_selected_cancel_sure_this(tr::now), + tr::lng_selected_upload_stop(tr::now), + tr::lng_continue(tr::now), stopUpload, continueUpload)); } void MainWidget::deletePhotoLayer(PhotoData *photo) { if (!photo) return; - Ui::show(Box(lang(lng_delete_photo_sure), lang(lng_box_delete), crl::guard(this, [=] { + Ui::show(Box(tr::lng_delete_photo_sure(tr::now), tr::lng_box_delete(tr::now), crl::guard(this, [=] { session().api().clearPeerPhoto(photo); Ui::hideLayer(); }))); @@ -888,7 +888,7 @@ void MainWidget::shareUrlLayer(const QString &url, const QString &text) { }; hiderLayer(base::make_unique_q( this, - lang(lng_forward_choose), + tr::lng_forward_choose(tr::now), std::move(callback))); } @@ -898,7 +898,7 @@ void MainWidget::inlineSwitchLayer(const QString &botAndQuery) { }; hiderLayer(base::make_unique_q( this, - lang(lng_inline_switch_choose), + tr::lng_inline_switch_choose(tr::now), std::move(callback))); } @@ -919,7 +919,7 @@ bool MainWidget::sendMessageFail(const RPCError &error) { } else if (error.type() == qstr("USER_BANNED_IN_CHANNEL")) { const auto link = textcmdLink( Core::App().createInternalLinkFull(qsl("spambot")), - lang(lng_cant_more_info)); + tr::lng_cant_more_info(tr::now)); const auto text = lng_error_public_groups_denied(lt_more_info, link); Ui::show(Box(text)); return true; @@ -1259,7 +1259,7 @@ void MainWidget::documentLoadFailed(FileLoader *loader, bool started) { if (started) { const auto origin = loader->fileOrigin(); const auto failedFileName = loader->fileName(); - Ui::show(Box(lang(lng_download_finish_failed), crl::guard(this, [=] { + Ui::show(Box(tr::lng_download_finish_failed(tr::now), crl::guard(this, [=] { Ui::hideLayer(); if (document) { document->save(origin, failedFileName); @@ -1269,7 +1269,7 @@ void MainWidget::documentLoadFailed(FileLoader *loader, bool started) { // Sometimes we have LOCATION_INVALID error in documents / stickers. // Sometimes FILE_REFERENCE_EXPIRED could not be handled. // - //Ui::show(Box(lang(lng_download_path_failed), lang(lng_download_path_settings), crl::guard(this, [=] { + //Ui::show(Box(tr::lng_download_path_failed(tr::now), tr::lng_download_path_settings(tr::now), crl::guard(this, [=] { // Global::SetDownloadPath(QString()); // Global::SetDownloadPathBookmark(QByteArray()); // Ui::show(Box()); @@ -2194,7 +2194,7 @@ bool MainWidget::deleteChannelFailed(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; //if (error.type() == qstr("CHANNEL_TOO_LARGE")) { - // Ui::show(Box(lang(lng_cant_delete_channel))); + // Ui::show(Box(tr::lng_cant_delete_channel(tr::now))); //} return true; @@ -2304,7 +2304,7 @@ void MainWidget::hideAll() { void MainWidget::showAll() { if (cPasswordRecovered()) { cSetPasswordRecovered(false); - Ui::show(Box(lang(lng_signin_password_removed))); + Ui::show(Box(tr::lng_signin_password_removed(tr::now))); } if (Adaptive::OneColumn()) { _sideShadow->hide(); @@ -3373,7 +3373,7 @@ void MainWidget::incrementSticker(DocumentData *sticker) { it = sets.insert(Stickers::CloudRecentSetId, Stickers::Set( Stickers::CloudRecentSetId, uint64(0), - lang(lng_recent_stickers), + tr::lng_recent_stickers(tr::now), QString(), 0, // count 0, // hash @@ -3381,7 +3381,7 @@ void MainWidget::incrementSticker(DocumentData *sticker) { TimeId(0), ImagePtr())); } else { - it->title = lang(lng_recent_stickers); + it->title = tr::lng_recent_stickers(tr::now); } } auto removedFromEmoji = std::vector>(); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index c4946ad6c..e4ee2f3dd 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -128,19 +128,19 @@ void MainWindow::firstShow() { trayIconMenu = new QMenu(this); #endif // else for Q_OS_WIN - auto notificationActionText = lang(Global::DesktopNotify() - ? lng_disable_notifications_from_tray - : lng_enable_notifications_from_tray); + auto notificationActionText = Global::DesktopNotify() + ? tr::lng_disable_notifications_from_tray(tr::now) + : tr::lng_enable_notifications_from_tray(tr::now); if (Platform::IsLinux()) { - trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray())); - trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray())); + trayIconMenu->addAction(tr::lng_open_from_tray(tr::now), this, SLOT(showFromTray())); + trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray())); trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray())); - trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray())); + trayIconMenu->addAction(tr::lng_quit_from_tray(tr::now), this, SLOT(quitFromTray())); } else { - trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray())); + trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray())); trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray())); - trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray())); + trayIconMenu->addAction(tr::lng_quit_from_tray(tr::now), this, SLOT(quitFromTray())); } Global::RefWorkMode().setForced(Global::WorkMode().value(), true); @@ -558,7 +558,9 @@ void MainWindow::updateTrayMenu(bool force) { disconnect(toggleAction, SIGNAL(triggered(bool)), this, SLOT(minimizeToTray())); disconnect(toggleAction, SIGNAL(triggered(bool)), this, SLOT(showFromTray())); connect(toggleAction, SIGNAL(triggered(bool)), this, active ? SLOT(minimizeToTray()) : SLOT(showFromTray())); - toggleAction->setText(lang(active ? lng_minimize_to_tray : lng_open_from_tray)); + toggleAction->setText(active + ? tr::lng_minimize_to_tray(tr::now) + : tr::lng_open_from_tray(tr::now)); // On macOS just remove trayIcon menu if the window is not active. // So we will activate the window on click instead of showing the menu. @@ -567,9 +569,9 @@ void MainWindow::updateTrayMenu(bool force) { } } auto notificationAction = actions.at(Platform::IsLinux() ? 2 : 1); - auto notificationActionText = lang(Global::DesktopNotify() - ? lng_disable_notifications_from_tray - : lng_enable_notifications_from_tray); + auto notificationActionText = Global::DesktopNotify() + ? tr::lng_disable_notifications_from_tray(tr::now) + : tr::lng_enable_notifications_from_tray(tr::now); notificationAction->setText(notificationActionText); #ifndef Q_OS_WIN @@ -627,8 +629,8 @@ void MainWindow::onLogout() { } }; Ui::show(Box( - lang(lng_sure_logout), - lang(lng_settings_logout), + tr::lng_sure_logout(tr::now), + tr::lng_settings_logout(tr::now), st::attentionBoxButton, callback)); } @@ -706,7 +708,7 @@ bool MainWindow::skipTrayClick() const { void MainWindow::toggleDisplayNotifyFromTray() { if (Core::App().locked()) { if (!isActive()) showFromTray(); - Ui::show(Box(lang(lng_passcode_need_unblock))); + Ui::show(Box(tr::lng_passcode_need_unblock(tr::now))); return; } if (!account().sessionExists()) { diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index 82125d200..5e7d12d43 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -540,7 +540,7 @@ void Widget::handleSongChange() { name.size(), QString())); } else { - textWithEntities.text = lang(lng_media_audio); + textWithEntities.text = tr::lng_media_audio(tr::now); } } else { const auto song = document->song(); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index c50938a27..3dd38a194 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -223,9 +223,9 @@ OverlayWidget::LottieFile::LottieFile( OverlayWidget::OverlayWidget() : OverlayParent(nullptr) , _transparentBrush(style::transparentPlaceholderBrush()) -, _docDownload(this, lang(lng_media_download), st::mediaviewFileLink) -, _docSaveAs(this, lang(lng_mediaview_save_as), st::mediaviewFileLink) -, _docCancel(this, lang(lng_cancel), st::mediaviewFileLink) +, _docDownload(this, tr::lng_media_download(tr::now), st::mediaviewFileLink) +, _docSaveAs(this, tr::lng_mediaview_save_as(tr::now), st::mediaviewFileLink) +, _docCancel(this, tr::lng_cancel(tr::now), st::mediaviewFileLink) , _radial([=](crl::time now) { return radialAnimationCallback(now); }) , _lastAction(-st::mediaviewDeltaFromLastAction, -st::mediaviewDeltaFromLastAction) , _stateAnimation([=](crl::time now) { return stateAnimationCallback(now); }) @@ -658,22 +658,22 @@ void OverlayWidget::updateActions() { _actions.clear(); if (_doc && _doc->loading()) { - _actions.push_back({ lang(lng_cancel), SLOT(onSaveCancel()) }); + _actions.push_back({ tr::lng_cancel(tr::now), SLOT(onSaveCancel()) }); } if (IsServerMsgId(_msgid.msg)) { - _actions.push_back({ lang(lng_context_to_msg), SLOT(onToMessage()) }); + _actions.push_back({ tr::lng_context_to_msg(tr::now), SLOT(onToMessage()) }); } if (_doc && !_doc->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) { - _actions.push_back({ lang(Platform::IsMac() ? lng_context_show_in_finder : lng_context_show_in_folder), SLOT(onShowInFolder()) }); + _actions.push_back({ Platform::IsMac() ? tr::lng_context_show_in_finder(tr::now) : tr::lng_context_show_in_folder(tr::now), SLOT(onShowInFolder()) }); } if ((_doc && documentContentShown()) || (_photo && _photo->loaded())) { - _actions.push_back({ lang(lng_mediaview_copy), SLOT(onCopy()) }); + _actions.push_back({ tr::lng_mediaview_copy(tr::now), SLOT(onCopy()) }); } if (_photo && _photo->hasSticker) { - _actions.push_back({ lang(lng_context_attached_stickers), SLOT(onAttachedStickers()) }); + _actions.push_back({ tr::lng_context_attached_stickers(tr::now), SLOT(onAttachedStickers()) }); } if (_canForwardItem) { - _actions.push_back({ lang(lng_mediaview_forward), SLOT(onForward()) }); + _actions.push_back({ tr::lng_mediaview_forward(tr::now), SLOT(onForward()) }); } auto canDelete = [&] { if (_canDeleteItem) { @@ -690,12 +690,12 @@ void OverlayWidget::updateActions() { return false; }(); if (canDelete) { - _actions.push_back({ lang(lng_mediaview_delete), SLOT(onDelete()) }); + _actions.push_back({ tr::lng_mediaview_delete(tr::now), SLOT(onDelete()) }); } - _actions.push_back({ lang(lng_mediaview_save_as), SLOT(onSaveAs()) }); + _actions.push_back({ tr::lng_mediaview_save_as(tr::now), SLOT(onSaveAs()) }); if (const auto overviewType = computeOverviewType()) { - _actions.push_back({ lang(_doc ? lng_mediaview_files_all : lng_mediaview_photos_all), SLOT(onOverview()) }); + _actions.push_back({ _doc ? tr::lng_mediaview_files_all(tr::now) : tr::lng_mediaview_photos_all(tr::now), SLOT(onOverview()) }); } } @@ -1121,7 +1121,7 @@ void OverlayWidget::onSaveAs() { } psBringToBack(this); - file = FileNameForSave(lang(lng_save_file), filter, qsl("doc"), name, true, alreadyDir); + file = FileNameForSave(tr::lng_save_file(tr::now), filter, qsl("doc"), name, true, alreadyDir); psShowOverAll(this); if (!file.isEmpty() && file != location.name()) { if (_doc->data().isEmpty()) { @@ -1150,7 +1150,7 @@ void OverlayWidget::onSaveAs() { auto filter = qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter(); FileDialog::GetWritePath( this, - lang(lng_save_photo), + tr::lng_save_photo(tr::now), filter, filedialogDefaultName( qsl("photo"), @@ -1909,14 +1909,14 @@ void OverlayWidget::displayDocument(DocumentData *doc, HistoryItem *item) { if (_doc) { _docName = (_doc->type == StickerDocument) - ? lang(lng_in_dlg_sticker) + ? tr::lng_in_dlg_sticker(tr::now) : (_doc->type == AnimatedDocument ? qsl("GIF") : (_doc->filename().isEmpty() - ? lang(lng_mediaview_doc_image) + ? tr::lng_mediaview_doc_image(tr::now) : _doc->filename())); } else { - _docName = lang(lng_message_empty); + _docName = tr::lng_message_empty(tr::now); } _docNameWidth = st::mediaviewFileNameFont->width(_docName); if (_docNameWidth > maxw) { @@ -2892,9 +2892,9 @@ void OverlayWidget::paintThemePreview(Painter &p, QRect clip) { p.setPen(st::themePreviewLoadingFg); p.drawText( _themePreviewRect, - lang(_themePreviewId - ? lng_theme_preview_generating - : lng_theme_preview_invalid), + (_themePreviewId + ? tr::lng_theme_preview_generating(tr::now) + : tr::lng_theme_preview_invalid(tr::now)), QTextOption(style::al_center)); } } @@ -2919,7 +2919,7 @@ void OverlayWidget::paintThemePreview(Painter &p, QRect clip) { if (titleRect.intersects(clip)) { p.setFont(st::themePreviewTitleFont); p.setPen(st::themePreviewTitleFg); - p.drawTextLeft(titleRect.x(), titleRect.y(), width(), lang(lng_theme_preview_title)); + p.drawTextLeft(titleRect.x(), titleRect.y(), width(), tr::lng_theme_preview_title(tr::now)); } auto buttonsRect = QRect(_themePreviewRect.x(), _themePreviewRect.y() + _themePreviewRect.height() - st::themePreviewMargin.bottom(), _themePreviewRect.width(), st::themePreviewMargin.bottom()); @@ -3783,18 +3783,18 @@ void OverlayWidget::updateHeader() { } } else { if (_doc) { - _headerText = _doc->filename().isEmpty() ? lang(lng_mediaview_doc_image) : _doc->filename(); + _headerText = _doc->filename().isEmpty() ? tr::lng_mediaview_doc_image(tr::now) : _doc->filename(); } else if (_msgid) { - _headerText = lang(lng_mediaview_single_photo); + _headerText = tr::lng_mediaview_single_photo(tr::now); } else if (_user) { - _headerText = lang(lng_mediaview_profile_photo); + _headerText = tr::lng_mediaview_profile_photo(tr::now); } else if ((_history && _history->channelId() && !_history->isMegagroup()) || (_peer && _peer->isChannel() && !_peer->isMegagroup())) { - _headerText = lang(lng_mediaview_channel_photo); + _headerText = tr::lng_mediaview_channel_photo(tr::now); } else if (_peer) { - _headerText = lang(lng_mediaview_group_photo); + _headerText = tr::lng_mediaview_group_photo(tr::now); } else { - _headerText = lang(lng_mediaview_single_photo); + _headerText = tr::lng_mediaview_single_photo(tr::now); } } _headerHasLink = computeOverviewType() != std::nullopt; diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 24e20c035..6efcf753b 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -253,7 +253,7 @@ void StatusText::update(int newSize, int fullSize, int duration, crl::time realD } else if (_size == FileStatusSizeLoaded) { _text = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize)); } else if (_size == FileStatusSizeFailed) { - _text = lang(lng_attach_failed); + _text = tr::lng_attach_failed(tr::now); } else if (_size >= 0) { _text = formatDownloadText(_size, fullSize); } else { diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 191230111..96291f765 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -747,7 +747,7 @@ std::vector> FormController::submitGetErrors() { _submitRequestId = 0; _submitSuccess = true; - _view->showToast(lang(lng_passport_success)); + _view->showToast(tr::lng_passport_success(tr::now)); App::CallDelayed( Ui::Toast::DefaultDuration + st::toastFadeOutDuration, @@ -886,10 +886,10 @@ void FormController::submitPassword( _password = PasswordSettings(); reloadPassword(); } else if (MTP::isFloodError(error)) { - _passwordError.fire(lang(lng_flood_error)); + _passwordError.fire(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("PASSWORD_HASH_INVALID") || error.type() == qstr("SRP_PASSWORD_CHANGED")) { - _passwordError.fire(lang(lng_passport_password_wrong)); + _passwordError.fire(tr::lng_passport_password_wrong(tr::now)); } else { _passwordError.fire_copy(error.type()); } @@ -970,7 +970,7 @@ void FormController::checkSavedPasswordSettings( void FormController::recoverPassword() { if (!_password.hasRecovery) { - _view->show(Box(lang(lng_signin_no_email_forgot))); + _view->show(Box(tr::lng_signin_no_email_forgot(tr::now))); return; } else if (_recoverRequestId) { return; @@ -1352,7 +1352,7 @@ void FormController::uploadScan( FileType type, QByteArray &&content) { if (!canAddScan(value, type)) { - _view->showToast(lang(lng_passport_scans_limit_reached)); + _view->showToast(tr::lng_passport_scans_limit_reached(tr::now)); return; } const auto nonconst = findValue(value); @@ -1453,7 +1453,7 @@ void FormController::scanDeleteRestore( auto &scan = nonconst->fileInEdit(type, fileIndex); if (scan.deleted && !deleted) { if (!canAddScan(value, type)) { - _view->showToast(lang(lng_passport_scans_limit_reached)); + _view->showToast(tr::lng_passport_scans_limit_reached(tr::now)); return; } } @@ -1607,10 +1607,10 @@ void FormController::verify( verificationError(nonconst, QString()); if (nonconst->verification.codeLength > 0 && nonconst->verification.codeLength != prepared.size()) { - verificationError(nonconst, lang(lng_signin_wrong_code)); + verificationError(nonconst, tr::lng_signin_wrong_code(tr::now)); return; } else if (prepared.isEmpty()) { - verificationError(nonconst, lang(lng_signin_wrong_code)); + verificationError(nonconst, tr::lng_signin_wrong_code(tr::now)); return; } nonconst->verification.requestId = [&] { @@ -1628,7 +1628,7 @@ void FormController::verify( if (error.type() == qstr("PHONE_CODE_INVALID")) { verificationError( nonconst, - lang(lng_signin_wrong_code)); + tr::lng_signin_wrong_code(tr::now)); } else { verificationError(nonconst, error.type()); } @@ -1645,7 +1645,7 @@ void FormController::verify( if (error.type() == qstr("CODE_INVALID")) { verificationError( nonconst, - lang(lng_signin_wrong_code)); + tr::lng_signin_wrong_code(tr::now)); } else { verificationError(nonconst, error.type()); } @@ -2033,7 +2033,7 @@ void FormController::sendSaveRequest( } else if (code == qstr("PHONE_NUMBER_INVALID")) { if (value->type == Value::Type::Phone) { value->data.parsedInEdit.fields["value"].error - = lang(lng_bad_phone); + = tr::lng_bad_phone(tr::now); valueSaveFailed(value); return; } @@ -2045,7 +2045,7 @@ void FormController::sendSaveRequest( } else if (code == qstr("EMAIL_INVALID")) { if (value->type == Value::Type::Email) { value->data.parsedInEdit.fields["value"].error - = lang(lng_cloud_password_bad_email); + = tr::lng_cloud_password_bad_email(tr::now); valueSaveFailed(value); return; } @@ -2252,8 +2252,8 @@ void FormController::saveSecret( void FormController::suggestRestart() { _suggestingRestart = true; _view->show(Box( - lang(lng_passport_restart_sure), - lang(lng_passport_restart), + tr::lng_passport_restart_sure(tr::now), + tr::lng_passport_restart(tr::now), [=] { _controller->showPassportForm(_request); }, [=] { cancel(); })); } @@ -2469,7 +2469,7 @@ auto FormController::findFile(const FileKey &key) void FormController::formDone(const MTPaccount_AuthorizationForm &result) { if (!parseForm(result)) { - _view->showCriticalError(lang(lng_passport_form_error)); + _view->showCriticalError(tr::lng_passport_form_error(tr::now)); } else { showForm(); } @@ -2538,7 +2538,7 @@ void FormController::formFail(const QString &error) { _serviceErrorText = error; if (!handleAppUpdateError(error)) { _view->showCriticalError( - lang(lng_passport_form_error) + "\n" + error); + tr::lng_passport_form_error(tr::now) + "\n" + error); } } @@ -2636,8 +2636,8 @@ bool FormController::applyPassword(PasswordSettings &&settings) { void FormController::cancel() { if (!_submitSuccess && _serviceErrorText.isEmpty()) { _view->show(Box( - lang(lng_passport_stop_sure), - lang(lng_passport_stop), + tr::lng_passport_stop_sure(tr::now), + tr::lng_passport_stop(tr::now), [=] { cancelSure(); }, [=] { cancelAbort(); })); } else { diff --git a/Telegram/SourceFiles/passport/passport_form_view_controller.cpp b/Telegram/SourceFiles/passport/passport_form_view_controller.cpp index 95e1fbfeb..fb0c926b4 100644 --- a/Telegram/SourceFiles/passport/passport_form_view_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_view_controller.cpp @@ -245,48 +245,48 @@ ScopeRow DocumentRowByType(Value::Type type) { switch (type) { case Type::Passport: return { - lang(lng_passport_identity_passport), - lang(lng_passport_identity_passport_upload), + tr::lng_passport_identity_passport(tr::now), + tr::lng_passport_identity_passport_upload(tr::now), }; case Type::DriverLicense: return { - lang(lng_passport_identity_license), - lang(lng_passport_identity_license_upload), + tr::lng_passport_identity_license(tr::now), + tr::lng_passport_identity_license_upload(tr::now), }; case Type::IdentityCard: return { - lang(lng_passport_identity_card), - lang(lng_passport_identity_card_upload), + tr::lng_passport_identity_card(tr::now), + tr::lng_passport_identity_card_upload(tr::now), }; case Type::InternalPassport: return { - lang(lng_passport_identity_internal), - lang(lng_passport_identity_internal_upload), + tr::lng_passport_identity_internal(tr::now), + tr::lng_passport_identity_internal_upload(tr::now), }; case Type::BankStatement: return { - lang(lng_passport_address_statement), - lang(lng_passport_address_statement_upload), + tr::lng_passport_address_statement(tr::now), + tr::lng_passport_address_statement_upload(tr::now), }; case Type::UtilityBill: return { - lang(lng_passport_address_bill), - lang(lng_passport_address_bill_upload), + tr::lng_passport_address_bill(tr::now), + tr::lng_passport_address_bill_upload(tr::now), }; case Type::RentalAgreement: return { - lang(lng_passport_address_agreement), - lang(lng_passport_address_agreement_upload), + tr::lng_passport_address_agreement(tr::now), + tr::lng_passport_address_agreement_upload(tr::now), }; case Type::PassportRegistration: return { - lang(lng_passport_address_registration), - lang(lng_passport_address_registration_upload), + tr::lng_passport_address_registration(tr::now), + tr::lng_passport_address_registration_upload(tr::now), }; case Type::TemporaryRegistration: return { - lang(lng_passport_address_temporary), - lang(lng_passport_address_temporary_upload), + tr::lng_passport_address_temporary(tr::now), + tr::lng_passport_address_temporary_upload(tr::now), }; default: Unexpected("Value type in DocumentRowByType."); } @@ -507,8 +507,8 @@ ScopeRow ComputeScopeRow(const Scope &scope) { && !scope.documents.empty()) { if (document) { row.description = (scope.type == Scope::Type::Identity) - ? lang(lng_passport_personal_details_enter) - : lang(lng_passport_address_enter); + ? tr::lng_passport_personal_details_enter(tr::now) + : tr::lng_passport_address_enter(tr::now); } else { const auto best = ranges::min( scope.documents, @@ -518,9 +518,9 @@ ScopeRow ComputeScopeRow(const Scope &scope) { }); const auto notFilled = best->whatNotFilled(); if (notFilled & Value::kNoTranslationFilled) { - row.description = lang(lng_passport_translation_needed); + row.description = tr::lng_passport_translation_needed(tr::now); } else if (notFilled & Value::kNoSelfieFilled) { - row.description = lang(lng_passport_identity_selfie); + row.description = tr::lng_passport_identity_selfie(tr::now); } } } @@ -529,33 +529,33 @@ ScopeRow ComputeScopeRow(const Scope &scope) { switch (scope.type) { case Scope::Type::PersonalDetails: return addReadyError({ - lang(lng_passport_personal_details), - lang(lng_passport_personal_details_enter), + tr::lng_passport_personal_details(tr::now), + tr::lng_passport_personal_details_enter(tr::now), }); case Scope::Type::Identity: return addReadyError(DocumentsOneOfRow( scope, - lang(lng_passport_identity_title), - lang(lng_passport_identity_description))); + tr::lng_passport_identity_title(tr::now), + tr::lng_passport_identity_description(tr::now))); case Scope::Type::AddressDetails: return addReadyError({ - lang(lng_passport_address), - lang(lng_passport_address_enter), + tr::lng_passport_address(tr::now), + tr::lng_passport_address_enter(tr::now), }); case Scope::Type::Address: return addReadyError(DocumentsOneOfRow( scope, - lang(lng_passport_address_title), - lang(lng_passport_address_description))); + tr::lng_passport_address_title(tr::now), + tr::lng_passport_address_description(tr::now))); case Scope::Type::Phone: return addReadyError({ - lang(lng_passport_phone_title), - lang(lng_passport_phone_description), + tr::lng_passport_phone_title(tr::now), + tr::lng_passport_phone_description(tr::now), }); case Scope::Type::Email: return addReadyError({ - lang(lng_passport_email_title), - lang(lng_passport_email_description), + tr::lng_passport_email_title(tr::now), + tr::lng_passport_email_description(tr::now), }); default: Unexpected("Scope type in ComputeScopeRow."); } diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index a04206f7b..f51f4fafd 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -38,7 +38,7 @@ ScanInfo CollectScanInfo(const EditFile &file) { const auto status = [&] { if (file.fields.accessHash) { if (file.fields.downloadOffset < 0) { - return lang(lng_attach_failed); + return tr::lng_attach_failed(tr::now); } else if (file.fields.downloadOffset < file.fields.size) { return formatDownloadText( file.fields.downloadOffset, @@ -50,7 +50,7 @@ ScanInfo CollectScanInfo(const EditFile &file) { } } else if (file.uploadData) { if (file.uploadData->offset < 0) { - return lang(lng_attach_failed); + return tr::lng_attach_failed(tr::now); } else if (file.uploadData->fullId) { return formatDownloadText( file.uploadData->offset, @@ -117,9 +117,9 @@ EditDocumentScheme GetDocumentScheme( }; const auto GenderFormat = [](const QString &value) { if (value == qstr("male")) { - return lang(lng_passport_gender_male); + return tr::lng_passport_gender_male(tr::now); } else if (value == qstr("female")) { - return lang(lng_passport_gender_female); + return tr::lng_passport_gender_female(tr::now); } return value; }; @@ -143,7 +143,7 @@ EditDocumentScheme GetDocumentScheme( } else if (!QRegularExpression( "^[a-zA-Z0-9\\.,/&\\-' ]+$" ).match(value).hasMatch()) { - return lang(lng_passport_bad_name); + return tr::lng_passport_bad_name(tr::now); } return std::nullopt; }; @@ -183,19 +183,19 @@ EditDocumentScheme GetDocumentScheme( case Scope::Type::PersonalDetails: case Scope::Type::Identity: { auto result = Scheme(); - result.detailsHeader = lang(lng_passport_personal_details); - result.fieldsHeader = lang(lng_passport_document_details); + result.detailsHeader = tr::lng_passport_personal_details(tr::now); + result.fieldsHeader = tr::lng_passport_document_details(tr::now); if (scansType) { result.scansHeader = [&] { switch (*scansType) { case Value::Type::Passport: - return lang(lng_passport_identity_passport); + return tr::lng_passport_identity_passport(tr::now); case Value::Type::DriverLicense: - return lang(lng_passport_identity_license); + return tr::lng_passport_identity_license(tr::now); case Value::Type::IdentityCard: - return lang(lng_passport_identity_card); + return tr::lng_passport_identity_card(tr::now); case Value::Type::InternalPassport: - return lang(lng_passport_identity_internal); + return tr::lng_passport_identity_internal(tr::now); default: Unexpected("scansType in GetDocumentScheme:Identity."); } @@ -206,7 +206,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("first_name"), - lang(lng_passport_first_name), + tr::lng_passport_first_name(tr::now), NameValidate, DontFormat, kMaxNameSize, @@ -215,7 +215,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("middle_name"), - lang(lng_passport_middle_name), + tr::lng_passport_middle_name(tr::now), NameOrEmptyValidate, DontFormat, kMaxNameSize, @@ -225,7 +225,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("last_name"), - lang(lng_passport_last_name), + tr::lng_passport_last_name(tr::now), NameValidate, DontFormat, kMaxNameSize, @@ -235,7 +235,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Date, qsl("birth_date"), - lang(lng_passport_birth_date), + tr::lng_passport_birth_date(tr::now), DateValidate, DontFormat, }, @@ -243,7 +243,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Gender, qsl("gender"), - lang(lng_passport_gender), + tr::lng_passport_gender(tr::now), GenderValidate, GenderFormat, }, @@ -251,7 +251,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Country, qsl("country_code"), - lang(lng_passport_country), + tr::lng_passport_country(tr::now), CountryValidate, CountryFormat, }, @@ -259,7 +259,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Country, qsl("residence_country_code"), - lang(lng_passport_residence_country), + tr::lng_passport_residence_country(tr::now), CountryValidate, CountryFormat, }, @@ -267,7 +267,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Scans, PanelDetailsType::Text, qsl("document_no"), - lang(lng_passport_document_number), + tr::lng_passport_document_number(tr::now), DocumentValidate, DontFormat, kMaxDocumentSize, @@ -276,7 +276,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Scans, PanelDetailsType::Date, qsl("expiry_date"), - lang(lng_passport_expiry_date), + tr::lng_passport_expiry_date(tr::now), DateOrEmptyValidate, DontFormat, }, @@ -300,7 +300,7 @@ EditDocumentScheme GetDocumentScheme( result.additionalHeader = [=](const QString &countryCode) { const auto language = languageValue(countryCode); return language.isEmpty() - ? lang(lng_passport_native_name_title) + ? tr::lng_passport_native_name_title(tr::now) : lng_passport_native_name_language( lt_language, language); @@ -308,7 +308,7 @@ EditDocumentScheme GetDocumentScheme( result.additionalDescription = [=](const QString &countryCode) { const auto language = languageValue(countryCode); if (!language.isEmpty()) { - return lang(lng_passport_native_name_language_about); + return tr::lng_passport_native_name_language_about(tr::now); } const auto name = CountrySelectBox::NameByISO(countryCode); Assert(!name.isEmpty()); @@ -336,7 +336,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Additional, PanelDetailsType::Text, qsl("first_name_native"), - lang(lng_passport_first_name), + tr::lng_passport_first_name(tr::now), NativeNameValidate, DontFormat, kMaxNameSize, @@ -347,7 +347,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Additional, PanelDetailsType::Text, qsl("middle_name_native"), - lang(lng_passport_middle_name), + tr::lng_passport_middle_name(tr::now), NativeNameOrEmptyValidate, DontFormat, kMaxNameSize, @@ -358,7 +358,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Additional, PanelDetailsType::Text, qsl("last_name_native"), - lang(lng_passport_last_name), + tr::lng_passport_last_name(tr::now), NativeNameValidate, DontFormat, kMaxNameSize, @@ -376,23 +376,23 @@ EditDocumentScheme GetDocumentScheme( case Scope::Type::AddressDetails: case Scope::Type::Address: { auto result = Scheme(); - result.detailsHeader = lang(lng_passport_address); + result.detailsHeader = tr::lng_passport_address(tr::now); if (scansType) { switch (*scansType) { case Value::Type::UtilityBill: - result.scansHeader = lang(lng_passport_address_bill); + result.scansHeader = tr::lng_passport_address_bill(tr::now); break; case Value::Type::BankStatement: - result.scansHeader = lang(lng_passport_address_statement); + result.scansHeader = tr::lng_passport_address_statement(tr::now); break; case Value::Type::RentalAgreement: - result.scansHeader = lang(lng_passport_address_agreement); + result.scansHeader = tr::lng_passport_address_agreement(tr::now); break; case Value::Type::PassportRegistration: - result.scansHeader = lang(lng_passport_address_registration); + result.scansHeader = tr::lng_passport_address_registration(tr::now); break; case Value::Type::TemporaryRegistration: - result.scansHeader = lang(lng_passport_address_temporary); + result.scansHeader = tr::lng_passport_address_temporary(tr::now); break; default: Unexpected("scansType in GetDocumentScheme:Address."); @@ -403,7 +403,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("street_line1"), - lang(lng_passport_street), + tr::lng_passport_street(tr::now), StreetValidate, DontFormat, kMaxStreetSize, @@ -412,7 +412,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("street_line2"), - lang(lng_passport_street), + tr::lng_passport_street(tr::now), DontValidate, DontFormat, kMaxStreetSize, @@ -421,7 +421,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("city"), - lang(lng_passport_city), + tr::lng_passport_city(tr::now), CityValidate, DontFormat, kMaxStreetSize, @@ -430,7 +430,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Text, qsl("state"), - lang(lng_passport_state), + tr::lng_passport_state(tr::now), DontValidate, DontFormat, kMaxStreetSize, @@ -439,7 +439,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Country, qsl("country_code"), - lang(lng_passport_country), + tr::lng_passport_country(tr::now), CountryValidate, CountryFormat, }, @@ -447,7 +447,7 @@ EditDocumentScheme GetDocumentScheme( ValueClass::Fields, PanelDetailsType::Postcode, qsl("post_code"), - lang(lng_passport_postcode), + tr::lng_passport_postcode(tr::now), PostcodeValidate, DontFormat, kMaxPostcodeSize, @@ -466,9 +466,9 @@ EditContactScheme GetContactScheme(Scope::Type type) { switch (type) { case Scope::Type::Phone: { auto result = Scheme(ValueType::Phone); - result.aboutExisting = lang(lng_passport_use_existing_phone); - result.newHeader = lang(lng_passport_new_phone); - result.aboutNew = lang(lng_passport_new_phone_code); + result.aboutExisting = tr::lng_passport_use_existing_phone(tr::now); + result.newHeader = tr::lng_passport_new_phone(tr::now); + result.aboutNew = tr::lng_passport_new_phone_code(tr::now); result.validate = [](const QString &value) { return QRegularExpression( "^\\d{2,12}$" @@ -485,10 +485,10 @@ EditContactScheme GetContactScheme(Scope::Type type) { case Scope::Type::Email: { auto result = Scheme(ValueType::Text); - result.aboutExisting = lang(lng_passport_use_existing_email); - result.newHeader = lang(lng_passport_new_email); + result.aboutExisting = tr::lng_passport_use_existing_email(tr::now); + result.newHeader = tr::lng_passport_new_email(tr::now); result.newPlaceholder = tr::lng_passport_email_title(); - result.aboutNew = lang(lng_passport_new_email_code); + result.aboutNew = tr::lng_passport_new_email_code(tr::now); result.validate = [](const QString &value) { const auto at = value.indexOf('@'); const auto dot = value.lastIndexOf('.'); @@ -742,8 +742,8 @@ void PanelController::setupPassword() { void PanelController::cancelPasswordSubmit() { const auto box = std::make_shared>(); *box = show(Box( - lang(lng_passport_stop_password_sure), - lang(lng_passport_stop), + tr::lng_passport_stop_password_sure(tr::now), + tr::lng_passport_stop(tr::now), [=] { if (*box) (*box)->closeBox(); _form->cancelPassword(); })); } @@ -874,26 +874,26 @@ void PanelController::deleteValue() { const auto text = [&] { switch (_editScope->type) { case Scope::Type::PersonalDetails: - return lang(lng_passport_delete_details_sure); + return tr::lng_passport_delete_details_sure(tr::now); case Scope::Type::Identity: - return lang(lng_passport_delete_document_sure); + return tr::lng_passport_delete_document_sure(tr::now); case Scope::Type::AddressDetails: - return lang(lng_passport_delete_address_sure); + return tr::lng_passport_delete_address_sure(tr::now); case Scope::Type::Address: - return lang(lng_passport_delete_document_sure); + return tr::lng_passport_delete_document_sure(tr::now); case Scope::Type::Phone: - return lang(lng_passport_delete_phone_sure); + return tr::lng_passport_delete_phone_sure(tr::now); case Scope::Type::Email: - return lang(lng_passport_delete_email_sure); + return tr::lng_passport_delete_email_sure(tr::now); } Unexpected("Type in deleteValue."); }(); const auto checkbox = (hasValueDocument() && hasValueFields()) ? [&] { switch (_editScope->type) { case Scope::Type::Identity: - return lang(lng_passport_delete_details); + return tr::lng_passport_delete_details(tr::now); case Scope::Type::Address: - return lang(lng_passport_delete_address); + return tr::lng_passport_delete_address(tr::now); } Unexpected("Type in deleteValue."); }() : QString(); @@ -972,8 +972,8 @@ void PanelController::showUpdateAppBox() { }; show( Box( - lang(lng_passport_app_out_of_date), - lang(lng_menu_update), + tr::lng_passport_app_out_of_date(tr::now), + tr::lng_menu_update(tr::now), callback, [=] { _form->cancelSure(); }), LayerOption::KeepOther, @@ -1038,13 +1038,13 @@ void PanelController::requestScopeFilesType(int index) { }) | ranges::view::transform([](Value::Type type) { switch (type) { case Value::Type::Passport: - return lang(lng_passport_identity_passport); + return tr::lng_passport_identity_passport(tr::now); case Value::Type::IdentityCard: - return lang(lng_passport_identity_card); + return tr::lng_passport_identity_card(tr::now); case Value::Type::DriverLicense: - return lang(lng_passport_identity_license); + return tr::lng_passport_identity_license(tr::now); case Value::Type::InternalPassport: - return lang(lng_passport_identity_internal); + return tr::lng_passport_identity_internal(tr::now); default: Unexpected("IdentityType in requestScopeFilesType"); } @@ -1061,15 +1061,15 @@ void PanelController::requestScopeFilesType(int index) { }) | ranges::view::transform([](Value::Type type) { switch (type) { case Value::Type::UtilityBill: - return lang(lng_passport_address_bill); + return tr::lng_passport_address_bill(tr::now); case Value::Type::BankStatement: - return lang(lng_passport_address_statement); + return tr::lng_passport_address_statement(tr::now); case Value::Type::RentalAgreement: - return lang(lng_passport_address_agreement); + return tr::lng_passport_address_agreement(tr::now); case Value::Type::PassportRegistration: - return lang(lng_passport_address_registration); + return tr::lng_passport_address_registration(tr::now); case Value::Type::TemporaryRegistration: - return lang(lng_passport_address_temporary); + return tr::lng_passport_address_temporary(tr::now); default: Unexpected("AddressType in requestScopeFilesType"); } @@ -1109,11 +1109,11 @@ void PanelController::readScanError(ReadScanError error) { show(Box([&] { switch (error) { case ReadScanError::FileTooLarge: - return lang(lng_passport_error_too_large); + return tr::lng_passport_error_too_large(tr::now); case ReadScanError::BadImageSize: - return lang(lng_passport_error_bad_size); + return tr::lng_passport_error_bad_size(tr::now); case ReadScanError::CantReadImage: - return lang(lng_passport_error_cant_read); + return tr::lng_passport_error_cant_read(tr::now); case ReadScanError::Unknown: return Lang::Hard::UnknownSecureScanError(); } @@ -1391,7 +1391,7 @@ void PanelController::saveScope(ValueMap &&data, ValueMap &&filesData) { Expects(_panel != nullptr); if (uploadingScopeScan()) { - showToast(lang(lng_passport_wait_upload)); + showToast(tr::lng_passport_wait_upload(tr::now)); return; } else if (savingScope()) { return; @@ -1426,8 +1426,8 @@ void PanelController::cancelEditScope() { if (_panelHasUnsavedChanges && _panelHasUnsavedChanges()) { if (!_confirmForgetChangesBox) { _confirmForgetChangesBox = show(Box( - lang(lng_passport_sure_cancel), - lang(lng_continue), + tr::lng_passport_sure_cancel(tr::now), + tr::lng_continue(tr::now), [=] { _panel->showForm(); })); _editScopeBoxes.emplace_back(_confirmForgetChangesBox); } diff --git a/Telegram/SourceFiles/passport/passport_panel_details_row.cpp b/Telegram/SourceFiles/passport/passport_panel_details_row.cpp index f13409f35..2d23109c5 100644 --- a/Telegram/SourceFiles/passport/passport_panel_details_row.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_details_row.cpp @@ -302,7 +302,7 @@ void AbstractTextRow::finishInnerAnimating() { QString CountryString(const QString &code) { const auto name = CountrySelectBox::NameByISO(code); - return name.isEmpty() ? lang(lng_passport_country_choose) : name; + return name.isEmpty() ? tr::lng_passport_country_choose(tr::now) : name; } CountryRow::CountryRow( @@ -739,13 +739,13 @@ int DateRow::resizeInner(int left, int top, int width) { const auto addToWidth = st::passportDetailsSeparatorPadding.left(); const auto dayWidth = _st.textMargins.left() + _st.placeholderMargins.left() - + font->width(lang(lng_date_input_day)) + + font->width(tr::lng_date_input_day(tr::now)) + _st.placeholderMargins.right() + _st.textMargins.right() + addToWidth; const auto monthWidth = _st.textMargins.left() + _st.placeholderMargins.left() - + font->width(lang(lng_date_input_month)) + + font->width(tr::lng_date_input_month(tr::now)) + _st.placeholderMargins.right() + _st.textMargins.right() + addToWidth; @@ -850,14 +850,14 @@ GenderRow::GenderRow( this, _group, Gender::Male, - lang(lng_passport_gender_male), + tr::lng_passport_gender_male(tr::now), st::defaultCheckbox, createRadioView(_maleRadio)) , _female( this, _group, Gender::Female, - lang(lng_passport_gender_female), + tr::lng_passport_gender_female(tr::now), st::defaultCheckbox, createRadioView(_femaleRadio)) , _value(StringToGender(value) ? value : QString()) { diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp index a3099b5d2..3bd49b487 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp @@ -126,7 +126,7 @@ void VerifyBox::setupControls( st::boxDividerLabel), small); if (resend) { - auto link = TextWithEntities{ lang(lng_cloud_password_resend) }; + auto link = TextWithEntities{ tr::lng_cloud_password_resend(tr::now) }; link.entities.push_back({ EntityType::CustomUrl, 0, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp index 2fc28fd3c..bcdbcdfee 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp @@ -100,7 +100,7 @@ void RequestTypeBox::setupControls( Fn submit) { const auto header = Ui::CreateChild( this, - lang(lng_passport_document_type), + tr::lng_passport_document_type(tr::now), st::boxDividerLabel); const auto group = std::make_shared(0); @@ -681,7 +681,7 @@ object_ptr RequestIdentityType( std::vector labels) { return Box( tr::lng_passport_identity_title(), - lang(lng_passport_identity_about), + tr::lng_passport_identity_about(tr::now), std::move(labels), submit); } @@ -691,7 +691,7 @@ object_ptr RequestAddressType( std::vector labels) { return Box( tr::lng_passport_address_title(), - lang(lng_passport_address_about), + tr::lng_passport_address_about(tr::now), std::move(labels), submit); } diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp index fd6baf71c..f65f73914 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp @@ -525,7 +525,7 @@ void EditScans::setupScans(const QString &header) { } setupList(inner, FileType::Scan, header); - setupList(inner, FileType::Translation, lang(lng_passport_translation)); + setupList(inner, FileType::Translation, tr::lng_passport_translation(tr::now)); init(); } @@ -601,13 +601,13 @@ void EditScans::setupSpecialScans( const auto title = [&](FileType type) { switch (type) { case FileType::FrontSide: - return lang(requiresBothSides - ? lng_passport_front_side_title - : lng_passport_main_page_title); + return requiresBothSides + ? tr::lng_passport_front_side_title(tr::now) + : tr::lng_passport_main_page_title(tr::now); case FileType::ReverseSide: - return lang(lng_passport_reverse_side_title); + return tr::lng_passport_reverse_side_title(tr::now); case FileType::Selfie: - return lang(lng_passport_selfie_title); + return tr::lng_passport_selfie_title(tr::now); } Unexpected("Type in special row title."); }; @@ -706,7 +706,7 @@ void EditScans::setupSpecialScans( st::passportFormLabelPadding)); } - setupList(inner, FileType::Translation, lang(lng_passport_translation)); + setupList(inner, FileType::Translation, tr::lng_passport_translation(tr::now)); init(); } @@ -808,13 +808,13 @@ void EditScans::createSpecialScanRow( const auto name = [&] { switch (type) { case FileType::FrontSide: - return lang(requiresBothSides - ? lng_passport_front_side_title - : lng_passport_main_page_title); + return requiresBothSides + ? tr::lng_passport_front_side_title(tr::now) + : tr::lng_passport_main_page_title(tr::now); case FileType::ReverseSide: - return lang(lng_passport_reverse_side_title); + return tr::lng_passport_reverse_side_title(tr::now); case FileType::Selfie: - return lang(lng_passport_selfie_title); + return tr::lng_passport_selfie_title(tr::now); } Unexpected("Type in special file name."); }(); @@ -836,7 +836,7 @@ void EditScans::createSpecialScanRow( void EditScans::chooseScan(FileType type) { if (!_controller->canAddScan(type)) { - _controller->showToast(lang(lng_passport_scans_limit_reached)); + _controller->showToast(tr::lng_passport_scans_limit_reached(tr::now)); return; } ChooseScan(this, type, [=](QByteArray &&content) { @@ -928,7 +928,7 @@ void EditScans::ChooseScan( || (type == FileType::Translation); (allowMany ? FileDialog::GetOpenPaths : FileDialog::GetOpenPath)( parent, - lang(lng_passport_choose_image), + tr::lng_passport_choose_image(tr::now), filter, processOpened, nullptr); diff --git a/Telegram/SourceFiles/passport/passport_panel_form.cpp b/Telegram/SourceFiles/passport/passport_panel_form.cpp index bcd48288d..2649b00ee 100644 --- a/Telegram/SourceFiles/passport/passport_panel_form.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_form.cpp @@ -241,7 +241,7 @@ not_null PanelForm::setupContent() { inner, object_ptr( inner, - lang(lng_passport_request2), + tr::lng_passport_request2(tr::now), st::passportPasswordLabel)), st::passportFormAbout2Padding)->entity(); @@ -251,7 +251,7 @@ not_null PanelForm::setupContent() { inner->add( object_ptr( inner, - lang(lng_passport_header), + tr::lng_passport_header(tr::now), st::passportFormHeader), st::passportFormHeaderPadding); diff --git a/Telegram/SourceFiles/passport/passport_panel_password.cpp b/Telegram/SourceFiles/passport/passport_panel_password.cpp index 8d911f78b..d9c52484b 100644 --- a/Telegram/SourceFiles/passport/passport_panel_password.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_password.cpp @@ -39,14 +39,14 @@ PanelAskPassword::PanelAskPassword( st::passportPasswordLabelBold) , _about2( this, - lang(lng_passport_request2), + tr::lng_passport_request2(tr::now), st::passportPasswordLabel) , _password( this, st::defaultInputField, tr::lng_passport_password_placeholder()) , _submit(this, tr::lng_passport_next(), st::passportPasswordSubmit) -, _forgot(this, lang(lng_signin_recover), st::defaultLinkButton) { +, _forgot(this, tr::lng_signin_recover(tr::now), st::defaultLinkButton) { connect(_password, &Ui::PasswordInput::submitted, this, [=] { submit(); }); @@ -184,7 +184,7 @@ void PanelNoPassword::setupContent() { _inner, object_ptr( _inner, - lang(lng_passport_request2), + tr::lng_passport_request2(tr::now), st::passportPasswordLabel)), st::passportPasswordAbout2Padding)->entity(); @@ -205,7 +205,7 @@ void PanelNoPassword::setupContent() { _inner, object_ptr( _inner, - lang(lng_passport_create_password), + tr::lng_passport_create_password(tr::now), st::passportPasswordSetupLabel)), st::passportFormAbout2Padding)->entity(); @@ -220,7 +220,7 @@ void PanelNoPassword::refreshBottom() { object_ptr( _inner, (pattern.isEmpty() - ? lang(lng_passport_about_password) + ? tr::lng_passport_about_password(tr::now) : lng_passport_code_sent(lt_email, pattern)), st::passportPasswordSetupLabel)), st::passportFormAbout2Padding)->entity()); diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 48ed97f01..05c3bf965 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -165,7 +165,7 @@ private: Libs::notify_notification_set_timeout(_data, Libs::NOTIFY_EXPIRES_DEFAULT); if ((*guarded)->hasActionsSupport()) { - auto label = lang(lng_notification_reply).toUtf8(); + auto label = tr::lng_notification_reply(tr::now).toUtf8(); auto actionReceiver = _data; auto actionHandler = &NotificationData::notificationClicked; auto actionLabel = label.constData(); diff --git a/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm b/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm index ce048fc34..be7fe5342 100644 --- a/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm +++ b/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/mac/file_utilities_mac.h" #include "platform/mac/mac_utilities.h" +#include "lang/lang_keys.h" #include "styles/style_window.h" #include @@ -190,7 +191,7 @@ QString strNeedToRefresh2() { } [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; } - NSMenuItem *item = [menu insertItemWithTitle:NSlang(lng_mac_choose_program_menu) action:@selector(itemChosen:) keyEquivalent:@"" atIndex:index++]; + NSMenuItem *item = [menu insertItemWithTitle:Q2NSString(tr::lng_mac_choose_program_menu(tr::now)) action:@selector(itemChosen:) keyEquivalent:@"" atIndex:index++]; [item setTarget:self]; [menu popUpMenuPositioningItem:nil atLocation:CGPointMake(x, y) inView:nil]; @@ -273,7 +274,7 @@ QString strNeedToRefresh2() { - (id) init:(NSArray *)recommendedApps withPanel:(NSOpenPanel *)creator withSelector:(NSPopUpButton *)menu withGood:(NSTextField *)goodLabel withBad:(NSTextField *)badLabel withIcon:(NSImageView *)badIcon withAccessory:(NSView *)acc { if (self = [super init]) { onlyRecommended = YES; - recom = [NSlang(lng_mac_recommended_apps) copy]; + recom = [Q2NSString(tr::lng_mac_recommended_apps(tr::now)) copy]; apps = recommendedApps; panel = creator; selector = menu; @@ -428,13 +429,13 @@ bool UnsafeShowOpenWith(const QString &filepath) { NSPopUpButton *selector = [[NSPopUpButton alloc] init]; [accessory addSubview:selector]; - [selector addItemWithTitle:NSlang(lng_mac_recommended_apps)]; - [selector addItemWithTitle:NSlang(lng_mac_all_apps)]; + [selector addItemWithTitle:Q2NSString(tr::lng_mac_recommended_apps(tr::now))]; + [selector addItemWithTitle:Q2NSString(tr::lng_mac_all_apps(tr::now))]; [selector sizeToFit]; NSTextField *enableLabel = [[NSTextField alloc] init]; [accessory addSubview:enableLabel]; - [enableLabel setStringValue:NSlang(lng_mac_enable_filter)]; + [enableLabel setStringValue:Q2NSString(tr::lng_mac_enable_filter(tr::now))]; [enableLabel setFont:[selector font]]; [enableLabel setBezeled:NO]; [enableLabel setDrawsBackground:NO]; @@ -457,7 +458,7 @@ bool UnsafeShowOpenWith(const QString &filepath) { [accessory addSubview:button]; [button setButtonType:NSSwitchButton]; [button setFont:[selector font]]; - [button setTitle:NSlang(lng_mac_always_open_with)]; + [button setTitle:Q2NSString(tr::lng_mac_always_open_with(tr::now))]; [button sizeToFit]; NSRect alwaysRect = [button frame]; alwaysRect.origin.x = (fullRect.size.width - alwaysRect.size.width) / 2; @@ -510,8 +511,8 @@ bool UnsafeShowOpenWith(const QString &filepath) { [openPanel setCanChooseFiles:YES]; [openPanel setAllowsMultipleSelection:NO]; [openPanel setResolvesAliases:YES]; - [openPanel setTitle:NSlang(lng_mac_choose_app)]; - [openPanel setMessage:Q2NSString(lng_mac_choose_text(lt_file, NS2QString(name)))]; + [openPanel setTitle:Q2NSString(tr::lng_mac_choose_app(tr::now))]; + [openPanel setMessage:Q2NSString(tr::lng_mac_choose_text(tr::now, lt_file, NS2QString(name)))]; NSArray *appsPaths = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationDirectory inDomains:NSLocalDomainMask]; if ([appsPaths count]) [openPanel setDirectoryURL:[appsPaths firstObject]]; diff --git a/Telegram/SourceFiles/platform/mac/mac_touchbar.mm b/Telegram/SourceFiles/platform/mac/mac_touchbar.mm index e9bbd3933..97061bce7 100644 --- a/Telegram/SourceFiles/platform/mac/mac_touchbar.mm +++ b/Telegram/SourceFiles/platform/mac/mac_touchbar.mm @@ -9,6 +9,7 @@ #import "mac_touchbar.h" #import +#include "platform/mac/mac_utilities.h" #include "auth_session.h" #include "core/application.h" #include "core/sandbox.h" @@ -74,6 +75,8 @@ const NSTouchBarItemIdentifier kMonospaceItemIdentifier = [NSString stringWithFo const NSTouchBarItemIdentifier kClearItemIdentifier = [NSString stringWithFormat:@"%@.clear", kCustomizationIdMain]; const NSTouchBarItemIdentifier kLinkItemIdentifier = [NSString stringWithFormat:@"%@.link", kCustomizationIdMain]; +using Platform::Q2NSString; + NSImage *CreateNSImageFromStyleIcon(const style::icon &icon, int size = kIdealIconSize) { const auto instance = icon.instance(QColor(255, 255, 255, 255), 100); auto pixmap = QPixmap::fromImage(instance); @@ -83,10 +86,6 @@ NSImage *CreateNSImageFromStyleIcon(const style::icon &icon, int size = kIdealIc return image; } -NSString *NSStringFromLang(LangKey key) { - return [NSString stringWithUTF8String:lang(key).toUtf8().constData()]; -} - inline bool CurrentSongExists() { return Media::Player::instance()->current(kSongType).audio() != nullptr; } @@ -453,27 +452,27 @@ void SendKeyEvent(int command) { }], kBoldItemIdentifier: [NSMutableDictionary dictionaryWithDictionary:@{ @"type": @"textButton", - @"name": NSStringFromLang(lng_menu_formatting_bold), + @"name": Q2NSString(tr::lng_menu_formatting_bold(tr::now)), @"cmd": [NSNumber numberWithInt:kCommandBold], }], kItalicItemIdentifier: [NSMutableDictionary dictionaryWithDictionary:@{ @"type": @"textButton", - @"name": NSStringFromLang(lng_menu_formatting_italic), + @"name": Q2NSString(tr::lng_menu_formatting_italic(tr::now)), @"cmd": [NSNumber numberWithInt:kCommandItalic], }], kMonospaceItemIdentifier: [NSMutableDictionary dictionaryWithDictionary:@{ @"type": @"textButton", - @"name": NSStringFromLang(lng_menu_formatting_monospace), + @"name": Q2NSString(tr::lng_menu_formatting_monospace(tr::now)), @"cmd": [NSNumber numberWithInt:kCommandMonospace], }], kClearItemIdentifier: [NSMutableDictionary dictionaryWithDictionary:@{ @"type": @"textButton", - @"name": NSStringFromLang(lng_menu_formatting_clear), + @"name": Q2NSString(tr::lng_menu_formatting_clear(tr::now)), @"cmd": [NSNumber numberWithInt:kCommandClear], }], kLinkItemIdentifier: [NSMutableDictionary dictionaryWithDictionary:@{ @"type": @"textButton", - @"name": NSStringFromLang(lng_info_link_label), + @"name": Q2NSString(tr::lng_info_link_label(tr::now)), @"cmd": [NSNumber numberWithInt:kCommandLink], }], kPopoverInputItemIdentifier: [NSMutableDictionary dictionaryWithDictionary:@{ diff --git a/Telegram/SourceFiles/platform/mac/mac_utilities.h b/Telegram/SourceFiles/platform/mac/mac_utilities.h index bf73c1f34..319d247c0 100644 --- a/Telegram/SourceFiles/platform/mac/mac_utilities.h +++ b/Telegram/SourceFiles/platform/mac/mac_utilities.h @@ -7,8 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "lang/lang_keys.h" - #include namespace Platform { @@ -17,15 +15,10 @@ inline NSString *Q2NSString(const QString &str) { return [NSString stringWithUTF8String:str.toUtf8().constData()]; } -inline NSString *NSlang(LangKey key) { - return Q2NSString(lang(key)); -} - inline QString NS2QString(NSString *str) { return QString::fromUtf8([str cStringUsingEncoding:NSUTF8StringEncoding]); } - template inline QString MakeFromLetters(const uint32 (&letters)[Size]) { QString result; diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 85235a5d8..97137c32b 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -647,25 +647,25 @@ void MainWindow::createGlobalMenu() { about->setMenuRole(QAction::AboutQtRole); main->addSeparator(); - QAction *prefs = main->addAction(lang(lng_mac_menu_preferences), App::wnd(), SLOT(showSettings()), QKeySequence(Qt::ControlModifier | Qt::Key_Comma)); + QAction *prefs = main->addAction(tr::lng_mac_menu_preferences(tr::now), App::wnd(), SLOT(showSettings()), QKeySequence(Qt::ControlModifier | Qt::Key_Comma)); prefs->setMenuRole(QAction::PreferencesRole); - QMenu *file = psMainMenu.addMenu(lang(lng_mac_menu_file)); - psLogout = file->addAction(lang(lng_mac_menu_logout), App::wnd(), SLOT(onLogout())); + QMenu *file = psMainMenu.addMenu(tr::lng_mac_menu_file(tr::now)); + psLogout = file->addAction(tr::lng_mac_menu_logout(tr::now), App::wnd(), SLOT(onLogout())); - QMenu *edit = psMainMenu.addMenu(lang(lng_mac_menu_edit)); - psUndo = edit->addAction(lang(lng_mac_menu_undo), this, SLOT(psMacUndo()), QKeySequence::Undo); - psRedo = edit->addAction(lang(lng_mac_menu_redo), this, SLOT(psMacRedo()), QKeySequence::Redo); + QMenu *edit = psMainMenu.addMenu(tr::lng_mac_menu_edit(tr::now)); + psUndo = edit->addAction(tr::lng_mac_menu_undo(tr::now), this, SLOT(psMacUndo()), QKeySequence::Undo); + psRedo = edit->addAction(tr::lng_mac_menu_redo(tr::now), this, SLOT(psMacRedo()), QKeySequence::Redo); edit->addSeparator(); - psCut = edit->addAction(lang(lng_mac_menu_cut), this, SLOT(psMacCut()), QKeySequence::Cut); - psCopy = edit->addAction(lang(lng_mac_menu_copy), this, SLOT(psMacCopy()), QKeySequence::Copy); - psPaste = edit->addAction(lang(lng_mac_menu_paste), this, SLOT(psMacPaste()), QKeySequence::Paste); - psDelete = edit->addAction(lang(lng_mac_menu_delete), this, SLOT(psMacDelete()), QKeySequence(Qt::ControlModifier | Qt::Key_Backspace)); + psCut = edit->addAction(tr::lng_mac_menu_cut(tr::now), this, SLOT(psMacCut()), QKeySequence::Cut); + psCopy = edit->addAction(tr::lng_mac_menu_copy(tr::now), this, SLOT(psMacCopy()), QKeySequence::Copy); + psPaste = edit->addAction(tr::lng_mac_menu_paste(tr::now), this, SLOT(psMacPaste()), QKeySequence::Paste); + psDelete = edit->addAction(tr::lng_mac_menu_delete(tr::now), this, SLOT(psMacDelete()), QKeySequence(Qt::ControlModifier | Qt::Key_Backspace)); edit->addSeparator(); - psSelectAll = edit->addAction(lang(lng_mac_menu_select_all), this, SLOT(psMacSelectAll()), QKeySequence::SelectAll); + psSelectAll = edit->addAction(tr::lng_mac_menu_select_all(tr::now), this, SLOT(psMacSelectAll()), QKeySequence::SelectAll); - QMenu *window = psMainMenu.addMenu(lang(lng_mac_menu_window)); - psContacts = window->addAction(lang(lng_mac_menu_contacts)); + QMenu *window = psMainMenu.addMenu(tr::lng_mac_menu_window(tr::now)); + psContacts = window->addAction(tr::lng_mac_menu_contacts(tr::now)); connect(psContacts, &QAction::triggered, psContacts, crl::guard(this, [=] { if (isHidden()) { App::wnd()->showFromTray(); @@ -678,12 +678,12 @@ void MainWindow::createGlobalMenu() { box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); }); })); })); - psAddContact = window->addAction(lang(lng_mac_menu_add_contact), App::wnd(), SLOT(onShowAddContact())); + psAddContact = window->addAction(tr::lng_mac_menu_add_contact(tr::now), App::wnd(), SLOT(onShowAddContact())); window->addSeparator(); - psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup())); - psNewChannel = window->addAction(lang(lng_mac_menu_new_channel), App::wnd(), SLOT(onShowNewChannel())); + psNewGroup = window->addAction(tr::lng_mac_menu_new_group(tr::now), App::wnd(), SLOT(onShowNewGroup())); + psNewChannel = window->addAction(tr::lng_mac_menu_new_channel(tr::now), App::wnd(), SLOT(onShowNewChannel())); window->addSeparator(); - psShowTelegram = window->addAction(lang(lng_mac_menu_show), App::wnd(), SLOT(showFromTray())); + psShowTelegram = window->addAction(tr::lng_mac_menu_show(tr::now), App::wnd(), SLOT(showFromTray())); updateGlobalMenu(); } diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index 1dfdf35c4..bfdf48ea6 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -39,7 +39,6 @@ std::optional ApplicationIsActive; NSImage *qt_mac_create_nsimage(const QPixmap &pm); using Platform::Q2NSString; -using Platform::NSlang; using Platform::NS2QString; @interface qVisualize : NSObject { diff --git a/Telegram/SourceFiles/platform/win/file_utilities_win.cpp b/Telegram/SourceFiles/platform/win/file_utilities_win.cpp index 5155462b5..add7ff93b 100644 --- a/Telegram/SourceFiles/platform/win/file_utilities_win.cpp +++ b/Telegram/SourceFiles/platform/win/file_utilities_win.cpp @@ -203,7 +203,7 @@ bool UnsafeShowOpenWithDropdown(const QString &filepath, QPoint menuPosition) { menuInfo.fType = MFT_STRING; menuInfo.wID = handlers.size() + 1; - QString name = lang(lng_wnd_choose_program_menu); + QString name = tr::lng_wnd_choose_program_menu(tr::now); if (name.size() > 512) name = name.mid(0, 512); WCHAR nameArr[1024]; name.toWCharArray(nameArr); diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index a70927683..cd97f6f2a 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -691,7 +691,7 @@ void MainWindow::psSetupTrayIcon() { void MainWindow::showTrayTooltip() { if (trayIcon && !cSeenTrayTooltip()) { - trayIcon->showMessage(str_const_toString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000); + trayIcon->showMessage(str_const_toString(AppName), tr::lng_tray_icon_text(tr::now), QSystemTrayIcon::Information, 10000); cSetSeenTrayTooltip(true); Local::writeSettings(); } diff --git a/Telegram/SourceFiles/profile/profile_block_group_members.cpp b/Telegram/SourceFiles/profile/profile_block_group_members.cpp index 3929530af..6906042a4 100644 --- a/Telegram/SourceFiles/profile/profile_block_group_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_group_members.cpp @@ -41,7 +41,7 @@ GroupMembersWidget::GroupMembersWidget( QWidget *parent, PeerData *peer, const style::PeerListItem &st) -: PeerListWidget(parent, peer, QString(), st, lang(lng_profile_kick)) { +: PeerListWidget(parent, peer, QString(), st, tr::lng_profile_kick(tr::now)) { _updateOnlineTimer.setSingleShot(true); connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay())); @@ -82,7 +82,7 @@ void GroupMembersWidget::removePeer(PeerData *selectedPeer) { } return MTP_chatBannedRights(MTP_flags(0), MTP_int(0)); }(); - Ui::show(Box(text, lang(lng_box_remove), [user, currentRestrictedRights, peer = peer()] { + Ui::show(Box(text, tr::lng_box_remove(tr::now), [user, currentRestrictedRights, peer = peer()] { Ui::hideLayer(); if (const auto chat = peer->asChat()) { Auth().api().kickParticipant(chat, user); @@ -160,7 +160,9 @@ void GroupMembersWidget::updateItemStatusText(Item *item) { if (member->statusText.isEmpty() || (member->onlineTextTill <= _now)) { if (user->botInfo) { auto seesAllMessages = (user->botInfo->readsAllHistory || (member->adminState != Item::AdminState::None)); - member->statusText = lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all); + member->statusText = seesAllMessages + ? tr::lng_status_bot_reads_all(tr::now) + : tr::lng_status_bot_not_reads_all(tr::now); member->onlineTextTill = _now + 86400; } else { member->statusHasOnlineColor = Data::OnlineTextActive(member->onlineTill, _now); diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index 0ed64e5e7..2cb8d5136 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -47,11 +47,11 @@ void SetupConnectionType(not_null container) { const auto transport = MTP::dctransport(); if (Global::ProxySettings() != ProxyData::Settings::Enabled) { return transport.isEmpty() - ? lang(lng_connection_auto_connecting) + ? tr::lng_connection_auto_connecting(tr::now) : lng_connection_auto(lt_transport, transport); } else { return transport.isEmpty() - ? lang(lng_connection_proxy_connecting) + ? tr::lng_connection_proxy_connecting(tr::now) : lng_connection_proxy(lt_transport, transport); } }; @@ -143,7 +143,7 @@ void SetupUpdate(not_null container) { showDownloadProgress(checker.already(), checker.size()); break; case State::Ready: - texts->fire(lang(lng_settings_update_ready)); + texts->fire(tr::lng_settings_update_ready(tr::now)); update->show(); break; default: @@ -198,12 +198,12 @@ void SetupUpdate(not_null container) { checker.checking() | rpl::start_with_next([=] { options->setAttribute(Qt::WA_TransparentForMouseEvents); - texts->fire(lang(lng_settings_update_checking)); + texts->fire(tr::lng_settings_update_checking(tr::now)); downloading->fire(false); }, options->lifetime()); checker.isLatest() | rpl::start_with_next([=] { options->setAttribute(Qt::WA_TransparentForMouseEvents, false); - texts->fire(lang(lng_settings_latest_installed)); + texts->fire(tr::lng_settings_latest_installed(tr::now)); downloading->fire(false); }, options->lifetime()); checker.progress( @@ -212,12 +212,12 @@ void SetupUpdate(not_null container) { }, options->lifetime()); checker.failed() | rpl::start_with_next([=] { options->setAttribute(Qt::WA_TransparentForMouseEvents, false); - texts->fire(lang(lng_settings_update_fail)); + texts->fire(tr::lng_settings_update_fail(tr::now)); downloading->fire(false); }, options->lifetime()); checker.ready() | rpl::start_with_next([=] { options->setAttribute(Qt::WA_TransparentForMouseEvents, false); - texts->fire(lang(lng_settings_update_ready)); + texts->fire(tr::lng_settings_update_ready(tr::now)); update->show(); downloading->fire(false); }, options->lifetime()); @@ -243,19 +243,19 @@ bool HasTray() { } void SetupTrayContent(not_null container) { - const auto checkbox = [&](LangKey label, bool checked) { + const auto checkbox = [&](const QString &label, bool checked) { return object_ptr( container, - lang(label), + label, checked, st::settingsCheckbox); }; - const auto addCheckbox = [&](LangKey label, bool checked) { + const auto addCheckbox = [&](const QString &label, bool checked) { return container->add( checkbox(label, checked), st::settingsCheckboxPadding); }; - const auto addSlidingCheckbox = [&](LangKey label, bool checked) { + const auto addSlidingCheckbox = [&](const QString &label, bool checked) { return container->add( object_ptr>( container, @@ -269,7 +269,7 @@ void SetupTrayContent(not_null container) { || (workMode == dbiwmWindowAndTray); }; const auto tray = addCheckbox( - lng_settings_workmode_tray, + tr::lng_settings_workmode_tray(tr::now), trayEnabled()); const auto taskbarEnabled = [] { @@ -279,7 +279,7 @@ void SetupTrayContent(not_null container) { }; const auto taskbar = Platform::IsWindows() ? addCheckbox( - lng_settings_workmode_window, + tr::lng_settings_workmode_window(tr::now), taskbarEnabled()) : nullptr; @@ -328,13 +328,13 @@ void SetupTrayContent(not_null container) { }; const auto autostart = addCheckbox( - lng_settings_auto_start, + tr::lng_settings_auto_start(tr::now), cAutoStart()); const auto minimized = addSlidingCheckbox( - lng_settings_start_min, + tr::lng_settings_start_min(tr::now), minimizedToggled()); const auto sendto = addCheckbox( - lng_settings_add_sendto, + tr::lng_settings_add_sendto(tr::now), cSendToMenu()); autostart->checkedChanges( @@ -360,7 +360,7 @@ void SetupTrayContent(not_null container) { if (Global::LocalPasscode()) { minimized->entity()->setChecked(false); Ui::show(Box( - lang(lng_error_start_minimized_passcoded))); + tr::lng_error_start_minimized_passcoded(tr::now))); } else { cSetStartMinimized(checked); Local::writeSettings(); diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index 4e519fc33..7654982ec 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -69,7 +69,7 @@ void Calls::setupContent() { const auto currentOutputName = [&] { if (Global::CallOutputDeviceID() == qsl("default")) { - return lang(lng_settings_call_device_default); + return tr::lng_settings_call_device_default(tr::now); } const auto &list = VoIPController::EnumerateAudioOutputs(); const auto i = ranges::find( @@ -83,7 +83,7 @@ void Calls::setupContent() { const auto currentInputName = [&] { if (Global::CallInputDeviceID() == qsl("default")) { - return lang(lng_settings_call_device_default); + return tr::lng_settings_call_device_default(tr::now); } const auto &list = VoIPController::EnumerateAudioInputs(); const auto i = ranges::find( @@ -109,7 +109,7 @@ void Calls::setupContent() { )->addClickHandler([=] { const auto &devices = VoIPController::EnumerateAudioOutputs(); const auto options = ranges::view::concat( - ranges::view::single(lang(lng_settings_call_device_default)), + ranges::view::single(tr::lng_settings_call_device_default(tr::now)), devices | ranges::view::transform(getName) ) | ranges::to_vector; const auto i = ranges::find( @@ -184,7 +184,7 @@ void Calls::setupContent() { )->addClickHandler([=] { const auto &devices = VoIPController::EnumerateAudioInputs(); const auto options = ranges::view::concat( - ranges::view::single(lang(lng_settings_call_device_default)), + ranges::view::single(tr::lng_settings_call_device_default(tr::now)), devices | ranges::view::transform(getName) ) | ranges::to_vector; const auto i = ranges::find( @@ -249,7 +249,7 @@ void Calls::setupContent() { AddButton( content, rpl::single( - lang(lng_settings_call_test_mic) + tr::lng_settings_call_test_mic(tr::now) ) | rpl::then( _micTestTextStream.events() ), @@ -304,7 +304,7 @@ void Calls::setupContent() { const auto opened = Platform::OpenSystemSettings( Platform::SystemSettingsType::Audio); if (!opened) { - Ui::show(Box(lang(lng_linux_no_audio_prefs))); + Ui::show(Box(tr::lng_linux_no_audio_prefs(tr::now))); } }); AddSkip(content); @@ -336,25 +336,25 @@ void Calls::requestPermissionAndStartTestingMicrophone() { Ui::hideLayer(); }; Ui::show(Box( - lang(lng_no_mic_permission), - lang(lng_menu_settings), + tr::lng_no_mic_permission(tr::now), + tr::lng_menu_settings(tr::now), showSystemSettings)); } } void Calls::startTestingMicrophone() { - _micTestTextStream.fire(lang(lng_settings_call_stop_mic_test)); + _micTestTextStream.fire(tr::lng_settings_call_stop_mic_test(tr::now)); _levelUpdateTimer.callEach(50); _micTester = std::make_unique( Global::CallInputDeviceID().toStdString()); if (_micTester->Failed()) { stopTestingMicrophone(); - Ui::show(Box(lang(lng_call_error_audio_io))); + Ui::show(Box(tr::lng_call_error_audio_io(tr::now))); } } void Calls::stopTestingMicrophone() { - _micTestTextStream.fire(lang(lng_settings_call_test_mic)); + _micTestTextStream.fire(tr::lng_settings_call_test_mic(tr::now)); _levelUpdateTimer.cancel(); _micTester.reset(); _micTestLevel->setValue(0.0f); diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 527626612..5b97e6fe6 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -111,9 +111,9 @@ void ChooseFromFile(not_null parent); BackgroundRow::BackgroundRow(QWidget *parent) : RpWidget(parent) , _chooseFromGallery( this, - lang(lng_settings_bg_from_gallery), + tr::lng_settings_bg_from_gallery(tr::now), st::settingsLink) -, _chooseFromFile(this, lang(lng_settings_bg_from_file), st::settingsLink) +, _chooseFromFile(this, tr::lng_settings_bg_from_file(tr::now), st::settingsLink) , _radial([=](crl::time now) { radialAnimationCallback(now); }) { updateImage(); @@ -400,7 +400,7 @@ void ChooseFromFile(not_null parent) { }; FileDialog::GetOpenPath( parent.get(), - lang(lng_choose_image), + tr::lng_choose_image(tr::now), filters.join(qsl(";;")), crl::guard(parent, callback)); @@ -408,9 +408,9 @@ void ChooseFromFile(not_null parent) { QString DownloadPathText() { if (Global::DownloadPath().isEmpty()) { - return lang(lng_download_path_default); + return tr::lng_download_path_default(tr::now); } else if (Global::DownloadPath() == qsl("tmp")) { - return lang(lng_download_path_temp); + return tr::lng_download_path_temp(tr::now); } return QDir::toNativeSeparators(Global::DownloadPath()); } @@ -428,14 +428,14 @@ void SetupStickersEmoji(not_null container) { std::move(wrap), QMargins(0, 0, 0, st::settingsCheckbox.margin.bottom()))); - const auto checkbox = [&](LangKey label, bool checked) { + const auto checkbox = [&](const QString &label, bool checked) { return object_ptr( container, - lang(label), + label, checked, st::settingsCheckbox); }; - const auto add = [&](LangKey label, bool checked, auto &&handle) { + const auto add = [&](const QString &label, bool checked, auto &&handle) { inner->add( checkbox(label, checked), st::settingsCheckboxPadding @@ -445,7 +445,7 @@ void SetupStickersEmoji(not_null container) { inner->lifetime()); }; add( - lng_settings_replace_emojis, + tr::lng_settings_replace_emojis(tr::now), Global::ReplaceEmoji(), [](bool checked) { Global::SetReplaceEmoji(checked); @@ -454,7 +454,7 @@ void SetupStickersEmoji(not_null container) { }); add( - lng_settings_suggest_emoji, + tr::lng_settings_suggest_emoji(tr::now), Global::SuggestEmoji(), [](bool checked) { Global::SetSuggestEmoji(checked); @@ -462,7 +462,7 @@ void SetupStickersEmoji(not_null container) { }); add( - lng_settings_suggest_by_emoji, + tr::lng_settings_suggest_by_emoji(tr::now), Global::SuggestStickersByEmoji(), [](bool checked) { Global::SetSuggestStickersByEmoji(checked); @@ -513,24 +513,24 @@ void SetupMessages(not_null container) { const auto group = std::make_shared>( Auth().settings().sendSubmitWay()); - const auto add = [&](SendByType value, LangKey key) { + const auto add = [&](SendByType value, const QString &text) { inner->add( object_ptr>( inner, group, value, - lang(key), + text, st::settingsSendType), st::settingsSendTypePadding); }; const auto small = st::settingsSendTypePadding; const auto top = skip; - add(SendByType::Enter, lng_settings_send_enter); + add(SendByType::Enter, tr::lng_settings_send_enter(tr::now)); add( SendByType::CtrlEnter, (Platform::IsMac() - ? lng_settings_send_cmdenter - : lng_settings_send_ctrlenter)); + ? tr::lng_settings_send_cmdenter(tr::now) + : tr::lng_settings_send_ctrlenter(tr::now))); group->setChangedCallback([](SendByType value) { Auth().settings().setSendSubmitWay(value); @@ -677,7 +677,7 @@ void SetupChatBackground(not_null container) { const auto tile = inner->add( object_ptr( inner, - lang(lng_settings_bg_tile), + tr::lng_settings_bg_tile(tr::now), Window::Theme::Background()->tile(), st::settingsCheckbox), st::settingsSendTypePadding); @@ -686,7 +686,7 @@ void SetupChatBackground(not_null container) { inner, object_ptr( inner, - lang(lng_settings_adaptive_wide), + tr::lng_settings_adaptive_wide(tr::now), Global::AdaptiveForWide(), st::settingsCheckbox), st::settingsSendTypePadding)); diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 7cf8b27ef..9ce301522 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -173,11 +173,11 @@ void AddSubsectionTitle( void FillMenu(Fn showOther, MenuCallback addAction) { if (!Auth().supportMode()) { addAction( - lang(lng_settings_information), + tr::lng_settings_information(tr::now), [=] { showOther(Type::Information); }); } addAction( - lang(lng_settings_logout), + tr::lng_settings_logout(tr::now), [=] { App::wnd()->onLogout(); }); } diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index 336814e3b..059c01a51 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -71,12 +71,12 @@ void SetupPhoto( if (image.isNull() || image.width() > 10 * image.height() || image.height() > 10 * image.width()) { - Ui::show(Box(lang(lng_bad_photo))); + Ui::show(Box(tr::lng_bad_photo(tr::now))); return; } const auto box = Ui::show( - Box(image, lang(lng_settings_crop_profile))); + Box(image, tr::lng_settings_crop_profile(tr::now))); box->ready( ) | rpl::start_with_next([=](QImage &&image) { Auth().api().uploadPeerPhoto(self, std::move(image)); @@ -84,7 +84,7 @@ void SetupPhoto( }; FileDialog::GetOpenPath( upload, - lang(lng_choose_image), + tr::lng_choose_image(tr::now), filter, crl::guard(upload, callback)); }); diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index ab28e723e..0d25572ec 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -175,8 +175,8 @@ void SetupInterfaceScale( [=] { (*setScale)(cConfigScale()); }); }); Ui::show(Box( - lang(lng_settings_need_restart), - lang(lng_settings_restart_now), + tr::lng_settings_need_restart(tr::now), + tr::lng_settings_restart_now(tr::now), confirmed, cancelled)); } else if (scale != cConfigScale()) { @@ -247,9 +247,9 @@ void SetupHelp(not_null container) { Auth().api().requestSupportContact(ready); }); auto box = Box( - lang(lng_settings_ask_sure), - lang(lng_settings_ask_ok), - lang(lng_settings_faq_button), + tr::lng_settings_ask_sure(tr::now), + tr::lng_settings_ask_ok(tr::now), + tr::lng_settings_faq_button(tr::now), sure, OpenFaq); box->setStrictCancel(true); diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index d47e9c85d..680b34d9d 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -272,7 +272,7 @@ void NotificationsCount::prepareNotificationSampleLarge() { auto rectForName = rtlrect(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height, w); - auto notifyText = st::dialogsTextFont->elided(lang(lng_notification_sample), itemWidth); + auto notifyText = st::dialogsTextFont->elided(tr::lng_notification_sample(tr::now), itemWidth); p.setFont(st::dialogsTextFont); p.setPen(st::dialogsTextFgService); p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dialogsTextFont->ascent, notifyText); @@ -517,19 +517,19 @@ void SetupAdvancedNotifications(not_null container) { void SetupNotificationsContent(not_null container) { AddSubsectionTitle(container, tr::lng_settings_notify_title()); - const auto checkbox = [&](LangKey label, bool checked) { + const auto checkbox = [&](const QString &label, bool checked) { return object_ptr( container, - lang(label), + label, checked, st::settingsCheckbox); }; - const auto addCheckbox = [&](LangKey label, bool checked) { + const auto addCheckbox = [&](const QString &label, bool checked) { return container->add( checkbox(label, checked), st::settingsCheckboxPadding); }; - const auto addSlidingCheckbox = [&](LangKey label, bool checked) { + const auto addSlidingCheckbox = [&](const QString &label, bool checked) { return container->add( object_ptr>( container, @@ -537,16 +537,16 @@ void SetupNotificationsContent(not_null container) { st::settingsCheckboxPadding)); }; const auto desktop = addCheckbox( - lng_settings_desktop_notify, + tr::lng_settings_desktop_notify(tr::now), Global::DesktopNotify()); const auto name = addSlidingCheckbox( - lng_settings_show_name, + tr::lng_settings_show_name(tr::now), (Global::NotifyView() <= dbinvShowName)); const auto preview = addSlidingCheckbox( - lng_settings_show_preview, + tr::lng_settings_show_preview(tr::now), (Global::NotifyView() <= dbinvShowPreview)); const auto sound = addCheckbox( - lng_settings_sound_notify, + tr::lng_settings_sound_notify(tr::now), Global::SoundNotify()); AddSkip(container, st::settingsCheckboxesSkip); @@ -555,10 +555,10 @@ void SetupNotificationsContent(not_null container) { AddSubsectionTitle(container, tr::lng_settings_badge_title()); const auto muted = addCheckbox( - lng_settings_include_muted, + tr::lng_settings_include_muted(tr::now), Auth().settings().includeMutedCounter()); const auto count = addCheckbox( - lng_settings_count_unread, + tr::lng_settings_count_unread(tr::now), Auth().settings().countUnreadMessages()); @@ -568,7 +568,7 @@ void SetupNotificationsContent(not_null container) { AddSubsectionTitle(container, tr::lng_settings_events_title()); const auto joined = addCheckbox( - lng_settings_events_joined, + tr::lng_settings_events_joined(tr::now), !Auth().api().contactSignupSilentCurrent().value_or(false)); Auth().api().contactSignupSilent( ) | rpl::start_with_next([=](bool silent) { @@ -583,7 +583,7 @@ void SetupNotificationsContent(not_null container) { }, joined->lifetime()); const auto pinned = addCheckbox( - lng_settings_events_pinned, + tr::lng_settings_events_pinned(tr::now), Auth().settings().notifyAboutPinned()); Auth().settings().notifyAboutPinnedChanges( ) | rpl::start_with_next([=](bool notify) { @@ -597,18 +597,18 @@ void SetupNotificationsContent(not_null container) { Auth().saveSettingsDelayed(); }, joined->lifetime()); - const auto nativeKey = [&] { + const auto nativeText = [&] { if (!Platform::Notifications::Supported()) { - return LangKey(); + return QString(); } else if (Platform::IsWindows()) { - return lng_settings_use_windows; + return tr::lng_settings_use_windows(tr::now); } else if (Platform::IsLinux()) { - return lng_settings_use_native_notifications; + return tr::lng_settings_use_native_notifications(tr::now); } - return LangKey(); + return QString(); }(); const auto native = [&]() -> Ui::Checkbox* { - if (!nativeKey) { + if (nativeText.isEmpty()) { return nullptr; } @@ -616,7 +616,7 @@ void SetupNotificationsContent(not_null container) { AddDivider(container); AddSkip(container, st::settingsCheckboxesSkip); AddSubsectionTitle(container, tr::lng_settings_native_title()); - return addCheckbox(nativeKey, Global::NativeNotifications()); + return addCheckbox(nativeText, Global::NativeNotifications()); }(); const auto advancedSlide = !Platform::IsMac10_8OrGreater() diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index ef12f5f68..e17a54974 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -81,7 +81,7 @@ void BlockUserBoxController::updateIsBlocked(not_null row, UserDat auto blocked = user->isBlocked(); row->setDisabledState(blocked ? PeerListRow::State::DisabledChecked : PeerListRow::State::Active); if (blocked) { - row->setCustomStatus(lang(lng_blocked_list_already_blocked)); + row->setCustomStatus(tr::lng_blocked_list_already_blocked(tr::now)); } else { row->clearCustomStatus(); } @@ -155,7 +155,7 @@ AdminLog::OwnedItem GenerateForwardedItem( void BlockedBoxController::prepare() { delegate()->peerListSetTitle(tr::lng_blocked_list_title()); - setDescriptionText(lang(lng_contacts_loading)); + setDescriptionText(tr::lng_contacts_loading(tr::now)); delegate()->peerListRefreshRows(); subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [this](const Notify::PeerUpdate &update) { @@ -169,7 +169,7 @@ void BlockedBoxController::prepare() { ) | rpl::take( 1 ) | rpl::start_with_next([=](const ApiWrap::BlockedUsersSlice &result) { - setDescriptionText(lang(lng_blocked_list_about)); + setDescriptionText(tr::lng_blocked_list_about(tr::now)); _loadRequestId = 0; _offset = result.list.size(); _allLoaded = (_offset >= result.total); @@ -286,18 +286,18 @@ bool BlockedBoxController::prependRow(not_null user) { std::unique_ptr BlockedBoxController::createRow( not_null user) const { auto row = std::make_unique(user); - row->setActionLink(lang((user->isBot() && !user->isSupport()) - ? lng_blocked_list_restart - : lng_blocked_list_unblock)); + row->setActionLink((user->isBot() && !user->isSupport()) + ? tr::lng_blocked_list_restart(tr::now) + : tr::lng_blocked_list_unblock(tr::now)); const auto status = [&] { if (!user->phone().isEmpty()) { return App::formatPhone(user->phone()); } else if (!user->username.isEmpty()) { return '@' + user->username; } else if (user->botInfo) { - return lang(lng_status_bot); + return tr::lng_status_bot(tr::now); } - return lang(lng_blocked_list_unknown_phone); + return tr::lng_blocked_list_unknown_phone(tr::now); }(); row->setCustomStatus(status); return std::move(row); @@ -403,9 +403,9 @@ void LastSeenPrivacyController::confirmSave(bool someAreDisallowed, FnMut( - lang(lng_edit_privacy_lastseen_warning), - lang(lng_continue), - lang(lng_cancel), + tr::lng_edit_privacy_lastseen_warning(tr::now), + tr::lng_continue(tr::now), + tr::lng_cancel(tr::now), std::move(callback)); *weakBox = Ui::show(std::move(box), LayerOption::KeepOther); } else { @@ -528,12 +528,12 @@ rpl::producer CallsPeer2PeerPrivacyController::optionsTitleKey() { return tr::lng_edit_privacy_calls_p2p_header(); } -LangKey CallsPeer2PeerPrivacyController::optionLabelKey( +QString CallsPeer2PeerPrivacyController::optionLabel( EditPrivacyBox::Option option) { switch (option) { - case Option::Everyone: return lng_edit_privacy_calls_p2p_everyone; - case Option::Contacts: return lng_edit_privacy_calls_p2p_contacts; - case Option::Nobody: return lng_edit_privacy_calls_p2p_nobody; + case Option::Everyone: return tr::lng_edit_privacy_calls_p2p_everyone(tr::now); + case Option::Contacts: return tr::lng_edit_privacy_calls_p2p_contacts(tr::now); + case Option::Nobody: return tr::lng_edit_privacy_calls_p2p_nobody(tr::now); } Unexpected("Option value in optionsLabelKey."); } @@ -616,7 +616,7 @@ object_ptr ForwardsPrivacyController::setupAboveWidget( delegate(), Auth().data().history( peerFromUser(PeerData::kServiceNotificationsId)), - lang(lng_edit_privacy_forwards_sample_message)); + tr::lng_edit_privacy_forwards_sample_message(tr::now)); const auto view = message.get(); auto result = object_ptr(parent); @@ -678,9 +678,12 @@ void ForwardsPrivacyController::PaintForwardedTooltip( const auto phrase = lng_forwarded( lt_user, App::peerName(view->data()->history()->session().user())); - const auto possiblePosition = Lang::FindTagReplacementPosition( - lang(lng_forwarded__tagged), - lt_user); + const auto kReplacementPosition = QChar(0x0001); + const auto possiblePosition = tr::lng_forwarded( + tr::now, + lt_user, + QString(1, kReplacementPosition) + ).indexOf(kReplacementPosition); const auto position = (possiblePosition >= 0 && possiblePosition < phrase.size()) ? possiblePosition @@ -691,18 +694,17 @@ void ForwardsPrivacyController::PaintForwardedTooltip( < 2 * st::msgServiceFont->height; const auto nameLeft = skip + (small ? st::msgServiceFont->width(before) : 0); const auto right = skip + innerWidth; - const auto key = [&] { + const auto text = [&] { switch (value) { case Option::Everyone: - return lng_edit_privacy_forwards_sample_everyone; + return tr::lng_edit_privacy_forwards_sample_everyone(tr::now); case Option::Contacts: - return lng_edit_privacy_forwards_sample_contacts; + return tr::lng_edit_privacy_forwards_sample_contacts(tr::now); case Option::Nobody: - return lng_edit_privacy_forwards_sample_nobody; + return tr::lng_edit_privacy_forwards_sample_nobody(tr::now); } Unexpected("Option value in ForwardsPrivacyController."); }(); - const auto text = lang(key); const auto &font = st::toastTextStyle.font; const auto textWidth = font->width(text); const auto arrowSkip = st::settingsForwardPrivacyArrowSkip; diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.h b/Telegram/SourceFiles/settings/settings_privacy_controllers.h index a59b12366..83e25b4f5 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.h +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.h @@ -125,7 +125,7 @@ public: rpl::producer title() override; rpl::producer optionsTitleKey() override; - LangKey optionLabelKey(EditPrivacyBox::Option option) override; + QString optionLabel(EditPrivacyBox::Option option) override; rpl::producer warning() override; rpl::producer exceptionButtonTextKey( Exception exception) override; diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index bedb038aa..99b7ed17e 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -49,30 +49,27 @@ rpl::producer<> PasscodeChanges() { } QString PrivacyBase(Privacy::Key key, Privacy::Option option) { - const auto phrase = [&] { - using Key = Privacy::Key; - using Option = Privacy::Option; - switch (key) { - case Key::CallsPeer2Peer: - switch (option) { - case Option::Everyone: - return lng_edit_privacy_calls_p2p_everyone; - case Option::Contacts: - return lng_edit_privacy_calls_p2p_contacts; - case Option::Nobody: - return lng_edit_privacy_calls_p2p_nobody; - } - Unexpected("Value in Privacy::Option."); - default: - switch (option) { - case Option::Everyone: return lng_edit_privacy_everyone; - case Option::Contacts: return lng_edit_privacy_contacts; - case Option::Nobody: return lng_edit_privacy_nobody; - } - Unexpected("Value in Privacy::Option."); + using Key = Privacy::Key; + using Option = Privacy::Option; + switch (key) { + case Key::CallsPeer2Peer: + switch (option) { + case Option::Everyone: + return tr::lng_edit_privacy_calls_p2p_everyone(tr::now); + case Option::Contacts: + return tr::lng_edit_privacy_calls_p2p_contacts(tr::now); + case Option::Nobody: + return tr::lng_edit_privacy_calls_p2p_nobody(tr::now); } - }(); - return lang(phrase); + Unexpected("Value in Privacy::Option."); + default: + switch (option) { + case Option::Everyone: return tr::lng_edit_privacy_everyone(tr::now); + case Option::Contacts: return tr::lng_edit_privacy_contacts(tr::now); + case Option::Nobody: return tr::lng_edit_privacy_nobody(tr::now); + } + Unexpected("Value in Privacy::Option."); + } } rpl::producer PrivacyString(Privacy::Key key) { @@ -260,7 +257,7 @@ void SetupCloudPassword(not_null container) { return state.unconfirmedPattern; }); auto confirmation = rpl::single( - lang(lng_profile_loading) + tr::lng_profile_loading(tr::now) ) | rpl::then(rpl::duplicate( pattern ) | rpl::filter([](const QString &pattern) { @@ -531,8 +528,8 @@ object_ptr CloudPasswordAppOutdatedBox() { if (*box) (*box)->closeBox(); }; auto result = Box( - lang(lng_passport_app_out_of_date), - lang(lng_menu_update), + tr::lng_passport_app_out_of_date(tr::now), + tr::lng_menu_update(tr::now), callback); *box = result.data(); return std::move(result); diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 0fbd6e8f8..1fe02b343 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -3484,13 +3484,13 @@ void _readStickerSets(FileKey &stickersKey, Stickers::Order *outOrder = nullptr, setFlags = MTPDstickerSet::Flags::from_raw(setFlagsValue); if (setId == Stickers::DefaultSetId) { - setTitle = lang(lng_stickers_default_set); + setTitle = tr::lng_stickers_default_set(tr::now); setFlags |= MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special; } else if (setId == Stickers::CustomSetId) { setTitle = qsl("Custom stickers"); setFlags |= MTPDstickerSet_ClientFlag::f_special; } else if (setId == Stickers::CloudRecentSetId) { - setTitle = lang(lng_recent_stickers); + setTitle = tr::lng_recent_stickers(tr::now); setFlags |= MTPDstickerSet_ClientFlag::f_special; } else if (setId == Stickers::FavedSetId) { setTitle = Lang::Hard::FavedSetTitle(); @@ -3721,7 +3721,7 @@ void importOldRecentStickers() { auto &def = sets.insert(Stickers::DefaultSetId, Stickers::Set( Stickers::DefaultSetId, uint64(0), - lang(lng_stickers_default_set), + tr::lng_stickers_default_set(tr::now), QString(), 0, // count 0, // hash diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 5a6320691..b2c440f57 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -77,7 +77,7 @@ QString findValidCode(QString fullCode) { CountryInput::CountryInput(QWidget *parent, const style::InputField &st) : TWidget(parent) , _st(st) -, _text(lang(lng_country_code)) { +, _text(tr::lng_country_code(tr::now)) { initCountries(); resize(_st.width, _st.heightMin); @@ -85,7 +85,7 @@ CountryInput::CountryInput(QWidget *parent, const style::InputField &st) : TWidg auto placeholderFont = _st.placeholderFont->f; placeholderFont.setStyleStrategy(QFont::PreferMatch); auto metrics = QFontMetrics(placeholderFont); - auto placeholder = QString();// metrics.elidedText(lang(lng_country_fake_ph), Qt::ElideRight, availableWidth); + auto placeholder = QString();// metrics.elidedText(tr::lng_country_fake_ph(tr::now), Qt::ElideRight, availableWidth); if (!placeholder.isNull()) { _placeholderPath.addText(0, QFontMetrics(placeholderFont).ascent(), placeholderFont, placeholder); } @@ -169,10 +169,10 @@ void CountryInput::onChooseCode(const QString &code) { _chosenIso = lastValidISO = info->iso2; setText(QString::fromUtf8(info->name)); } else { - setText(lang(lng_bad_country_code)); + setText(tr::lng_bad_country_code(tr::now)); } } else { - setText(lang(lng_country_code)); + setText(tr::lng_country_code(tr::now)); } update(); } @@ -389,7 +389,7 @@ void CountrySelectBox::Inner::paintEvent(QPaintEvent *e) { p.fillRect(r, st::boxBg); p.setFont(st::noContactsFont); p.setPen(st::noContactsColor); - p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_country_none), style::al_center); + p.drawText(QRect(0, 0, width(), st::noContactsHeight), tr::lng_country_none(tr::now), style::al_center); } } diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index cab5624df..cca32ecf9 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -37,11 +37,11 @@ constexpr int kWideScale = 5; QString CropTitle(not_null peer) { if (peer->isChat() || peer->isMegagroup()) { - return lang(lng_create_group_crop); + return tr::lng_create_group_crop(tr::now); } else if (peer->isChannel()) { - return lang(lng_create_channel_crop); + return tr::lng_create_channel_crop(tr::now); } else { - return lang(lng_settings_crop_profile); + return tr::lng_settings_crop_profile(tr::now); } } @@ -70,7 +70,7 @@ void SuggestPhoto( || badAspect(image.width(), image.height()) || badAspect(image.height(), image.width())) { Ui::show( - Box(lang(lng_bad_photo)), + Box(tr::lng_bad_photo(tr::now)), LayerOption::KeepOther); return; } @@ -125,7 +125,7 @@ void ShowChoosePhotoBox( }; FileDialog::GetOpenPath( parent, - lang(lng_choose_image), + tr::lng_choose_image(tr::now), filter, std::move(handleChosenPhoto)); } @@ -1021,7 +1021,9 @@ void SilentToggle::mouseReleaseEvent(QMouseEvent *e) { } QString SilentToggle::tooltipText() const { - return lang(_checked ? lng_wont_be_notified : lng_will_be_notified); + return _checked + ? tr::lng_wont_be_notified(tr::now) + : tr::lng_will_be_notified(tr::now); } QPoint SilentToggle::tooltipPos() const { diff --git a/Telegram/SourceFiles/ui/widgets/input_fields.cpp b/Telegram/SourceFiles/ui/widgets/input_fields.cpp index 170303961..334009d33 100644 --- a/Telegram/SourceFiles/ui/widgets/input_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/input_fields.cpp @@ -3298,7 +3298,7 @@ void InputField::addMarkdownActions( if (!_markdownEnabled) { return; } - const auto formatting = new QAction(lang(lng_menu_formatting), menu); + const auto formatting = new QAction(tr::lng_menu_formatting(tr::now), menu); addMarkdownMenuAction(menu, formatting); const auto submenu = new QMenu(menu); @@ -3316,48 +3316,48 @@ void InputField::addMarkdownActions( } const auto fullTag = GetFullSimpleTextTag(textWithTags); const auto add = [&]( - LangKey key, + const QString &base, QKeySequence sequence, bool disabled, auto callback) { const auto add = sequence.isEmpty() ? QString() : QChar('\t') + sequence.toString(QKeySequence::NativeText); - const auto action = new QAction(lang(key) + add, submenu); + const auto action = new QAction(base + add, submenu); connect(action, &QAction::triggered, this, callback); action->setDisabled(disabled); submenu->addAction(action); }; const auto addtag = [&]( - LangKey key, + const QString &base, QKeySequence sequence, const QString &tag) { const auto disabled = (fullTag == tag) || (fullTag == kTagPre && tag == kTagCode); - add(key, sequence, (!hasText || fullTag == tag), [=] { + add(base, sequence, (!hasText || fullTag == tag), [=] { toggleSelectionMarkdown(tag); }); }; const auto addlink = [&] { const auto selection = editLinkSelection(e); const auto data = selectionEditLinkData(selection); - const auto key = data.link.isEmpty() - ? lng_menu_formatting_link_create - : lng_menu_formatting_link_edit; - add(key, kEditLinkSequence, false, [=] { + const auto base = data.link.isEmpty() + ? tr::lng_menu_formatting_link_create(tr::now) + : tr::lng_menu_formatting_link_edit(tr::now); + add(base, kEditLinkSequence, false, [=] { editMarkdownLink(selection); }); }; const auto addclear = [&] { const auto disabled = !hasText || !hasTags; - add(lng_menu_formatting_clear, kClearFormatSequence, disabled, [=] { + add(tr::lng_menu_formatting_clear(tr::now), kClearFormatSequence, disabled, [=] { clearSelectionMarkdown(); }); }; - addtag(lng_menu_formatting_bold, QKeySequence::Bold, kTagBold); - addtag(lng_menu_formatting_italic, QKeySequence::Italic, kTagItalic); - addtag(lng_menu_formatting_monospace, kMonospaceSequence, kTagCode); + addtag(tr::lng_menu_formatting_bold(tr::now), QKeySequence::Bold, kTagBold); + addtag(tr::lng_menu_formatting_italic(tr::now), QKeySequence::Italic, kTagItalic); + addtag(tr::lng_menu_formatting_monospace(tr::now), kMonospaceSequence, kTagCode); if (_editLinkCallback) { submenu->addSeparator(); @@ -3982,7 +3982,7 @@ void CountryCodeInput::correctValue( } } -PhonePartInput::PhonePartInput(QWidget *parent, const style::InputField &st) : MaskedInputField(parent, st/*, lang(lng_phone_ph)*/) { +PhonePartInput::PhonePartInput(QWidget *parent, const style::InputField &st) : MaskedInputField(parent, st/*, tr::lng_phone_ph(tr::now)*/) { } void PhonePartInput::paintAdditionalPlaceholder(Painter &p) { @@ -4307,7 +4307,7 @@ void PhoneInput::correctValue( if (_pattern.isEmpty()) { newPlaceholder = QString(); } else if (_pattern.size() == 1 && _pattern.at(0) == digits.size()) { - newPlaceholder = QString(_pattern.at(0) + 2, ' ') + lang(lng_contact_phone); + newPlaceholder = QString(_pattern.at(0) + 2, ' ') + tr::lng_contact_phone(tr::now); } else { newPlaceholder.reserve(20); for (int i = 0, l = _pattern.size(); i < l; ++i) { diff --git a/Telegram/SourceFiles/ui/widgets/labels.cpp b/Telegram/SourceFiles/ui/widgets/labels.cpp index 9bdf8bbd0..ce9af754b 100644 --- a/Telegram/SourceFiles/ui/widgets/labels.cpp +++ b/Telegram/SourceFiles/ui/widgets/labels.cpp @@ -134,7 +134,7 @@ FlatLabel::FlatLabel(QWidget *parent, const style::FlatLabel &st) : RpWidget(parent) , _text(st.minWidth ? st.minWidth : QFIXED_MAX) , _st(st) -, _contextCopyText(lang(lng_context_copy_text)) { +, _contextCopyText(tr::lng_context_copy_text(tr::now)) { init(); } @@ -145,7 +145,7 @@ FlatLabel::FlatLabel( : RpWidget(parent) , _text(st.minWidth ? st.minWidth : QFIXED_MAX) , _st(st) -, _contextCopyText(lang(lng_context_copy_text)) { +, _contextCopyText(tr::lng_context_copy_text(tr::now)) { setText(text); init(); } @@ -157,7 +157,7 @@ FlatLabel::FlatLabel( : RpWidget(parent) , _text(st.minWidth ? st.minWidth : QFIXED_MAX) , _st(st) -, _contextCopyText(lang(lng_context_copy_text)) { +, _contextCopyText(tr::lng_context_copy_text(tr::now)) { textUpdated(); std::move( text @@ -173,7 +173,7 @@ FlatLabel::FlatLabel( : RpWidget(parent) , _text(st.minWidth ? st.minWidth : QFIXED_MAX) , _st(st) -, _contextCopyText(lang(lng_context_copy_text)) { +, _contextCopyText(tr::lng_context_copy_text(tr::now)) { textUpdated(); std::move( text @@ -571,7 +571,7 @@ void FlatLabel::showContextMenu(QContextMenuEvent *e, ContextMenuReason reason) if (fullSelection && !_contextCopyText.isEmpty()) { _contextMenu->addAction(_contextCopyText, this, SLOT(onCopyContextText())); } else if (uponSelection && !fullSelection) { - _contextMenu->addAction(lang(lng_context_copy_selected), this, SLOT(onCopySelectedText())); + _contextMenu->addAction(tr::lng_context_copy_selected(tr::now), this, SLOT(onCopySelectedText())); } else if (!hasSelection && !_contextCopyText.isEmpty()) { _contextMenu->addAction(_contextCopyText, this, SLOT(onCopyContextText())); } diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 6d43f0001..021dc3640 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -204,7 +204,7 @@ void MainWindow::checkLockByTerms() { void MainWindow::showTermsDecline() { const auto box = Ui::show( Box( - TextWithEntities{ lang(lng_terms_update_sorry) }, + TextWithEntities{ tr::lng_terms_update_sorry(tr::now) }, tr::lng_terms_decline_and_delete(), tr::lng_terms_back(), true), @@ -237,8 +237,8 @@ void MainWindow::showTermsDelete() { }; *box = Ui::show( Box( - lang(lng_terms_delete_warning), - lang(lng_terms_delete_now), + tr::lng_terms_delete_warning(tr::now), + tr::lng_terms_delete_now(tr::now), st::attentionBoxButton, deleteByTerms, [=] { if (*box) (*box)->closeBox(); }), diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 5b6c007c4..824d40868 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -518,9 +518,9 @@ void NativeManager::doShowNotification(HistoryItem *item, int forwardedCount) { const auto title = options.hideNameAndPhoto ? qsl("Telegram Desktop") : item->history()->peer->name; const auto subtitle = options.hideNameAndPhoto ? QString() : item->notificationHeader(); const auto text = options.hideMessageText - ? lang(lng_notification_preview) + ? tr::lng_notification_preview(tr::now) : (forwardedCount < 2 - ? (item->groupId() ? lang(lng_in_dlg_album) : item->notificationText()) + ? (item->groupId() ? tr::lng_in_dlg_album(tr::now) : item->notificationText()) : lng_forward_messages(lt_count, forwardedCount)); doShowNativeNotification( diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index a2252f5ee..71f944901 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -708,7 +708,7 @@ void Notification::updateNotifyDisplay() { p.drawText(r.left(), r.top() + st::dialogsTextFont->ascent, lng_forward_messages(lt_count, _forwardedCount)); } } else { - static QString notifyText = st::dialogsTextFont->elided(lang(lng_notification_preview), itemWidth); + static QString notifyText = st::dialogsTextFont->elided(tr::lng_notification_preview(tr::now), itemWidth); p.setFont(st::dialogsTextFont); p.setPen(st::dialogsTextFgService); p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dialogsTextFont->ascent, notifyText); @@ -958,7 +958,7 @@ void HideAllButton::paintEvent(QPaintEvent *e) { p.setFont(st::defaultLinkButton.font); p.setPen(_mouseOver ? st::lightButtonFgOver : st::lightButtonFg); - p.drawText(rect(), lang(lng_notification_hide_all), style::al_center); + p.drawText(rect(), tr::lng_notification_hide_all(tr::now), style::al_center); } } // namespace internal diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index 0e42827c9..05c560ea8 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -306,7 +306,7 @@ Editor::Inner::Inner(QWidget *parent, const QString &path) : TWidget(parent) if (update.type == BackgroundUpdate::Type::TestingTheme) { Revert(); App::CallDelayed(st::slideDuration, this, [] { - Ui::show(Box(lang(lng_theme_editor_cant_change_theme))); + Ui::show(Box(tr::lng_theme_editor_cant_change_theme(tr::now))); }); } }); @@ -394,7 +394,7 @@ void Editor::Inner::paintEvent(QPaintEvent *e) { p.setFont(st::boxTitleFont); p.setPen(st::windowFg); if (!_newRows->isHidden()) { - p.drawTextLeft(st::themeEditorMargin.left(), _existingRows->y() + _existingRows->height() + st::boxLayerTitlePosition.y(), width(), lang(lng_theme_editor_new_keys)); + p.drawTextLeft(st::themeEditorMargin.left(), _existingRows->y() + _existingRows->height() + st::boxLayerTitlePosition.y(), width(), tr::lng_theme_editor_new_keys(tr::now)); } } @@ -561,8 +561,8 @@ ThemeExportBox::ThemeExportBox(QWidget*, const QByteArray &paletteContent, const , _paletteContent(paletteContent) , _background(background) , _backgroundContent(backgroundContent) -, _chooseFromFile(this, lang(lng_settings_bg_from_file), st::boxLinkButton) -, _tileBackground(this, lang(lng_settings_bg_tile), tileBackground, st::defaultBoxCheckbox) { +, _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())); _chooseFromFile->setClickedCallback([this] { chooseBackgroundFromFile(); }); } @@ -621,7 +621,7 @@ void ThemeExportBox::updateThumbnail() { } void ThemeExportBox::chooseBackgroundFromFile() { - FileDialog::GetOpenPath(this, lang(lng_theme_editor_choose_image), "Image files (*.jpeg *.jpg *.png)", crl::guard(this, [this](const FileDialog::OpenResult &result) { + FileDialog::GetOpenPath(this, tr::lng_theme_editor_choose_image(tr::now), "Image files (*.jpeg *.jpg *.png)", crl::guard(this, [this](const FileDialog::OpenResult &result) { auto content = result.remoteContent; if (!result.paths.isEmpty()) { QFile f(result.paths.front()); @@ -648,7 +648,7 @@ void ThemeExportBox::chooseBackgroundFromFile() { void ThemeExportBox::exportTheme() { App::CallDelayed(st::defaultRippleAnimation.hideDuration, this, [this] { - auto caption = lang(lng_theme_editor_choose_name); + auto caption = tr::lng_theme_editor_choose_name(tr::now); auto filter = "Themes (*.tdesktop-theme)"; auto name = "awesome.tdesktop-theme"; FileDialog::GetWritePath(this, caption, filter, name, crl::guard(this, [this](const QString &path) { @@ -667,7 +667,7 @@ void ThemeExportBox::exportTheme() { if (zip.error() != ZIP_OK) { LOG(("Theme Error: could not export zip-ed theme, status: %1").arg(zip.error())); - Ui::show(Box(lang(lng_theme_editor_error))); + Ui::show(Box(tr::lng_theme_editor_error(tr::now))); return; } auto result = zip.result(); @@ -675,16 +675,16 @@ void ThemeExportBox::exportTheme() { QFile f(path); if (!f.open(QIODevice::WriteOnly)) { LOG(("Theme Error: could not open zip-ed theme file '%1' for writing").arg(path)); - Ui::show(Box(lang(lng_theme_editor_error))); + Ui::show(Box(tr::lng_theme_editor_error(tr::now))); return; } if (f.write(result) != result.size()) { LOG(("Theme Error: could not write zip-ed theme to file '%1'").arg(path)); - Ui::show(Box(lang(lng_theme_editor_error))); + Ui::show(Box(tr::lng_theme_editor_error(tr::now))); return; } Ui::hideLayer(); - Ui::Toast::Show(lang(lng_theme_editor_done)); + Ui::Toast::Show(tr::lng_theme_editor_done(tr::now)); })); }); } @@ -695,13 +695,13 @@ Editor::Editor(QWidget*, const QString &path) , _select(this, st::contactsMultiSelect, tr::lng_country_ph()) , _leftShadow(this) , _topShadow(this) -, _export(this, lang(lng_theme_editor_export_button).toUpper(), st::dialogsUpdateButton) { +, _export(this, tr::lng_theme_editor_export_button(tr::now).toUpper(), st::dialogsUpdateButton) { _inner = _scroll->setOwnedWidget(object_ptr(this, path)); _export->setClickedCallback(_inner->exportCallback()); _inner->setErrorCallback([this] { - Ui::show(Box(lang(lng_theme_editor_error))); + Ui::show(Box(tr::lng_theme_editor_error(tr::now))); // This could be from inner->_context observable notification. // We should not destroy it while iterating in subscribers. @@ -781,7 +781,7 @@ void Editor::paintEvent(QPaintEvent *e) { p.setFont(st::boxTitleFont); p.setPen(st::windowFg); - p.drawTextLeft(st::themeEditorMargin.left(), st::themeEditorMargin.top(), width(), lang(lng_theme_editor_title)); + p.drawTextLeft(st::themeEditorMargin.left(), st::themeEditorMargin.top(), width(), tr::lng_theme_editor_title(tr::now)); } void Editor::Start() { @@ -792,7 +792,7 @@ void Editor::Start() { writeDefaultPalette(path); } if (!Apply(path)) { - Ui::show(Box(lang(lng_theme_editor_error))); + Ui::show(Box(tr::lng_theme_editor_error(tr::now))); return; } KeepApplied(); @@ -802,7 +802,7 @@ void Editor::Start() { }; FileDialog::GetWritePath( App::wnd(), - lang(lng_theme_editor_save_palette), + tr::lng_theme_editor_save_palette(tr::now), "Palette (*.tdesktop-palette)", "colors.tdesktop-palette", start); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp index b9409ff68..c9cc01600 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp @@ -620,7 +620,7 @@ void EditorBlock::paintEvent(QPaintEvent *e) { p.fillRect(clip, st::dialogsBg); p.setFont(st::noContactsFont); p.setPen(st::noContactsColor); - p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_theme_editor_no_keys)); + p.drawText(QRect(0, 0, width(), st::noContactsHeight), tr::lng_theme_editor_no_keys(tr::now)); } auto cliptop = clip.y(); diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index d09a17938..7e473fc39 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -515,7 +515,7 @@ void Generator::paintComposeArea() { field.y() + st::historyComposeField.textMargins.top() + st::historyComposeField.placeholderMargins.top(), field.width() - st::historyComposeField.textMargins.left() - st::historyComposeField.textMargins.right(), field.height() - st::historyComposeField.textMargins.top() - st::historyComposeField.textMargins.bottom()); - _p->drawText(placeholderRect, lang(lng_message_ph), QTextOption(st::historyComposeField.placeholderAlign)); + _p->drawText(placeholderRect, tr::lng_message_ph(tr::now), QTextOption(st::historyComposeField.placeholderAlign)); _p->restore(); _p->setClipping(false); @@ -551,7 +551,7 @@ void Generator::paintDialogs() { auto phRect = QRect(filter.x() + st::dialogsFilter.textMrg.left() + st::dialogsFilter.phPos.x(), filter.y() + st::dialogsFilter.textMrg.top() + st::dialogsFilter.phPos.y(), filter.width() - st::dialogsFilter.textMrg.left() - st::dialogsFilter.textMrg.right(), filter.height() - st::dialogsFilter.textMrg.top() - st::dialogsFilter.textMrg.bottom());; _p->setFont(st::dialogsFilter.font); _p->setPen(st::dialogsFilter.phColor[_palette]); - _p->drawText(phRect, lang(lng_dlg_filter), QTextOption(st::dialogsFilter.phAlign)); + _p->drawText(phRect, tr::lng_dlg_filter(tr::now), QTextOption(st::dialogsFilter.phAlign)); _p->restore(); _p->setClipping(false); diff --git a/Telegram/SourceFiles/window/themes/window_theme_warning.cpp b/Telegram/SourceFiles/window/themes/window_theme_warning.cpp index c418925d6..3bab5c834 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_warning.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_warning.cpp @@ -63,7 +63,7 @@ void WarningWidget::paintEvent(QPaintEvent *e) { p.setFont(st::boxTitleFont); p.setPen(st::boxTitleFg); - p.drawTextLeft(_inner.x() + st::boxTitlePosition.x(), _inner.y() + st::boxTitlePosition.y(), width(), lang(lng_theme_sure_keep)); + p.drawTextLeft(_inner.x() + st::boxTitlePosition.x(), _inner.y() + st::boxTitlePosition.y(), width(), tr::lng_theme_sure_keep(tr::now)); p.setFont(st::boxTextFont); p.setPen(st::boxTextFg); diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index 72fdf5062..6bf645626 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -399,7 +399,7 @@ auto ConnectionState::computeLayout(const State &state) const -> Layout { || state.type == State::Type::Waiting; switch (state.type) { case State::Type::Connecting: - result.text = state.underCursor ? lang(lng_connecting) : QString(); + result.text = state.underCursor ? tr::lng_connecting(tr::now) : QString(); break; case State::Type::Waiting: @@ -419,7 +419,7 @@ auto ConnectionState::computeLayout(const State &state) const -> Layout { if (state.type == State::Type::Waiting) { result.contentWidth += st::connectingRetryLink.padding.left() + st::connectingRetryLink.font->width( - lang(lng_reconnecting_try_now)) + tr::lng_reconnecting_try_now(tr::now)) + st::connectingRetryLink.padding.right(); } result.hasRetry = (state.type == State::Type::Waiting); @@ -576,7 +576,7 @@ void ConnectionState::Widget::refreshRetryLink(bool hasRetry) { if (hasRetry && !_retry) { _retry = base::make_unique_q( this, - lang(lng_reconnecting_try_now), + tr::lng_reconnecting_try_now(tr::now), st::connectingRetryLink); _retry->addClickHandler([=] { MTP::restart(); diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index bad087173..29618af83 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -98,7 +98,7 @@ PasscodeLockWidget::PasscodeLockWidget(QWidget *parent) : LockWidget(parent) , _passcode(this, st::passcodeInput, tr::lng_passcode_ph()) , _submit(this, tr::lng_passcode_submit(), st::passcodeSubmit) -, _logout(this, lang(lng_passcode_logout)) { +, _logout(this, tr::lng_passcode_logout(tr::now)) { connect(_passcode, &Ui::MaskedInputField::changed, [=] { changed(); }); connect(_passcode, &Ui::MaskedInputField::submitted, [=] { submit(); }); @@ -111,7 +111,7 @@ void PasscodeLockWidget::paintContent(Painter &p) { p.setFont(st::passcodeHeaderFont); p.setPen(st::windowFg); - p.drawText(QRect(0, _passcode->y() - st::passcodeHeaderHeight, width(), st::passcodeHeaderHeight), lang(lng_passcode_enter), style::al_center); + p.drawText(QRect(0, _passcode->y() - st::passcodeHeaderHeight, width(), st::passcodeHeaderHeight), tr::lng_passcode_enter(tr::now), style::al_center); if (!_error.isEmpty()) { p.setFont(st::boxTextFont); @@ -126,7 +126,7 @@ void PasscodeLockWidget::submit() { return; } if (!passcodeCanTry()) { - _error = lang(lng_flood_error); + _error = tr::lng_flood_error(tr::now); _passcode->showError(); update(); return; @@ -147,7 +147,7 @@ void PasscodeLockWidget::submit() { } void PasscodeLockWidget::error() { - _error = lang(lng_passcode_wrong); + _error = tr::lng_passcode_wrong(tr::now); _passcode->selectAll(); _passcode->showError(); update(); diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 9ef50342a..761b2fed9 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -168,7 +168,7 @@ MainMenu::MainMenu( } _contextMenu = base::make_unique_q(this); _contextMenu->addAction( - lang(lng_context_archive_to_list), [=] { + tr::lng_context_archive_to_list(tr::now), [=] { _controller->session().settings().setArchiveInMainMenu(false); _controller->session().saveSettingsDelayed(); Ui::hideSettingsAndLayer(); @@ -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, lang(lng_menu_about))); + _version->setRichText(textcmdLink(1, lng_settings_current_version(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()); })); @@ -231,20 +231,20 @@ MainMenu::MainMenu( void MainMenu::refreshMenu() { _menu->clearActions(); if (!Auth().supportMode()) { - _menu->addAction(lang(lng_create_group_title), [] { + _menu->addAction(tr::lng_create_group_title(tr::now), [] { App::wnd()->onShowNewGroup(); }, &st::mainMenuNewGroup, &st::mainMenuNewGroupOver); - _menu->addAction(lang(lng_create_channel_title), [] { + _menu->addAction(tr::lng_create_channel_title(tr::now), [] { App::wnd()->onShowNewChannel(); }, &st::mainMenuNewChannel, &st::mainMenuNewChannelOver); - _menu->addAction(lang(lng_menu_contacts), [] { + _menu->addAction(tr::lng_menu_contacts(tr::now), [] { Ui::show(Box(std::make_unique(), [](not_null box) { box->addButton(tr::lng_close(), [box] { box->closeBox(); }); box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); }); })); }, &st::mainMenuContacts, &st::mainMenuContactsOver); if (Global::PhoneCallsEnabled()) { - _menu->addAction(lang(lng_menu_calls), [] { + _menu->addAction(tr::lng_menu_calls(tr::now), [] { Ui::show(Box(std::make_unique(), [](not_null box) { box->addButton(tr::lng_close(), [=] { box->closeBox(); @@ -258,7 +258,7 @@ void MainMenu::refreshMenu() { }, &st::mainMenuCalls, &st::mainMenuCallsOver); } } else { - _menu->addAction(lang(lng_profile_add_contact), [] { + _menu->addAction(tr::lng_profile_add_contact(tr::now), [] { App::wnd()->onShowAddContact(); }, &st::mainMenuContacts, &st::mainMenuContactsOver); @@ -275,12 +275,12 @@ void MainMenu::refreshMenu() { Auth().supportTemplates().reload(); }, &st::mainMenuReload, &st::mainMenuReloadOver); } - _menu->addAction(lang(lng_menu_settings), [] { + _menu->addAction(tr::lng_menu_settings(tr::now), [] { App::wnd()->showSettings(); }, &st::mainMenuSettings, &st::mainMenuSettingsOver); _nightThemeAction = std::make_shared>(); - auto action = _menu->addAction(lang(lng_menu_night_mode), [=] { + auto action = _menu->addAction(tr::lng_menu_night_mode(tr::now), [=] { if (auto action = *_nightThemeAction) { action->setChecked(!action->isChecked()); _nightThemeSwitch.callOnce(st::mainMenu.itemToggle.duration); diff --git a/Telegram/SourceFiles/window/window_outdated_bar.cpp b/Telegram/SourceFiles/window/window_outdated_bar.cpp index 18397726b..bdf91217c 100644 --- a/Telegram/SourceFiles/window/window_outdated_bar.cpp +++ b/Telegram/SourceFiles/window/window_outdated_bar.cpp @@ -57,7 +57,7 @@ Bar::Bar(not_null parent, QDate date) _details->setTryMakeSimilarLines(true); _details->setText(_soon ? lng_outdated_soon(lt_date, langDayOfMonthFull(date)) - : lang(lng_outdated_now)); + : tr::lng_outdated_now(tr::now)); } rpl::producer<> Bar::hideClicks() const { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 835dab342..38bbfe03f 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -233,9 +233,9 @@ void Filler::addTogglePin() { isPinned = history->isPinnedDialog(); } auto pinText = [](bool isPinned) { - return lang(isPinned - ? lng_context_unpin_from_top - : lng_context_pin_to_top); + return isPinned + ? tr::lng_context_unpin_from_top(tr::now) + : tr::lng_context_pin_to_top(tr::now); }; auto pinToggle = [=] { TogglePinnedDialog(peer->owner().history(peer)); @@ -255,18 +255,18 @@ void Filler::addTogglePin() { void Filler::addInfo() { const auto controller = _controller; const auto peer = _peer; - const auto infoKey = (peer->isChat() || peer->isMegagroup()) - ? lng_context_view_group + const auto text = (peer->isChat() || peer->isMegagroup()) + ? tr::lng_context_view_group(tr::now) : (peer->isUser() - ? lng_context_view_profile - : lng_context_view_channel); - _addAction(lang(infoKey), [=] { + ? tr::lng_context_view_profile(tr::now) + : tr::lng_context_view_channel(tr::now)); + _addAction(text, [=] { controller->showPeerInfo(peer); }); } //void Filler::addSearch() { -// _addAction(lang(lng_profile_search_messages), [peer = _peer] { +// _addAction(tr::lng_profile_search_messages(tr::now), [peer = _peer] { // App::main()->searchInChat(peer->owner().history(peer)); // }); //} @@ -281,9 +281,9 @@ void Filler::addToggleUnreadMark() { return false; }; const auto label = [=](not_null peer) { - return lang(isUnread(peer) - ? lng_context_mark_read - : lng_context_mark_unread); + return isUnread(peer) + ? tr::lng_context_mark_read(tr::now) + : tr::lng_context_mark_unread(tr::now); }; auto action = _addAction(label(peer), [=] { const auto markAsRead = isUnread(peer); @@ -324,20 +324,22 @@ void Filler::addToggleArchive() { !archived); }; _addAction( - lang(archived ? lng_archived_remove : lng_archived_add), + (archived + ? tr::lng_archived_remove(tr::now) + : tr::lng_archived_add(tr::now)), toggle); } void Filler::addBlockUser(not_null user) { const auto window = &_controller->window()->controller(); const auto blockText = [](not_null user) { - return lang(user->isBlocked() + return user->isBlocked() ? ((user->isBot() && !user->isSupport()) - ? lng_profile_restart_bot - : lng_profile_unblock_user) + ? tr::lng_profile_restart_bot(tr::now) + : tr::lng_profile_unblock_user(tr::now)) : ((user->isBot() && !user->isSupport()) - ? lng_profile_block_bot - : lng_profile_block_user)); + ? tr::lng_profile_block_bot(tr::now) + : tr::lng_profile_block_user(tr::now)); }; const auto blockAction = _addAction(blockText(user), [=] { if (user->isBlocked()) { @@ -372,38 +374,38 @@ void Filler::addUserActions(not_null user) { } if (!user->isContact() && !user->isSelf() && !user->isBot()) { _addAction( - lang(lng_info_add_as_contact), + tr::lng_info_add_as_contact(tr::now), [=] { window->show(Box(EditContactBox, window, user)); }); } if (user->canShareThisContact()) { _addAction( - lang(lng_info_share_contact), + tr::lng_info_share_contact(tr::now), [=] { PeerMenuShareContactBox(user); }); } if (user->isContact() && !user->isSelf()) { _addAction( - lang(lng_info_edit_contact), + tr::lng_info_edit_contact(tr::now), [=] { window->show(Box(EditContactBox, window, user)); }); _addAction( - lang(lng_info_delete_contact), + tr::lng_info_delete_contact(tr::now), [=] { PeerMenuDeleteContact(user); }); } if (user->isBot() && !user->botInfo->cantJoinGroups) { _addAction( - lang(lng_profile_invite_to_group), + tr::lng_profile_invite_to_group(tr::now), [=] { AddBotToGroupBoxController::Start(user); }); } if (user->canExportChatHistory()) { _addAction( - lang(lng_profile_export_chat), + tr::lng_profile_export_chat(tr::now), [=] { PeerMenuExportChat(user); }); } } _addAction( - lang(lng_profile_delete_conversation), + tr::lng_profile_delete_conversation(tr::now), DeleteAndLeaveHandler(user)); _addAction( - lang(lng_profile_clear_history), + tr::lng_profile_clear_history(tr::now), ClearHistoryHandler(user)); if (!user->isInaccessible() && user != Auth().user() @@ -416,32 +418,32 @@ void Filler::addChatActions(not_null chat) { if (_source != PeerMenuSource::ChatsList) { const auto controller = _controller; if (EditPeerInfoBox::Available(chat)) { - const auto text = lang(lng_manage_group_title); + const auto text = tr::lng_manage_group_title(tr::now); _addAction(text, [=] { controller->showEditPeerBox(chat); }); } if (chat->canAddMembers()) { _addAction( - lang(lng_profile_add_participant), + tr::lng_profile_add_participant(tr::now), [chat] { AddChatMembers(chat); }); } if (chat->canSendPolls()) { _addAction( - lang(lng_polls_create), + tr::lng_polls_create(tr::now), [=] { PeerMenuCreatePoll(chat); }); } if (chat->canExportChatHistory()) { _addAction( - lang(lng_profile_export_chat), + tr::lng_profile_export_chat(tr::now), [=] { PeerMenuExportChat(chat); }); } } _addAction( - lang(lng_profile_clear_and_exit), + tr::lng_profile_clear_and_exit(tr::now), DeleteAndLeaveHandler(_peer)); _addAction( - lang(lng_profile_clear_history), + tr::lng_profile_clear_history(tr::now), ClearHistoryHandler(_peer)); } @@ -452,52 +454,52 @@ void Filler::addChannelActions(not_null channel) { // const auto grouped = (feed != nullptr); // if (!grouped || feed->channels().size() > 1) { // _addAction( // #feed - // lang(grouped ? lng_feed_ungroup : lng_feed_group), + // (grouped ? tr::lng_feed_ungroup(tr::now) : tr::lng_feed_group(tr::now)), // [=] { ToggleChannelGrouping(channel, !grouped); }); // } //} if (_source != PeerMenuSource::ChatsList) { if (EditPeerInfoBox::Available(channel)) { const auto controller = _controller; - const auto text = lang(isGroup - ? lng_manage_group_title - : lng_manage_channel_title); + const auto text = isGroup + ? tr::lng_manage_group_title(tr::now) + : tr::lng_manage_channel_title(tr::now); _addAction(text, [=] { controller->showEditPeerBox(channel); }); } if (channel->canAddMembers()) { _addAction( - lang(lng_channel_add_members), + tr::lng_channel_add_members(tr::now), [channel] { PeerMenuAddChannelMembers(channel); }); } if (channel->canSendPolls()) { _addAction( - lang(lng_polls_create), + tr::lng_polls_create(tr::now), [=] { PeerMenuCreatePoll(channel); }); } if (channel->canExportChatHistory()) { _addAction( - lang(isGroup - ? lng_profile_export_chat - : lng_profile_export_channel), + (isGroup + ? tr::lng_profile_export_chat(tr::now) + : tr::lng_profile_export_channel(tr::now)), [=] { PeerMenuExportChat(channel); }); } } if (channel->amIn()) { if (isGroup && !channel->isPublic()) { _addAction( - lang(lng_profile_clear_history), + tr::lng_profile_clear_history(tr::now), ClearHistoryHandler(channel)); } - auto text = lang(isGroup - ? lng_profile_leave_group - : lng_profile_leave_channel); + auto text = isGroup + ? tr::lng_profile_leave_group(tr::now) + : tr::lng_profile_leave_channel(tr::now); _addAction(text, DeleteAndLeaveHandler(channel)); } else { - auto text = lang(isGroup - ? lng_profile_join_group - : lng_profile_join_channel); + auto text = isGroup + ? tr::lng_profile_join_group(tr::now) + : tr::lng_profile_join_channel(tr::now); _addAction( text, [channel] { Auth().api().joinChannel(channel); }); @@ -506,7 +508,7 @@ void Filler::addChannelActions(not_null channel) { auto needReport = !channel->amCreator() && (!isGroup || channel->isPublic()); if (needReport) { - _addAction(lang(lng_profile_report), [channel] { + _addAction(tr::lng_profile_report(tr::now), [channel] { Ui::show(Box(channel)); }); } @@ -563,17 +565,17 @@ void FolderFiller::addTogglesForArchive() { } const auto controller = _controller; const auto hidden = controller->session().settings().archiveCollapsed(); - const auto text = lang(hidden - ? lng_context_archive_expand - : lng_context_archive_collapse); + const auto text = hidden + ? tr::lng_context_archive_expand(tr::now) + : tr::lng_context_archive_collapse(tr::now); _addAction(text, [=] { controller->session().settings().setArchiveCollapsed(!hidden); controller->session().saveSettingsDelayed(); }); - _addAction(lang(lng_context_archive_to_menu), [=] { + _addAction(tr::lng_context_archive_to_menu(tr::now), [=] { Ui::Toast::Config toast; - toast.text = lang(lng_context_archive_to_menu_info); + toast.text = tr::lng_context_archive_to_menu_info(tr::now); toast.maxWidth = st::boxWideWidth; toast.durationMs = kArchivedToastDuration; Ui::Toast::Show(toast); @@ -587,7 +589,7 @@ void FolderFiller::addTogglesForArchive() { //void FolderFiller::addInfo() { // auto controller = _controller; // auto feed = _feed; -// _addAction(lang(lng_context_view_feed_info), [=] { +// _addAction(tr::lng_context_view_feed_info(tr::now), [=] { // controller->showSection(Info::Memento( // feed, // Info::Section(Info::Section::Type::Profile))); @@ -596,21 +598,21 @@ void FolderFiller::addTogglesForArchive() { // //void FolderFiller::addNotifications() { // const auto feed = _feed; -// _addAction(lang(lng_feed_notifications), [=] { +// _addAction(tr::lng_feed_notifications(tr::now), [=] { // Info::FeedProfile::NotificationsController::Start(feed); // }); //} // //void FolderFiller::addSearch() { // const auto feed = _feed; -// _addAction(lang(lng_profile_search_messages), [=] { +// _addAction(tr::lng_profile_search_messages(tr::now), [=] { // App::main()->searchInChat(feed); // }); //} // //void FolderFiller::addUngroup() { // const auto feed = _feed; -// //_addAction(lang(lng_feed_ungroup_all), [=] { // #feed +// //_addAction(tr::lng_feed_ungroup_all(tr::now), [=] { // #feed // // PeerMenuUngroupFeed(feed); // //}); //} @@ -635,7 +637,7 @@ void PeerMenuDeleteContact(not_null user) { }; Ui::show(Box( text, - lang(lng_box_delete), + tr::lng_box_delete(tr::now), deleteSure)); } @@ -644,13 +646,13 @@ void PeerMenuShareContactBox(not_null user) { auto callback = [=](not_null peer) { if (!peer->canWrite()) { Ui::show(Box( - lang(lng_forward_share_cant)), + tr::lng_forward_share_cant(tr::now)), LayerOption::KeepOther); return; } else if (peer->isSelf()) { auto options = ApiWrap::SendOptions(peer->owner().history(peer)); Auth().api().shareContact(user, options); - Ui::Toast::Show(lang(lng_share_done)); + Ui::Toast::Show(tr::lng_share_done(tr::now)); if (auto strong = *weak) { strong->closeBox(); } @@ -661,7 +663,7 @@ void PeerMenuShareContactBox(not_null user) { : '\xAB' + peer->name + '\xBB'; Ui::show(Box( lng_forward_share_contact(lt_recipient, recipient), - lang(lng_forward_send), + tr::lng_forward_send(tr::now), [peer, user] { const auto history = peer->owner().history(peer); Ui::showPeerHistory(history, ShowAtTheEndMsgId); @@ -698,7 +700,7 @@ void PeerMenuCreatePoll(not_null peer) { box->closeBox(); }), crl::guard(box, [=](const RPCError &error) { *lock = false; - box->submitFailed(lang(lng_attach_failed)); + box->submitFailed(tr::lng_attach_failed(tr::now)); })); }, box->lifetime()); } @@ -725,7 +727,7 @@ void PeerMenuBlockUserBox( const auto report = (settings & Flag::f_report_spam) ? box->addRow(object_ptr( box, - lang(lng_report_spam), + tr::lng_report_spam(tr::now), true, st::defaultBoxCheckbox)) : nullptr; @@ -736,7 +738,7 @@ void PeerMenuBlockUserBox( const auto clear = box->addRow(object_ptr( box, - lang(lng_blocked_list_confirm_clear), + tr::lng_blocked_list_confirm_clear(tr::now), true, st::defaultBoxCheckbox)); @@ -789,7 +791,7 @@ QPointer ShowForwardMessagesBox( auto options = ApiWrap::SendOptions(peer->owner().history(peer)); options.generateLocal = false; Auth().api().forwardMessages(std::move(items), options, [] { - Ui::Toast::Show(lang(lng_share_done)); + Ui::Toast::Show(tr::lng_share_done(tr::now)); }); } } else { @@ -850,9 +852,9 @@ void PeerMenuAddMuteAction( const PeerMenuCallback &addAction) { Auth().data().requestNotifySettings(peer); const auto muteText = [](bool isMuted) { - return lang(isMuted - ? lng_enable_notifications_from_tray - : lng_disable_notifications_from_tray); + return isMuted + ? tr::lng_enable_notifications_from_tray(tr::now) + : tr::lng_disable_notifications_from_tray(tr::now); }; const auto muteAction = addAction(QString("-"), [=] { if (!Auth().data().notifyIsMuted(peer)) { @@ -872,17 +874,17 @@ void PeerMenuAddMuteAction( // #feed //void PeerMenuUngroupFeed(not_null feed) { // Ui::show(Box( -// lang(lng_feed_sure_ungroup_all), -// lang(lng_feed_ungroup_sure), +// tr::lng_feed_sure_ungroup_all(tr::now), +// tr::lng_feed_ungroup_sure(tr::now), // [=] { Ui::hideLayer(); Auth().api().ungroupAllFromFeed(feed); })); //} // void ToggleHistoryArchived(not_null history, bool archived) { const auto callback = [=] { Ui::Toast::Config toast; - toast.text = lang(archived - ? lng_archived_added - : lng_archived_removed); + toast.text = archived + ? tr::lng_archived_added(tr::now) + : tr::lng_archived_removed(tr::now); toast.maxWidth = st::boxWideWidth; if (archived) { toast.durationMs = kArchivedToastDuration;