mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 16:53:52 +02:00
Merge #18922: gui: Do not translate InitWarning messages in debug.log
78be8d97d3util: Drop OpOriginal() and OpTranslated() (Hennadii Stepanov)da16f95c3fgui: Do not translate InitWarning messages in debug.log (Hennadii Stepanov)4c9b9a4882util: Enhance Join() (Hennadii Stepanov)fe05dd0611util: Enhance bilingual_str (Hennadii Stepanov) Pull request description: This PR forces the `bitcoin-qt` to write `InitWarning()` messages to the `debug.log` file in untranslated form, i.e., in English. On master (376294cde6): ``` $ ./src/qt/bitcoin-qt -lang=nl -debug=vladidation -printtoconsole | grep 'vladi' Warning: Niet-ondersteunde logcategorie -debug=vladidation. 2020-05-09T12:39:59Z Warning: Niet-ondersteunde logcategorie -debug=vladidation. 2020-05-09T12:40:02Z Command-line arg: debug="vladidation" ``` With this PR: ``` $ ./src/qt/bitcoin-qt -lang=nl -debug=vladidation -printtoconsole | grep 'vladi' Warning: Unsupported logging category -debug=vladidation. 2020-05-09T12:42:04Z Warning: Unsupported logging category -debug=vladidation. 2020-05-09T12:42:35Z Command-line arg: debug="vladidation" ```  Related to #16218. ACKs for top commit: laanwj: ACK78be8d97d3jonasschnelli: utACK78be8d97d3MarcoFalke: ACK78be8d97d3📢 Tree-SHA512: 48e9ecd23c4dd8ec262e3eb94f8e30944bcc9c6c163245fb837b2e0c484d4d0b4f47f7abc638c14edc27d635d340ba3ee4ba4506b062399e9cf59a1564c98755
This commit is contained in:
@@ -30,10 +30,11 @@ NODISCARD inline std::string TrimString(const std::string& str, const std::strin
|
||||
* @param separator The separator
|
||||
* @param unary_op Apply this operator to each item in the list
|
||||
*/
|
||||
template <typename T, typename UnaryOp>
|
||||
std::string Join(const std::vector<T>& list, const std::string& separator, UnaryOp unary_op)
|
||||
template <typename T, typename BaseType, typename UnaryOp>
|
||||
auto Join(const std::vector<T>& list, const BaseType& separator, UnaryOp unary_op)
|
||||
-> decltype(unary_op(list.at(0)))
|
||||
{
|
||||
std::string ret;
|
||||
decltype(unary_op(list.at(0))) ret;
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
if (i > 0) ret += separator;
|
||||
ret += unary_op(list.at(i));
|
||||
@@ -41,9 +42,16 @@ std::string Join(const std::vector<T>& list, const std::string& separator, Unary
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Join(const std::vector<T>& list, const T& separator)
|
||||
{
|
||||
return Join(list, separator, [](const T& i) { return i; });
|
||||
}
|
||||
|
||||
// Explicit overload needed for c_str arguments, which would otherwise cause a substitution failure in the template above.
|
||||
inline std::string Join(const std::vector<std::string>& list, const std::string& separator)
|
||||
{
|
||||
return Join(list, separator, [](const std::string& i) { return i; });
|
||||
return Join<std::string>(list, separator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,21 +16,23 @@
|
||||
struct bilingual_str {
|
||||
std::string original;
|
||||
std::string translated;
|
||||
|
||||
bilingual_str& operator+=(const bilingual_str& rhs)
|
||||
{
|
||||
original += rhs.original;
|
||||
translated += rhs.translated;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline bilingual_str operator+(const bilingual_str& lhs, const bilingual_str& rhs)
|
||||
inline bilingual_str operator+(bilingual_str lhs, const bilingual_str& rhs)
|
||||
{
|
||||
return bilingual_str{
|
||||
lhs.original + rhs.original,
|
||||
lhs.translated + rhs.translated};
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
/** Mark a bilingual_str as untranslated */
|
||||
inline bilingual_str Untranslated(std::string original) { return {original, original}; }
|
||||
/** Unary operator to return the original */
|
||||
inline std::string OpOriginal(const bilingual_str& b) { return b.original; }
|
||||
/** Unary operator to return the translation */
|
||||
inline std::string OpTranslated(const bilingual_str& b) { return b.translated; }
|
||||
|
||||
namespace tinyformat {
|
||||
template <typename... Args>
|
||||
|
||||
Reference in New Issue
Block a user