Skip to content

U0018 ui-locale-strings

Rule: String literals shown to a person come from the translation catalogue, not written in the call.

Code U0018 (stable, never reused)
Id ui-locale-strings
Category ui
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded off
ui off opt-in: a project that has not started translating its UI would see this fire on every label; a project that translates turns it on
egui off opt-in: a project that has not started translating its UI would see this fire on every label; a project that translates turns it on
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
calls list of strings [] calls that show text to a person
toolkits list of strings ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"] UI toolkits: a crate that depends on one directly is a UI crate, unless the crate map says ui = false

Why

A project that translates its UI reads every piece of text a person sees from a translation catalogue, keyed by locale, never from a literal written into the call. Off by default: a project that does not translate yet would see this fire on every label it has.

The lint reports a string literal that holds a letter, passed to one of calls. A literal with no letter (a placeholder, a number, punctuation) needs no catalogue entry and is not reported.

ui.label("Connected");           // reported once the lint is on: move it to the catalogue
ui.label(t!("status.connected")); // passes: the literal is the catalogue key, not the text
ui.label(format!("{count}"));     // passes: no letter in the format string itself

How to fix

Move the text to the project's translation catalogue and pass the catalogue key (or the call the catalogue gives) instead of the literal.

Configure

[lints.ui-locale-strings]
level = "deny"
calls = []
toolkits = ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(ui-locale-strings) <reason> (waivers); the code works there too, as in [lints.U0018].