es_fluent_generate/
value.rs1use heck::ToTitleCase as _;
2
3pub struct ValueFormatter;
4impl ValueFormatter {
5 pub fn expand(key: &str) -> String {
6 let mut parts = key.rsplit('-');
7 let last = parts.next().unwrap();
8 last.to_title_case()
9 }
10}
11
12#[cfg(test)]
13mod tests {
14 use super::*;
15
16 #[test]
17 fn test_value_formatter_expand() {
18 assert_eq!(ValueFormatter::expand("simple-key"), "Key");
19 assert_eq!(ValueFormatter::expand("another-test-value"), "Value");
20 assert_eq!(ValueFormatter::expand("single"), "Single");
21 }
22}