Skip to content

Commit aabc897

Browse files
committed
rpc: Don't translate warning messages
But keep translating them in the GUI. This - necessarily - requires duplication of a few messages. Alternative take on #7134, that keeps the translations from being wiped. Also document GetWarnings() input argument. Fixes #5895.
1 parent 30c2d8c commit aabc897

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/main.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3979,29 +3979,34 @@ std::string GetWarnings(const std::string& strFor)
39793979
int nPriority = 0;
39803980
string strStatusBar;
39813981
string strRPC;
3982+
string strGUI;
39823983

3983-
if (!CLIENT_VERSION_IS_RELEASE)
3984-
strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
3984+
if (!CLIENT_VERSION_IS_RELEASE) {
3985+
strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
3986+
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
3987+
}
39853988

39863989
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
3987-
strStatusBar = strRPC = "testsafemode enabled";
3990+
strStatusBar = strRPC = strGUI = "testsafemode enabled";
39883991

39893992
// Misc warnings like out of disk space and clock is wrong
39903993
if (strMiscWarning != "")
39913994
{
39923995
nPriority = 1000;
3993-
strStatusBar = strMiscWarning;
3996+
strStatusBar = strGUI = strMiscWarning;
39943997
}
39953998

39963999
if (fLargeWorkForkFound)
39974000
{
39984001
nPriority = 2000;
3999-
strStatusBar = strRPC = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
4002+
strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
4003+
strGUI = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
40004004
}
40014005
else if (fLargeWorkInvalidChainFound)
40024006
{
40034007
nPriority = 2000;
4004-
strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
4008+
strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
4009+
strGUI = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
40054010
}
40064011

40074012
// Alerts
@@ -4013,12 +4018,14 @@ std::string GetWarnings(const std::string& strFor)
40134018
if (alert.AppliesToMe() && alert.nPriority > nPriority)
40144019
{
40154020
nPriority = alert.nPriority;
4016-
strStatusBar = alert.strStatusBar;
4021+
strStatusBar = strGUI = alert.strStatusBar;
40174022
}
40184023
}
40194024
}
40204025

4021-
if (strFor == "statusbar")
4026+
if (strFor == "gui")
4027+
return strGUI;
4028+
else if (strFor == "statusbar")
40224029
return strStatusBar;
40234030
else if (strFor == "rpc")
40244031
return strRPC;

src/main.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ void ThreadScriptCheck();
206206
void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader, int64_t nPowTargetSpacing);
207207
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
208208
bool IsInitialBlockDownload();
209-
/** Format a string that describes several potential problems detected by the core */
209+
/** Format a string that describes several potential problems detected by the core.
210+
* strFor can have three values:
211+
* - "rpc": get critical warnings, which should put the client in safe mode if non-empty
212+
* - "statusbar": get all warnings
213+
* - "gui": get all warnings, translated (where possible) for GUI
214+
* This function only returns the highest priority warning of the set selected by strFor.
215+
*/
210216
std::string GetWarnings(const std::string& strFor);
211217
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
212218
bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false);

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ enum BlockSource ClientModel::getBlockSource() const
158158

159159
QString ClientModel::getStatusBarWarnings() const
160160
{
161-
return QString::fromStdString(GetWarnings("statusbar"));
161+
return QString::fromStdString(GetWarnings("gui"));
162162
}
163163

164164
OptionsModel *ClientModel::getOptionsModel()

0 commit comments

Comments
 (0)