diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 20fae9a19..a704b7484 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -29,6 +29,7 @@ set( calamaresui_SOURCES widgets/ClickableLabel.cpp widgets/FixedAspectRatioLabel.cpp widgets/PrettyRadioButton.cpp + widgets/TranslationFix.cpp widgets/WaitingWidget.cpp ${CMAKE_SOURCE_DIR}/3rdparty/waitingspinnerwidget.cpp diff --git a/src/libcalamaresui/widgets/TranslationFix.cpp b/src/libcalamaresui/widgets/TranslationFix.cpp new file mode 100644 index 000000000..6bd2900be --- /dev/null +++ b/src/libcalamaresui/widgets/TranslationFix.cpp @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "TranslationFix.h" + +#include +#include +#include + +namespace Calamares +{ + +void +fixButtonLabels( QMessageBox* box ) +{ + if ( !box ) + { + return; + } + + static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] + = { { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) } }; + + for ( auto [ sb, label ] : maps ) + { + auto* button = box->button( sb ); + if ( button ) + { + button->setText( QCoreApplication::translate( "StandardButtons", label ) ); + } + } +} + +} // namespace Calamares diff --git a/src/libcalamaresui/widgets/TranslationFix.h b/src/libcalamaresui/widgets/TranslationFix.h new file mode 100644 index 000000000..107dad67d --- /dev/null +++ b/src/libcalamaresui/widgets/TranslationFix.h @@ -0,0 +1,31 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef LIBCALAMARESUI_WIDGETS_TRANSLATIONFIX_H +#define LIBCALAMARESUI_WIDGETS_TRANSLATIONFIX_H + +#include "DllMacro.h" + +class QMessageBox; + +namespace Calamares +{ + +/** @brief Fixes the labels on the standard buttons of the message box + * + * Updates OK / Cancel / Yes / No because there does not + * seem to be a way to do so in the Retranslator code + * (in libcalamares) since the translated strings may come + * from a variety of platform-plugin sources and we can't + * guess the context. + */ +void UIDLLEXPORT fixButtonLabels( QMessageBox* ); +} // namespace Calamares + +#endif diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index a82d873e9..1ea3f2429 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -26,6 +26,7 @@ #include "utils/Logger.h" #include "utils/NamedEnum.h" #include "utils/Retranslator.h" +#include "widgets/TranslationFix.h" #include #include @@ -251,6 +252,7 @@ WelcomePage::showAboutBox() .arg( Calamares::Branding::instance()->versionedName() ), QMessageBox::Ok, this ); + Calamares::fixButtonLabels( &mb ); mb.setIconPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Squid, CalamaresUtils::Original,