Skip to content
Clone
69f12aa
26 lines 1.1 KB Rust
//! Server-side message catalogue for everything the backend renders itself:
//! transactional e-mail, in-app notification text and the HTML result pages.
//!
//! The interface language is a per-recipient property, so this crate never
//! holds "the" locale — it resolves one per message from the recipient's
//! `users.language` and falls back to the request's `Accept-Language`, then to
//! `[email].default_locale`.
//!
//! Scope is deliberately narrow: two locales (`zh-CN`, `en`) covering the
//! strings the platform actually emits. Anything written by a user is never
//! translated here.
pub mod catalog;
pub mod locale;
pub use catalog::*;
pub use locale::{UiLocale, negotiate_accept_language, resolve_user_locale, resolve_user_locales};
/// Normalize a stored user preference to a locale this build can render.
///
/// `users.language` is a free-form preference, so values such as `ja` or `auto`
/// are normal: they are not errors, they simply do not select a UI catalogue and
/// therefore lose their turn in the chain.
pub fn from_user_preference(value: Option<&str>) -> Option<UiLocale> {
UiLocale::parse(value?)
}