-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add bilingual_str type #16362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bilingual_str type #16362
Conversation
GH does not render comment address correctly: |
ACK 4e1eda7, the diff seems verbose but I think it makes sense Also, this is a requirement for future fixes such as #16224 Show signature and timestampSignature:
Timestamp of file with hash |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
4e1eda7
to
29b28c7
Compare
Rebased. |
29b28c7
to
d2a5927
Compare
Rebased. |
d2a5927
to
3b7348f
Compare
Rebased. |
There was a problem hiding this 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.
Needs rebase |
@ryanofsky Thank you for your review.
Done.
Let it be ;) |
3b7348f
to
375d909
Compare
There was a problem hiding this 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.
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-
375d909
to
753f7cc
Compare
Fixed.
Fair point. Done. |
There was a problem hiding this 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)
ACK 753f7cc Show signature and timestampSignature:
Timestamp of file with hash |
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
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
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
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
This PR adds the
bilingual_str
struct and astrprintf
overload:bitcoin/src/tinyformat.h
Lines 1066 to 1067 in 0626b8c
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.