Try to open localized changelog.

This commit is contained in:
John Preston 2021-02-04 20:42:32 +04:00
parent d782ea63f8
commit e8affa85b0
5 changed files with 38 additions and 3 deletions

View File

@ -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<InformBox>("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());
}
}

View File

@ -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<LocalUrlHandler> &handlers,

View File

@ -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(

View File

@ -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());
}
}

View File

@ -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<UrlClickHandler>(qsl("https://desktop.telegram.org/changelog")));
_version->setLink(1, std::make_shared<UrlClickHandler>(Core::App().changelogLink()));
_version->setLink(2, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<AboutBox>()); }));
_controller->session().downloaderTaskFinished(