Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jul 9, 2019

This PR adds the bilingual_str struct and a strprintf overload:

bitcoin/src/tinyformat.h

Lines 1066 to 1067 in 0626b8c

/** Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for details) */
#define strprintf tfm::format

Both new features allow bitcoin code to easily send dual translated and non-translated messages to the GUI and the logging framework.

This PR is only a refactoring (has been split off the #16224 (see: #16224)) and does not change behavior.

@hebasto
Copy link
Member Author

hebasto commented Jul 9, 2019

GH does not render comment address correctly:
https://github.com/bitcoin/bitcoin/pull/16224/#issuecomment-509701396

@maflcko
Copy link
Member

maflcko commented Jul 9, 2019

ACK 4e1eda7, the diff seems verbose but I think it makes sense
to be more explicit where translated strings are passed in.
Currently we have issues where translated strings end up in the debug log.

Also, this is a requirement for future fixes such as #16224

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 4e1eda717e, the diff seems verbose but I think it makes sense
to be more explicit where translated strings are passed in.
Currently we have issues where translated strings end up in the debug log.

Also, this is a requirement for future fixes such as #16224
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgAxgv7B8gVJW+NBhgvYFjV7GzTcEDz0+R5pW0pW+8JXt5bYm4l9YkmBZVq/kk+
Pf/Wr2Vv91OoFIAiAu8iObedp35PzybgeZ4Dc9HlidhOHZvqxOrjNf+lINNyh+ZZ
ibv0VVcNQTeffMf6+zQoHazuyJPtNarJHmfPQQPBuYPbniW8DpDcRtamMIBxg0sd
2FMLWtgt214boyf0aNUTmQUjxqwtafuqSpOri1VVMc458lIAKma8tdQUo9U/ryfP
+F8ev8SuK+ZJF3DRqah5mCO6+5Cd5vv0e/wsVemL6DBW11IuTOdW8WCFQoTIQINL
ayT1m4fbe9wdKh1r/j4Hla8qGjrtPSfgoEj+wfghACLP2MVZxZwqraLz2tH4NFQ4
8zVtjR7Ms1PVSSNFGEoEWU7ouYdX/Jgz/KDp/MxpeFMwzTNZkBWrP5An1AwuJyyt
5VR16+80UJfF5qnOXpO3tt7t7CQzB194ZBJVLneTVUye0Q/87xW8Y5MjCDn5QBVD
TtPRZurp
=g2TS
-----END PGP SIGNATURE-----

Timestamp of file with hash a12ab7776476c20805e88823e532aa26d34082ee0510d1f17344e7869974c62a -

@maflcko maflcko added this to the 0.19.0 milestone Jul 9, 2019
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 9, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16443 (refactor: have CCoins* data managed under CChainState by jamesob)
  • #16442 (Serve BIP 157 compact filters by jimpo)
  • #16426 (Reverse cs_main, cs_wallet lock order and reduce cs_main locking by ariard)
  • #16341 (WIP: Introduce ScriptPubKeyMan interface and use it for key and script management (aka wallet boxes) by achow101)
  • #16265 (Update check disk space in bitcoind by asood123)
  • #16248 (Make whitebind/whitelist permissions more flexible by NicolasDorier)
  • #16003 (init: an incorrect amount of file descriptors is requested, and a different amount is also asserted by tryphe)
  • #15946 (Allow maintaining the blockfilterindex when using prune by jonasschnelli)
  • #15861 (Restore warning for individual unknown version bits, as well as unknown version schemas by luke-jr)
  • #15761 (Replace -upgradewallet startup option with upgradewallet RPC by achow101)
  • #15606 ([experimental] UTXO snapshots by jamesob)
  • #15112 (build: Optionally enable -Wzero-as-null-pointer-constant by Empact)
  • #13751 (Utils and libraries: Drops the boost/algorithm/string/split.hpp dependency by l2a5b1)
  • #10443 (Add fee_est tool for debugging fee estimation code by ryanofsky)
  • #8994 (Testchains: Introduce custom chain whose constructor... by jtimon)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@fanquake fanquake added the GUI label Jul 9, 2019
@hebasto hebasto force-pushed the 20190709-bilingual-part-one branch from 4e1eda7 to 29b28c7 Compare July 10, 2019 15:14
@hebasto
Copy link
Member Author

hebasto commented Jul 10, 2019

Rebased.

@hebasto hebasto force-pushed the 20190709-bilingual-part-one branch from 29b28c7 to d2a5927 Compare July 18, 2019 15:48
@hebasto
Copy link
Member Author

hebasto commented Jul 18, 2019

Rebased.

@hebasto hebasto force-pushed the 20190709-bilingual-part-one branch from d2a5927 to 3b7348f Compare July 23, 2019 17:18
@hebasto
Copy link
Member Author

hebasto commented Jul 23, 2019

Rebased.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for a making new PR to separate refactoring and behavior changes!

Conditional utACK 3b7348f if this PR is fixed to have a descriptive title and OP. For title I'd suggest, "Add bilingual_str class". In the description, I'd say something like, "This PR adds a bilingual_str class and a strprintf overload that allows bitcoin code to easily send dual translated and non-translated messages to the GUI and the logging framework. This PR is only a refactoring, and does not change behavior."

As I commented on the other PR, I think this PR and its followup would be simpler if the _ function signature was changed to return bilingual_str in the same commit that changed ThreadSafeMessageBox, InitError, InitWarning, and similar functions to accept bilingual_str arguments. This would avoid the churn of having to add .translated suffixes and then remove them later. It would mean replacing the scripted diff commit with a manual commit, but I think the manual commit should be smaller, and honestly I'd consider it an advantage not to have to decipher the sed / bash code anyway. But this is just my suggested approach, I'm also fine with the current approach.

@DrahtBot
Copy link
Contributor

Needs rebase

@hebasto hebasto changed the title gui: Bilingual translation gui: Add bilingual_str type Jul 24, 2019
@hebasto
Copy link
Member Author

hebasto commented Jul 24, 2019

@ryanofsky Thank you for your review.

For title I'd suggest, "Add bilingual_str class". In the description, I'd say something like, "This PR adds a bilingual_str class and a strprintf overload that allows bitcoin code to easily send dual translated and non-translated messages to the GUI and the logging framework. This PR is only a refactoring, and does not change behavior."

Done.

... I'm also fine with the current approach.

Let it be ;)

