Skip to content

Commit

Permalink
Merge #1376: [Init] Combine common error strings so translations can …
Browse files Browse the repository at this point in the history
…be shared

77998ed5cd067302801ce9b863d59722df9fedca Combine common error strings so translations can be shared and reused (Luke Dashjr)

Pull request description:

  Backport of bitcoin/bitcoin#7257

  Adds helper methods for common translatable string outputs during init, end result is that the number of strings sent to Transifex is reduced/standardized.

  Based on top of #1375

  Conflicts with #1373 (this to be rebased after both #1373 and #1375 are merged)

ACKs for top commit:
  random-zebra:
    utACK 77998ed5cd067302801ce9b863d59722df9fedca
  furszy:
    utACK 77998ed and merging..

Tree-SHA512: 9805b931829f76cbc34b43b7e6141b236d162bd0267342714222612b8e51cdc9d8b35e68971775bd7a489e95a3c4f9b533bbf1ecaa0e56b19a443ed308141c87
  • Loading branch information
furszy authored and wqking committed Aug 10, 2020
1 parent dffa1f3 commit 8d0144b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,16 @@ void InitParameterInteraction()
}
}

static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
{
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
}

static std::string AmountErrMsg(const char * const optname, const std::string& strValue)
{
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
}

void InitLogging()
{
fPrintToConsole = GetBoolArg("-printtoconsole", false);
Expand Down Expand Up @@ -1020,7 +1030,7 @@ bool AppInit2()
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
::minRelayTxFee = CFeeRate(n);
else
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"]));
return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"]));
}

#ifdef ENABLE_WALLET
Expand All @@ -1029,12 +1039,12 @@ bool AppInit2()
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
CWallet::minTxFee = CFeeRate(n);
else
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"]));
return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
}
if (mapArgs.count("-paytxfee")) {
CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"]));
return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
if (nFeePerK > nHighTransactionFeeWarning)
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
payTxFee = CFeeRate(nFeePerK, 1000);
Expand All @@ -1046,7 +1056,7 @@ bool AppInit2()
if (mapArgs.count("-maxtxfee")) {
CAmount nMaxFee = 0;
if (!ParseMoney(mapArgs["-maxtxfee"], nMaxFee))
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s'"), mapArgs["-maxtxfee"]));
return InitError(AmountErrMsg("maxtxfee", mapArgs["-maxtxfee"]));
if (nMaxFee > nHighTransactionMaxFeeWarning)
InitWarning(_("Warning: -maxtxfee is set very high! Fees this large could be paid on a single transaction."));
maxTxFee = nMaxFee;
Expand Down Expand Up @@ -1400,13 +1410,13 @@ bool AppInit2()
for (std::string strBind : mapMultiArgs["-bind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind));
return InitError(ResolveErrMsg("bind", strBind));
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
}
for (std::string strBind : mapMultiArgs["-whitebind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, 0, false))
return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind));
return InitError(ResolveErrMsg("whitebind", strBind));
if (addrBind.GetPort() == 0)
return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind));
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST));
Expand All @@ -1427,7 +1437,7 @@ bool AppInit2()
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
AddLocal(addrLocal,LOCAL_MANUAL);
else
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
return InitError(ResolveErrMsg("externalip", strAddr));
}
}

Expand Down

0 comments on commit 8d0144b

Please sign in to comment.