Skip to content

Commit bdbefdc

Browse files
committed
Merge #454: Use only Qt translation primitives in GUI code
58765a4 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 58765a4 Tree-SHA512: d0cc5901426c47d411d0fe75aac195b9684b51385f74c161da772dbf9f0977f7ad7a0976e17366f49b40718e9b6eb87c3e93306dc845f97adddbc47d00731742
2 parents 224e90d + 58765a4 commit bdbefdc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/qt/bitcoin.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ static bool InitSettings()
154154

155155
std::vector<std::string> errors;
156156
if (!gArgs.ReadSettingsFile(&errors)) {
157-
bilingual_str error = _("Settings file could not be read");
158-
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, MakeUnorderedList(errors))));
157+
std::string error = QT_TRANSLATE_NOOP("bitcoin-core", "Settings file could not be read");
158+
std::string error_translated = QCoreApplication::translate("bitcoin-core", error.c_str()).toStdString();
159+
InitError(Untranslated(strprintf("%s:\n%s\n", error, MakeUnorderedList(errors))));
159160

160-
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Reset | QMessageBox::Abort);
161+
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error_translated)), QMessageBox::Reset | QMessageBox::Abort);
161162
/*: Explanatory text shown on startup when the settings file cannot be read.
162163
Prompts user to make a choice between resetting or aborting. */
163164
messagebox.setInformativeText(QObject::tr("Do you want to reset settings to default values, or to abort without making changes?"));
@@ -176,10 +177,11 @@ static bool InitSettings()
176177

177178
errors.clear();
178179
if (!gArgs.WriteSettingsFile(&errors)) {
179-
bilingual_str error = _("Settings file could not be written");
180-
InitError(Untranslated(strprintf("%s:\n%s\n", error.original, MakeUnorderedList(errors))));
180+
std::string error = QT_TRANSLATE_NOOP("bitcoin-core", "Settings file could not be written");
181+
std::string error_translated = QCoreApplication::translate("bitcoin-core", error.c_str()).toStdString();
182+
InitError(Untranslated(strprintf("%s:\n%s\n", error, MakeUnorderedList(errors))));
181183

182-
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error.translated)), QMessageBox::Ok);
184+
QMessageBox messagebox(QMessageBox::Critical, PACKAGE_NAME, QString::fromStdString(strprintf("%s.", error_translated)), QMessageBox::Ok);
183185
/*: Explanatory text shown on startup when the settings file could not be written.
184186
Prompts user to check that we have the ability to write to the file.
185187
Explains that the user has the option of running without a settings file.*/

src/qt/splashscreen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ static void InitMessage(SplashScreen *splash, const std::string &message)
184184
static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible)
185185
{
186186
InitMessage(splash, title + std::string("\n") +
187-
(resume_possible ? _("(press q to shutdown and continue later)").translated
188-
: _("press q to shutdown").translated) +
187+
(resume_possible ? SplashScreen::tr("(press q to shutdown and continue later)").toStdString()
188+
: SplashScreen::tr("press q to shutdown").toStdString()) +
189189
strprintf("\n%d", nProgress) + "%");
190190
}
191191

0 commit comments

Comments
 (0)