@hebasto hebasto force-pushed the 20190709-bilingual-part-one branch from 3b7348f to 375d909 Compare July 24, 2019 13:21
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 375d909. Only changes since last review are rebase and updating the PR title & description (thanks!). There currently a lint error making travis fail, but this looks good otherwise.

One thing is I would probably remove "gui:" prefix from PR title because that even though this is refactoring that doesn't change behavior and is meant to help the gui, the prefix could mislead reviewers to thinking the PR doesn't touch non-gui code.

hebasto added 3 commits July 24, 2019 16:32
This is a prerequisite for introducing bilingual error messages.
Note: #includes are arranged by clang-format-diff.py script.
-BEGIN VERIFY SCRIPT-
sed -i 's/inline std::string _(const char\* psz)/inline bilingual_str _(const char\* psz)/' src/util/translation.h
sed -i 's/return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz;/return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};/' src/util/translation.h
sed -i 's/\b_("\([^"]\|\\"\)*")/&.translated/g' $(git grep --files-with-matches '\b_("' src)
echo Hard cases - multiline strings.
sed -i 's/"Visit %s for further information about the software.")/&.translated/g' src/init.cpp
sed -i "s/\"Only rebuild the block database if you are sure that your computer's date and time are correct\")/&.translated/g" src/init.cpp
sed -i 's/" restore from a backup.")/&.translated/g' src/wallet/db.cpp
sed -i 's/" or address book entries might be missing or incorrect.")/&.translated/g' src/wallet/wallet.cpp
echo Special case.
sed -i 's/_(COPYRIGHT_HOLDERS)/&.translated/' src/util/system.cpp test/lint/lint-format-strings.py
-END VERIFY SCRIPT-
@hebasto hebasto force-pushed the 20190709-bilingual-part-one branch from 375d909 to 753f7cc Compare July 24, 2019 13:33
@hebasto hebasto changed the title gui: Add bilingual_str type Add bilingual_str type Jul 24, 2019
@hebasto
Copy link
Member Author

hebasto commented Jul 24, 2019

There currently a lint error making travis fail, but this looks good otherwise.

Fixed.

One thing is I would probably remove "gui:" prefix from PR title because that even though this is refactoring that doesn't change behavior and is meant to help the gui, the prefix could mislead reviewers to thinking the PR doesn't touch non-gui code.

Fair point. Done.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 753f7cc. Only change since last review is fixing lint error (double includes)

@maflcko
Copy link
Member

maflcko commented Jul 24, 2019

ACK 753f7cc

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 753f7cccce
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiBwgv+OJt8U0HjITstlQNagRqZacUEQZyME/hdiZRw7caFb5FGuDAulw8igqrl
PyfXIFF++rOnK/SztA/KklP6vTaTQ5VhVJpMYLsklwE0Bq4WLfhrKOybpnI+WZbo
Iv/jbKwTpjw2XR/LtVIZ6F1Dos3CTBFfJwDXgru6JEi86ByOMf9X7yCJdEi1v546
Bpg9brypH3hwcmv40mTlqazxYGvbX8PKRxH8TpEStgmyujpsKsnLHsAAQAFqAO+R
mlSC8IhT35IXAxUlr8LTvyIK1sVmShfOm9j2xUZh9DLBPR8aVt19eHgcYUNh/z1Z
ybNOe+MyYnfAnfHFmWAFaBd9lFiZWfbANsqI+htv1z5WDoEbq2j2urB7xnHbTiX+
fUmsCzUgMlIu88B02CyUuCqmeRYkPoPRIX0PEgqOVD83+TyseMjUzBPKHGgQhL71
GUV3yqgxAyme+cqFm8gHg3K/bBeY2vm5HRfK1RplJSssQrWJtzLpeT4uMSj5VSnV
qcBkK4py
=g2sy
-----END PGP SIGNATURE-----

