Skip to main content

agentics_domain/models/
localization.rs

1//! Localized text contracts shared by API, bundle, and frontend DTOs.
2
3use std::fmt;
4
5use serde::{Deserialize, Serialize};
6
7/// English and Chinese text for short public challenge copy.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
9#[serde(deny_unknown_fields)]
10pub struct LocalizedText {
11    pub en: String,
12    pub zh: String,
13}
14
15impl LocalizedText {
16    /// Build localized text from required English and Chinese values.
17    pub fn new(en: impl Into<String>, zh: impl Into<String>) -> Self {
18        Self {
19            en: en.into(),
20            zh: zh.into(),
21        }
22    }
23}
24
25impl fmt::Display for LocalizedText {
26    /// Formats both locales for validation diagnostics.
27    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28        write!(f, "en={}, zh={}", self.en, self.zh)
29    }
30}