[ai] Improve the tr::marked() force rules.

This commit is contained in:
John Preston
2026-03-27 12:54:49 +07:00
parent 1dca7c2a69
commit 507af0a14d
+14 -1
View File
@@ -114,7 +114,7 @@ bool _expanded = false;
SomeType *_pointer = nullptr;
```
## Prefer tr:: projections over Ui::Text:: in localization calls
## Use tr:: projections for TextWithEntities
Inside `tr::lng_...()` calls, always use the `tr::` projection helpers instead of their `Ui::Text::` equivalents. The `tr::` helpers are shorter and work uniformly as both placeholder wrappers and final projectors.
@@ -145,6 +145,19 @@ tr::lng_some_key(
tr::rich)
```
Also use `tr::marked()` as the standard way to create `TextWithEntities` — not just as a projector:
```cpp
// BAD - verbose constructor:
auto text = TextWithEntities();
auto text = TextWithEntities{ u"hello"_q };
auto text = TextWithEntities().append(u"hello"_q);
// GOOD - concise:
auto text = tr::marked();
auto text = tr::marked(u"hello"_q);
```
## Multi-line calls — one argument per line
When a function call doesn't fit on one line, put each argument on its own line. Don't group "logical pairs" on the same line — it creates inconsistent line lengths and makes diffs noisier.