common project localization: move out all updating strings

- finish localizing boostrapper/runner/action_runner
This commit is contained in:
yuyoyuppe
2020-10-22 19:02:59 +03:00
committed by Andrey Nekrasov
parent 5629e8068b
commit f33b3c771a
18 changed files with 427 additions and 181 deletions

View File

@@ -64,4 +64,94 @@
<data name="DOTNET_CORE_DOWNLOAD_FAILURE_TITLE" xml:space="preserve">
<value>PowerToys installation error</value>
</data>
<data name="GITHUB_NEW_VERSION_AVAILABLE" xml:space="preserve">
<value>An update to PowerToys is available.</value>
</data>
<data name="GITHUB_NEW_VERSION_DOWNLOAD_STARTED" xml:space="preserve">
<value>PowerToys download started.</value>
</data>
<data name="GITHUB_NEW_VERSION_READY_TO_INSTALL" xml:space="preserve">
<value>An update to PowerToys is ready to install.</value>
</data>
<data name="GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR" xml:space="preserve">
<value>Error: couldn't download PowerToys installer. Visit our GitHub page to update.</value>
</data>
<data name="GITHUB_NEW_VERSION_UPDATE_NOW" xml:space="preserve">
<value>Update now</value>
</data>
<data name="GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART" xml:space="preserve">
<value>At next launch</value>
</data>
<data name="UNINSTALLATION_UNKNOWN_ERROR" xml:space="preserve">
<value>Error: please uninstall the previous version of PowerToys manually.</value>
</data>
<data name="GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT" xml:space="preserve">
<value>An update to PowerToys is available. Visit our GitHub page to update.</value>
</data>
<data name="GITHUB_NEW_VERSION_UNAVAILABLE" xml:space="preserve">
<value>PowerToys is up to date.</value>
</data>
<data name="GITHUB_NEW_VERSION_VISIT" xml:space="preserve">
<value>Visit</value>
</data>
<data name="GITHUB_NEW_VERSION_MORE_INFO" xml:space="preserve">
<value>More info...</value>
</data>
<data name="GITHUB_NEW_VERSION_ABORT" xml:space="preserve">
<value>Abort</value>
</data>
<data name="GITHUB_NEW_VERSION_SNOOZE_TITLE" xml:space="preserve">
<value>Click Snooze to be reminded in:</value>
</data>
<data name="GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D" xml:space="preserve">
<value>1 day</value>
</data>
<data name="GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D" xml:space="preserve">
<value>5 days</value>
</data>
<data name="DOWNLOAD_IN_PROGRESS" xml:space="preserve">
<value>Downloading...</value>
</data>
<data name="DOWNLOAD_COMPLETE" xml:space="preserve">
<value>Download complete</value>
</data>
<data name="TOAST_TITLE" xml:space="preserve">
<value>PowerToys Update</value>
</data>
<data name="OFFER_UNINSTALL_MSI" xml:space="preserve">
<value>We've detected a previous installation of PowerToys. Would you like to remove it?</value>
</data>
<data name="OFFER_UNINSTALL_MSI_TITLE" xml:space="preserve">
<value>PowerToys: uninstall previous version?</value>
</data>
<data name="INSTALLER_EXTRACT_ERROR" xml:space="preserve">
<value>Couldn't extract MSI installer!</value>
</data>
<data name="EXTRACTING_INSTALLER" xml:space="preserve">
<value>Extracting PowerToys MSI...</value>
</data>
<data name="UNINSTALLING_PREVIOUS_VERSION" xml:space="preserve">
<value>Uninstalling previous PowerToys version...</value>
</data>
<data name="UNINSTALL_PREVIOUS_VERSION_ERROR" xml:space="preserve">
<value>Couldn't uninstall previous PowerToys version!</value>
</data>
<data name="INSTALLING_DOTNET" xml:space="preserve">
<value>Installing dotnet...</value>
</data>
<data name="DOTNET_INSTALL_ERROR" xml:space="preserve">
<value>Couldn't install dotnet!</value>
</data>
<data name="INSTALLING_NEW_VERSION" xml:space="preserve">
<value>Installing new PowerToys version...</value>
</data>
<data name="NEW_VERSION_INSTALLATION_DONE" xml:space="preserve">
<value>PowerToys installation complete!</value>
</data>
<data name="NEW_VERSION_INSTALLATION_ERROR" xml:space="preserve">
<value>Couldn't install new PowerToys version.</value>
</data>
<data name="SNOOZE_BUTTON" xml:space="preserve">
<value>Snooze</value>
</data>
</root>

View File

