From e8affa85b0a403ac818a5e032644ba53d2e52fb5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Feb 2021 20:42:32 +0400 Subject: [PATCH] Try to open localized changelog. --- Telegram/SourceFiles/boxes/about_box.cpp | 3 +- Telegram/SourceFiles/core/application.cpp | 33 +++++++++++++++++++ Telegram/SourceFiles/core/application.h | 1 + Telegram/SourceFiles/core/changelogs.cpp | 2 +- .../SourceFiles/window/window_main_menu.cpp | 2 +- 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index 31798dc594..c43cb3afaf 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_info.h" #include "core/click_handler_types.h" #include "core/update_checker.h" +#include "core/application.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -109,7 +110,7 @@ void AboutBox::showVersionHistory() { Ui::show(Box("The link to the current private alpha version of Telegram Desktop was copied to the clipboard.")); } else { - UrlClickHandler::Open(qsl("https://desktop.telegram.org/changelog")); + UrlClickHandler::Open(Core::App().changelogLink()); } } diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 045146b0c5..719f9fbe35 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -764,6 +764,39 @@ bool Application::openInternalUrl(const QString &url, QVariant context) { return openCustomUrl("internal:", InternalUrlHandlers(), url, context); } +QString Application::changelogLink() const { + const auto base = u"https://desktop.telegram.org/changelog"_q; + const auto languages = { + "id", + "de", + "fr", + "nl", + "pl", + "tr", + "uk", + "fa", + "ru", + "ms", + "es", + "it", + "uz", + "pt-br", + "be", + "ar", + "ko", + }; + const auto current = _langpack->id().replace("-raw", ""); + if (current.isEmpty()) { + return base; + } + for (const auto language : languages) { + if (current == language || current.split(u'-')[0] == language) { + return base + "?setln=" + language; + } + } + return base; +} + bool Application::openCustomUrl( const QString &protocol, const std::vector &handlers, diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 15a5fcb1a6..4342f315fd 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -227,6 +227,7 @@ public: void checkStartUrl(); bool openLocalUrl(const QString &url, QVariant context); bool openInternalUrl(const QString &url, QVariant context); + [[nodiscard]] QString changelogLink() const; // Float player. void setDefaultFloatPlayerDelegate( diff --git a/Telegram/SourceFiles/core/changelogs.cpp b/Telegram/SourceFiles/core/changelogs.cpp index 52d1c8d4cf..87b2f70980 100644 --- a/Telegram/SourceFiles/core/changelogs.cpp +++ b/Telegram/SourceFiles/core/changelogs.cpp @@ -185,7 +185,7 @@ void Changelogs::addLocalLogs() { lt_changes, tr::lng_new_version_minor(tr::now), lt_link, - qsl("https://desktop.telegram.org/changelog")); + Core::App().changelogLink()); addLocalLog(text.trimmed()); } } diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 8a6cd9aa40..cbb07f8c3f 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -616,7 +616,7 @@ MainMenu::MainMenu( qsl("https://desktop.telegram.org"))); _telegram->setLinksTrusted(); _version->setRichText(textcmdLink(1, tr::lng_settings_current_version(tr::now, lt_version, currentVersionText())) + QChar(' ') + QChar(8211) + QChar(' ') + textcmdLink(2, tr::lng_menu_about(tr::now))); - _version->setLink(1, std::make_shared(qsl("https://desktop.telegram.org/changelog"))); + _version->setLink(1, std::make_shared(Core::App().changelogLink())); _version->setLink(2, std::make_shared([] { Ui::show(Box()); })); _controller->session().downloaderTaskFinished(