HomePhabricator

Extend bilingual_str support for tinyformat

Description

Extend bilingual_str support for tinyformat

Summary:
Previous bilingual_str tinyformat::format accepted bilingual format strings,
but not bilingual arguments. Extend it to accept both. This is useful when
embedding one translated string inside another translated string, for example:
strprintf(_("Error: %s"), message) which would fail previously if message
was a bilingual_str.

This is a partial backport of core#27150
https://github.com/bitcoin/bitcoin/pull/27150/commits/3db2874bd71d2391747b7385cabcbfef67218c4c


refactor: Avoid copy of bilingual_str when formatting, Fix ADL violation

The return type of TranslateArg is std::string, which creates a copy.
Fix this by moving everything into a lambda that takes a reference and
returns a reference.

Also, the format function is called without specifying the namespace it
lives in. Fix this by specifying the namespace. See also:
https://github.com/bitcoin/bitcoin/blob/7a59865793cd710d7d6650a6106ca4e790ced5d3/doc/developer-notes.md#L117-L137.

This is a backport of core#27892

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14993

Details

Provenance
Ryan Ofsky <ryan@ofsky.org>Authored on Mar 11 2024, 10:22
PiRKCommitted on Mar 12 2024, 14:25
PiRKPushed on Mar 12 2024, 14:26
Reviewer
Restricted Project
Differential Revision
D14993: Extend bilingual_str support for tinyformat
Parents
rABCa5e3440acb24: [Cashtab] Simplify and standardize buttons
Branches
Unknown
Tags
Unknown