Timestamp of file with hash ca358d398db24f0840fdb656fc63a356463d01b9f675517cbd06d4b4e20071c3 -

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Jul 24, 2019
753f7cc scripted-diff: Make translation bilingual (Hennadii Stepanov)
7c45e14 Add bilingual message type (Hennadii Stepanov)
0b86e51 Refactor out translation.h (Hennadii Stepanov)

Pull request description:

  This PR adds the `bilingual_str` struct and a `strprintf` overload:
  https://github.com/bitcoin/bitcoin/blob/0626b8cbdf0aa971500eb5613c7ab4096c496966/src/tinyformat.h#L1066-L1067

  Both new features allow bitcoin code to easily send dual translated and non-translated messages to the GUI and the logging framework.

  This PR is only a refactoring (has been split off the bitcoin#16224 (see: bitcoin#16224)) and does not change behavior.

ACKs for top commit:
  MarcoFalke:
    ACK 753f7cc
  ryanofsky:
    utACK 753f7cc. Only change since last review is fixing lint error (double includes)

Tree-SHA512: 52b0654421d558e4775c0484d78be26319fe3db5118af9b0a9bdfbdaad53a3704f527a5d5aba1013a64560b9b6a0c3c4cf0a6782e49aa731e18d99de95220385
@maflcko maflcko merged commit 753f7cc into bitcoin:master Jul 24, 2019
@hebasto hebasto deleted the 20190709-bilingual-part-one branch July 26, 2019 19:15
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 29, 2019
753f7cc scripted-diff: Make translation bilingual (Hennadii Stepanov)
7c45e14 Add bilingual message type (Hennadii Stepanov)
0b86e51 Refactor out translation.h (Hennadii Stepanov)

Pull request description:

  This PR adds the `bilingual_str` struct and a `strprintf` overload:
  https://github.com/bitcoin/bitcoin/blob/0626b8cbdf0aa971500eb5613c7ab4096c496966/src/tinyformat.h#L1066-L1067

  Both new features allow bitcoin code to easily send dual translated and non-translated messages to the GUI and the logging framework.

  This PR is only a refactoring (has been split off the bitcoin#16224 (see: bitcoin#16224)) and does not change behavior.

ACKs for top commit:
  MarcoFalke:
    ACK 753f7cc
  ryanofsky:
    utACK 753f7cc. Only change since last review is fixing lint error (double includes)

Tree-SHA512: 52b0654421d558e4775c0484d78be26319fe3db5118af9b0a9bdfbdaad53a3704f527a5d5aba1013a64560b9b6a0c3c4cf0a6782e49aa731e18d99de95220385
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2020
Summary:
This is a partial backport of Core [[bitcoin/bitcoin#16362 | PR16362]] : bitcoin/bitcoin@7c45e14

Depends on D6048

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6050
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2020
Summary:
-BEGIN VERIFY SCRIPT-
sed -i 's/inline std::string _(const char\* psz)/inline bilingual_str _(const char\* psz)/' src/util/translation.h
sed -i 's/return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz;/return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};/' src/util/translation.h
sed -i 's/\b_("\([^"]\|\\"\)*")/&.translated/g' $(git grep --files-with-matches '\b_("' src)
echo Hard cases - multiline strings.
sed -i 's/"Visit %s for further information about the software.")/&.translated/g' src/init.cpp
sed -i "s/\"Only rebuild the block database if you are sure that your computer's date and time are correct\")/&.translated/g" src/init.cpp
sed -i 's/" restore from a backup.")/&.translated/g' src/wallet/db.cpp
sed -i 's/" or address book entries might be missing or incorrect.")/&.translated/g' src/wallet/wallet.cpp
echo Special case.
sed -i 's/_(COPYRIGHT_HOLDERS)/&.translated/' src/util/system.cpp test/lint/lint-format-strings.py
-END VERIFY SCRIPT-

This is a partial backport of Core [[bitcoin/bitcoin#16362 | PR16362]] : bitcoin/bitcoin@753f7cc

Depends on D6050

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6052
kwvg added a commit to kwvg/dash that referenced this pull request Nov 6, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Nov 30, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Nov 30, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Nov 30, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Nov 30, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants