#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LocaleEntry {
pub category: Option<String>,
pub key: String,
pub value: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LocaleFile {
pub lang: String,
pub file: String,
pub entries: Vec<LocaleEntry>,
}
impl LocaleFile {
#[must_use]
pub fn to_cfg(&self) -> String {
let mut output = String::new();
let mut current_category: Option<&str> = None;
let mut first_section = true;
for entry in &self.entries {
let category = entry.category.as_deref();
if category != current_category {
if !first_section {
output.push('\n');
}
if let Some(name) = category {
output.push('[');
output.push_str(name);
output.push_str("]\n");
}
current_category = category;
first_section = false;
}
output.push_str(&entry.key);
output.push('=');
output.push_str(&entry.value);
output.push('\n');
}
output
}
}