Skip to content

Commit 58765a4

Browse files
committed
qt: Use only Qt translation primitives in GUI code
Use `QObject::tr`, `QT_TR_NOOP`, and `QCoreApplication::translate` as appropriate instead of using `_()` which doesn't get picked up.
1 parent 71a85fb commit 58765a4

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)