@@ -14,11 +14,14 @@
extern "C" IMAGE_DOS_HEADER __ImageBase;
auto Strings = updating::notifications::strings::create();
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
namespace
namespace // Strings in this namespace should not be localized
{
const wchar_t APPLICATION_ID[] = L"PowerToysInstaller";
const wchar_t INSTALLATION_TOAST_TITLE[] = L"PowerToys Installation";
const wchar_t TOAST_TAG[] = L"PowerToysInstallerProgress";
const char LOG_FILENAME[] = "powertoys-bootstrapper-" STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_REVISION) ".log";
const char MSI_LOG_FILENAME[] = "powertoys-bootstrapper-msi-" STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_REVISION) ".log";
@@ -27,20 +30,6 @@ namespace
#undef STR
#undef STR_HELPER
namespace localized_strings
{
const wchar_t INSTALLER_EXTRACT_ERROR[] = L"Couldn't extract MSI installer!";
const wchar_t TOAST_TITLE[] = L"PowerToys Installation";
const wchar_t EXTRACTING_INSTALLER[] = L"Extracting PowerToys MSI...";
const wchar_t UNINSTALLING_PREVIOUS_VERSION[] = L"Uninstalling previous PowerToys version...";
const wchar_t UNINSTALL_PREVIOUS_VERSION_ERROR[] = L"Couldn't uninstall previous PowerToys version!";
const wchar_t INSTALLING_DOTNET[] = L"Installing dotnet...";
const wchar_t DOTNET_INSTALL_ERROR[] = L"Couldn't install dotnet!";
const wchar_t INSTALLING_NEW_VERSION[] = L"Installing new PowerToys version...";
const wchar_t NEW_VERSION_INSTALLATION_DONE[] = L"PowerToys installation complete!";
const wchar_t NEW_VERSION_INSTALLATION_ERROR[] = L"Couldn't install new PowerToys version.";
}
namespace fs = std::filesystem;
std::optional<fs::path> extractEmbeddedInstaller()
@@ -96,7 +85,6 @@ void setup_log(fs::path directory, const spdlog::level::level_enum severity)
int bootstrapper()
{
using namespace localized_strings;
winrt::init_apartment();
cxxopts::Options options{ "PowerToysBootstrapper" };
// clang-format off
@@ -252,7 +240,7 @@ int bootstrapper()
iconPath = std::move(*extractedIcon);
}
spdlog::debug("Registering app id for toast notifications");
notifications::register_application_id(TOAST_TITLE, iconPath.c_str());
notifications::register_application_id(INSTALLATION_TOAST_TITLE, iconPath.c_str());
auto removeShortcut = wil::scope_exit([&] {
notifications::unregister_application_id();
@@ -274,12 +262,12 @@ int bootstrapper()
std::mutex progressLock;
notifications::progress_bar_params progressParams;
progressParams.progress = 0.0f;
progressParams.progress_title = EXTRACTING_INSTALLER;
progressParams.progress_title = GET_RESOURCE_STRING(IDS_EXTRACTING_INSTALLER);
notifications::toast_params params{ TOAST_TAG, false, std::move(progressParams) };
if (!silent)
{
spdlog::debug("Launching progress toast notification");
notifications::show_toast_with_activations({}, TOAST_TITLE, {}, {}, std::move(params));
notifications::show_toast_with_activations({}, INSTALLATION_TOAST_TITLE, {}, {}, std::move(params));
}
auto processToasts = wil::scope_exit([&] {
@@ -322,7 +310,7 @@ int bootstrapper()
{
if (!silent)
{
notifications::show_toast(INSTALLER_EXTRACT_ERROR, TOAST_TITLE);
notifications::show_toast(GET_RESOURCE_STRING(IDS_INSTALLER_EXTRACT_ERROR), INSTALLATION_TOAST_TITLE);
}
spdlog::error("Couldn't install the MSI installer ({})", GetLastError());
return 1;
@@ -332,7 +320,7 @@ int bootstrapper()
fs::remove(*installerPath, _);
});
updateProgressBar(.25f, UNINSTALLING_PREVIOUS_VERSION);
updateProgressBar(.25f, GET_RESOURCE_STRING(IDS_UNINSTALLING_PREVIOUS_VERSION).c_str());
spdlog::debug("Acquiring existing MSI package path");
const auto package_path = updating::get_msi_package_path();
if (!package_path.empty())
@@ -343,15 +331,15 @@ int bootstrapper()
{
spdlog::debug("Existing MSI package path not found");
}
if (!package_path.empty() && !updating::uninstall_msi_version(package_path) && !silent)
if (!package_path.empty() && !updating::uninstall_msi_version(package_path, Strings) && !silent)
{
spdlog::error("Couldn't install the existing MSI package ({})", GetLastError());
notifications::show_toast(UNINSTALL_PREVIOUS_VERSION_ERROR, TOAST_TITLE);
notifications::show_toast(GET_RESOURCE_STRING(IDS_UNINSTALL_PREVIOUS_VERSION_ERROR), INSTALLATION_TOAST_TITLE);
}
const bool installDotnet = !skipDotnetInstall;
if (installDotnet)
{
updateProgressBar(.5f, INSTALLING_DOTNET);
updateProgressBar(.5f, GET_RESOURCE_STRING(IDS_INSTALLING_DOTNET).c_str());
}
try
@@ -365,7 +353,7 @@ int bootstrapper()
!updating::install_dotnet(silent) &&
!silent)
{
notifications::show_toast(DOTNET_INSTALL_ERROR, TOAST_TITLE);
notifications::show_toast(GET_RESOURCE_STRING(IDS_DOTNET_INSTALL_ERROR), INSTALLATION_TOAST_TITLE);
}
}
}
@@ -375,13 +363,14 @@ int bootstrapper()
MessageBoxW(nullptr, L".NET Core installation", L"Unknown exception encountered!", MB_OK | MB_ICONERROR);
}
updateProgressBar(.75f, INSTALLING_NEW_VERSION);
updateProgressBar(.75f, GET_RESOURCE_STRING(IDS_INSTALLING_NEW_VERSION).c_str());
// Always skip dotnet install, because we should've installed it from here earlier
std::wstring msiProps = L"SKIPDOTNETINSTALL=1 ";
spdlog::debug("Launching MSI installation for new package {}", installerPath->string());
const bool installationDone = MsiInstallProductW(installerPath->c_str(), msiProps.c_str()) == ERROR_SUCCESS;
updateProgressBar(1.f, installationDone ? NEW_VERSION_INSTALLATION_DONE : NEW_VERSION_INSTALLATION_ERROR);
updateProgressBar(1.f,
installationDone ? GET_RESOURCE_STRING(IDS_NEW_VERSION_INSTALLATION_DONE).c_str() : GET_RESOURCE_STRING(IDS_NEW_VERSION_INSTALLATION_ERROR).c_str());
if (!installationDone)
{
spdlog::error("Couldn't install new MSI package ({})", GetLastError());