Merge bitcoin-core/gui#454: Use only Qt translation primitives in GUI code

58765a450c40152db8160bca8a6b0f5b754c5858 qt: Use only Qt translation primitives in GUI code (W. J. van der Laan)

Pull request description:

  Use `Object::tr`, `QT_TRANSLATE_NOOP`, and `QCoreApplication::translate` as appropriate instead of using `_()` which doesn't get picked up.

  Replaces bitcoin/bitcoin#22764

  Edit: I checked that the strings end up in the appropriate context in `bitcoin_en.ts` after `make translate`:
  - "Settings file could not be read" "Settings file could not be written" end up in `bitcoin-core`
  - "(press q to shutdown and continue later)" and "press q to shutdown" end up in `SplashScreen`

ACKs for top commit:
  hebasto:
    ACK 58765a450c40152db8160bca8a6b0f5b754c5858

Tree-SHA512: d0cc5901426c47d411d0fe75aac195b9684b51385f74c161da772dbf9f0977f7ad7a0976e17366f49b40718e9b6eb87c3e93306dc845f97adddbc47d00731742
This commit is contained in:
Hennadii Stepanov 2021-10-22 23:43:28 +03:00 committed by pasta
parent 95aeb6a08d
commit 7455b5557a
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
2 changed files with 10 additions and 8 deletions

View File

@ -156,10 +156,11 @@ static bool InitSettings()
std::vector<std::string> errors; std::vector<std::string> errors;
if (!gArgs.ReadSettingsFile(&errors)) { if (!gArgs.ReadSettingsFile(&errors)) {
bilingual_str error = _("Settings file could not be read"); std::string error = QT_TRANSLATE_NOOP("dash-core", "Settings file could not be read");
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, MakeUnorderedList(errors)))); std::string error_translated = QCoreApplication::translate("dash-core", error.c_str()).toStdString();
InitError(Untranslated(strprintf("%s:\n%s\n", error, MakeUnorderedList(errors))));
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Reset | QMessageBox::Abort); QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error_translated)), QMessageBox::Reset | QMessageBox::Abort);
/*: Explanatory text shown on startup when the settings file cannot be read. /*: Explanatory text shown on startup when the settings file cannot be read.
Prompts user to make a choice between resetting or aborting. */ Prompts user to make a choice between resetting or aborting. */
messagebox.setInformativeText(QObject::tr("Do you want to reset settings to default values, or to abort without making changes?")); messagebox.setInformativeText(QObject::tr("Do you want to reset settings to default values, or to abort without making changes?"));
@ -178,10 +179,11 @@ static bool InitSettings()
errors.clear(); errors.clear();
if (!gArgs.WriteSettingsFile(&errors)) { if (!gArgs.WriteSettingsFile(&errors)) {
bilingual_str error = _("Settings file could not be written"); std::string error = QT_TRANSLATE_NOOP("dash-core", "Settings file could not be written");
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, MakeUnorderedList(errors)))); std::string error_translated = QCoreApplication::translate("dash-core", error.c_str()).toStdString();
InitError(Untranslated(strprintf("%s:\n%s\n", error, MakeUnorderedList(errors))));
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Ok); QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error_translated)), QMessageBox::Ok);
/*: Explanatory text shown on startup when the settings file could not be written. /*: Explanatory text shown on startup when the settings file could not be written.
Prompts user to check that we have the ability to write to the file. Prompts user to check that we have the ability to write to the file.
Explains that the user has the option of running without a settings file.*/ Explains that the user has the option of running without a settings file.*/

View File

@ -189,8 +189,8 @@ static void InitMessage(SplashScreen *splash, const std::string &message)
static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible) static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible)
{ {
InitMessage(splash, title + std::string("\n") + InitMessage(splash, title + std::string("\n") +
(resume_possible ? _("(press q to shutdown and continue later)").translated (resume_possible ? SplashScreen::tr("(press q to shutdown and continue later)").toStdString()
: _("press q to shutdown").translated) + : SplashScreen::tr("press q to shutdown").toStdString()) +
strprintf("\n%d", nProgress) + "%"); strprintf("\n%d", nProgress) + "%");
} }