Add bilingual_str type #16362

pull hebasto wants to merge 3 commits into bitcoin:master from hebasto:20190709-bilingual-part-one changing 27 files +248 −184
  1. hebasto commented at 6:01 pm on July 9, 2019: member

    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 #16224 (see: https://github.com/bitcoin/bitcoin/pull/16224/#issuecomment-509718579)) and does not change behavior.

  2. hebasto commented at 6:02 pm on July 9, 2019: member
    GH does not render comment address correctly: https://github.com/bitcoin/bitcoin/pull/16224/#issuecomment-509701396
  3. MarcoFalke commented at 6:48 pm on July 9, 2019: member

    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

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK 4e1eda717e, the diff seems verbose but I think it makes sense
     4to be more explicit where translated strings are passed in.
     5Currently we have issues where translated strings end up in the debug log.
     6
     7Also, this is a requirement for future fixes such as [#16224](/bitcoin-bitcoin/16224/)
     8-----BEGIN PGP SIGNATURE-----
     9
    10iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    11pUgAxgv7B8gVJW+NBhgvYFjV7GzTcEDz0+R5pW0pW+8JXt5bYm4l9YkmBZVq/kk+
    12Pf/Wr2Vv91OoFIAiAu8iObedp35PzybgeZ4Dc9HlidhOHZvqxOrjNf+lINNyh+ZZ
    13ibv0VVcNQTeffMf6+zQoHazuyJPtNarJHmfPQQPBuYPbniW8DpDcRtamMIBxg0sd
    142FMLWtgt214boyf0aNUTmQUjxqwtafuqSpOri1VVMc458lIAKma8tdQUo9U/ryfP
    15+F8ev8SuK+ZJF3DRqah5mCO6+5Cd5vv0e/wsVemL6DBW11IuTOdW8WCFQoTIQINL
    16ayT1m4fbe9wdKh1r/j4Hla8qGjrtPSfgoEj+wfghACLP2MVZxZwqraLz2tH4NFQ4
    178zVtjR7Ms1PVSSNFGEoEWU7ouYdX/Jgz/KDp/MxpeFMwzTNZkBWrP5An1AwuJyyt
    185VR16+80UJfF5qnOXpO3tt7t7CQzB194ZBJVLneTVUye0Q/87xW8Y5MjCDn5QBVD
    19TtPRZurp
    20=g2TS
    21-----END PGP SIGNATURE-----
    

    Timestamp of file with hash a12ab7776476c20805e88823e532aa26d34082ee0510d1f17344e7869974c62a -

  4. MarcoFalke added this to the milestone 0.19.0 on Jul 9, 2019
  5. DrahtBot commented at 7:40 pm on July 9, 2019: member

    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.

  6. fanquake added the label GUI on Jul 9, 2019
  7. DrahtBot added the label Needs rebase on Jul 9, 2019
  8. hebasto force-pushed on Jul 10, 2019
  9. hebasto commented at 3:15 pm on July 10, 2019: member
    Rebased.
  10. DrahtBot removed the label Needs rebase on Jul 10, 2019
  11. DrahtBot added the label Needs rebase on Jul 16, 2019
  12. hebasto force-pushed on Jul 18, 2019
  13. hebasto commented at 4:37 pm on July 18, 2019: member
    Rebased.
  14. DrahtBot removed the label Needs rebase on Jul 18, 2019
  15. DrahtBot added the label Needs rebase on Jul 23, 2019
  16. hebasto force-pushed on Jul 23, 2019
  17. hebasto commented at 5:19 pm on July 23, 2019: member
    Rebased.
  18. DrahtBot removed the label Needs rebase on Jul 23, 2019
  19. ryanofsky approved
  20. ryanofsky commented at 8:04 pm on July 23, 2019: member

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

    Conditional utACK 3b7348ff8a4633679a387dcbfe266348dcba6c2a 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.

  21. DrahtBot added the label Needs rebase on Jul 24, 2019
  22. DrahtBot commented at 0:43 am on July 24, 2019: member
  23. hebasto renamed this:
    gui: Bilingual translation
    gui: Add bilingual_str type
    on Jul 24, 2019
  24. hebasto commented at 12:27 pm on July 24, 2019: member

    @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 ;)

  25. hebasto force-pushed on Jul 24, 2019
  26. ryanofsky approved
  27. ryanofsky commented at 1:31 pm on July 24, 2019: member

    utACK 375d90974a9ba3569bb6710c8f26cdda53d01389. 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.

  28. Refactor out translation.h
    This is a prerequisite for introducing bilingual error messages.
    Note: #includes are arranged by clang-format-diff.py script.
    0b86e517ad
  29. Add bilingual message type 7c45e14f2f
  30. scripted-diff: Make translation bilingual
    -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-
    753f7cccce
  31. hebasto force-pushed on Jul 24, 2019
  32. hebasto renamed this:
    gui: Add bilingual_str type
    Add bilingual_str type
    on Jul 24, 2019
  33. hebasto commented at 1:46 pm on July 24, 2019: member

    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.

  34. fanquake removed the label Needs rebase on Jul 24, 2019
  35. fanquake removed the label GUI on Jul 24, 2019
  36. fanquake added the label Utils/log/libs on Jul 24, 2019
  37. ryanofsky approved
  38. ryanofsky commented at 2:06 pm on July 24, 2019: member
    utACK 753f7cccce83084f4b18cf4bdf3225183179508c. Only change since last review is fixing lint error (double includes)
  39. MarcoFalke commented at 6:06 pm on July 24, 2019: member

    ACK 753f7cccce

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK 753f7cccce
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUiBwgv+OJt8U0HjITstlQNagRqZacUEQZyME/hdiZRw7caFb5FGuDAulw8igqrl
     8PyfXIFF++rOnK/SztA/KklP6vTaTQ5VhVJpMYLsklwE0Bq4WLfhrKOybpnI+WZbo
     9Iv/jbKwTpjw2XR/LtVIZ6F1Dos3CTBFfJwDXgru6JEi86ByOMf9X7yCJdEi1v546
    10Bpg9brypH3hwcmv40mTlqazxYGvbX8PKRxH8TpEStgmyujpsKsnLHsAAQAFqAO+R
    11mlSC8IhT35IXAxUlr8LTvyIK1sVmShfOm9j2xUZh9DLBPR8aVt19eHgcYUNh/z1Z
    12ybNOe+MyYnfAnfHFmWAFaBd9lFiZWfbANsqI+htv1z5WDoEbq2j2urB7xnHbTiX+
    13fUmsCzUgMlIu88B02CyUuCqmeRYkPoPRIX0PEgqOVD83+TyseMjUzBPKHGgQhL71
    14GUV3yqgxAyme+cqFm8gHg3K/bBeY2vm5HRfK1RplJSssQrWJtzLpeT4uMSj5VSnV
    15qcBkK4py
    16=g2sy
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash ca358d398db24f0840fdb656fc63a356463d01b9f675517cbd06d4b4e20071c3 -

  40. MarcoFalke referenced this in commit d960d5ca99 on Jul 24, 2019
  41. MarcoFalke merged this on Jul 24, 2019
  42. MarcoFalke closed this on Jul 24, 2019

  43. hebasto deleted the branch on Jul 26, 2019
  44. sidhujag referenced this in commit b4919222bc on Jul 29, 2019
  45. deadalnix referenced this in commit 917bbbb1de on May 13, 2020
  46. deadalnix referenced this in commit 8a9cc07623 on May 13, 2020
  47. kittywhiskers referenced this in commit c7da18e243 on Nov 6, 2021
  48. kittywhiskers referenced this in commit 91e74d0b44 on Nov 30, 2021
  49. kittywhiskers referenced this in commit 42e5bfe8c1 on Nov 30, 2021
  50. kittywhiskers referenced this in commit 3bd97cc679 on Nov 30, 2021
  51. kittywhiskers referenced this in commit dbb322add5 on Nov 30, 2021
  52. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-06-29 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me