TagBalanceRule class

Inline rich-text tags (<b>…</b>, <j>…</j>) must balance, and a translation must carry the source key's tags in a single rendered message.

The rich-text recipe (docs/platforms-frontend.md, "Rich text inside one sentence"): a styled run inside a localized sentence is authored as an inline HTML-style tag in the ARB value, passed through gen_l10n as literal text, and rebuilt into spans by a small app-side helper from a tag → style map. That helper can only rebuild what is well-formed, so:

  • every open tag needs its close tag, properly nested;
  • a translation must use the same tags, the same number of times, as its source — a dropped </b> bolds the rest of the sentence, an invented tag renders as literal <x> in the UI.

Tags may move freely (target-language word order wins). Counts are compared over ONE rendered message, not the raw string, because an ICU plural/select repeats its tags once per branch. A source {n, plural, =1{<b>..</b>} other{<b>..</b>}} carries <b> twice in the raw value, but a target locale with a single CLDR category (Vietnamese, Japanese) correctly collapses to one other branch and carries it once. Both render exactly one <b> run, so both are correct. Collapsing every plural/select to its other branch (via IcuMessage.flattenToOther) before counting makes the comparison see what the user sees: the tags in a single rendering. Balance is still enforced over the WHOLE raw value, so a broken tag hiding in any branch is caught. Values without tags are ignored.

Inheritance

Constructors

TagBalanceRule()
const

Properties

defaultSeverity IssueSeverity
Default severity. May be overridden per-issue.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
name String
Stable rule identifier (snake_case). Used by the report formatter to group findings and by users to silence/ack via state file (post-v1.0).
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(DialectProject project) List<Issue>
Inspect project and return findings. May return an empty list. Should NOT throw — turn unexpected conditions into Issues so the report surfaces them rather than crashing.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited