Expand description
Localized endpoint text: resource references resolved against the host’s configured culture.
The framework follows the .NET model: metadata stores a resource key (optionally with a literal fallback), translations live in resource files, and the active culture is a host-wide setting. Nothing in a route declaration enumerates languages.
ⓘ
#[get("/api/blog")]
#[display(key = "endpoint.blog.list.name", text = "博客模块-博客列表")]
impl IRequest<Vec<BlogModel>> for ListBlogRequest {}Resources are registered at startup. The conventional layout needs one call:
ⓘ
Host::builder().add_localization().build(); // reads locales/<culture>.jsonFor a single-file deployment, compile them in:
ⓘ
Host::builder()
.add_localization_with(
LocalizationOptions::none()
.resources("zh-CN", include_str!("../locales/zh-CN.json"))
.resources("en", include_str!("../locales/en.json")),
)
.build();Lookup follows .NET’s resource fallback: exact culture, its parent cultures, then the default culture, then the literal fallback, then the key itself.
Structs§
- Localization
Options - Resource files registered with the host.
- Localized
String - The result of resolving a
TextRef. - String
Localizer - The framework’s default
IStringLocalizer: static JSON resource tables. - TextRef
- A reference to localized text.
Traits§
- IString
Localizer - Resolves resource keys for a culture.