diff --git a/src/lib.rs b/src/lib.rs index 6da52b0..fa6a021 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,12 @@ pub trait Language { fn place_unit_before(&self, _: u64) -> bool { false } + fn between_chunks(&self) -> &str { + " " + } + fn between_value_and_word(&self) -> &str { + " " + } /// Make a dynamic copy of this language fn clone_boxed(&self) -> BoxedLanguage; @@ -444,7 +450,11 @@ impl Formatter { if now != "0" { return now.to_owned(); } else { - ret = format!("0 {}", self.lang.get_word(self.min_unit, 0)); + ret = format!( + "0{}{}", + self.lang.between_value_and_word(), + self.lang.get_word(self.min_unit, 0) + ); } } @@ -483,12 +493,14 @@ impl Formatter { let recurse_result = self.convert_impl(rem, items_left - 1); let word = self.lang.get_word(dtu, x); + let between = self.lang.between_value_and_word(); + let between_chunk = self.lang.between_chunks(); match (self.lang.place_unit_before(x), recurse_result.is_empty()) { - (true, true) => format!("{word} {x}"), - (true, false) => format!("{word} {x} {recurse_result}"), - (false, true) => format!("{x} {word}"), - (false, false) => format!("{x} {word} {recurse_result}"), + (true, true) => format!("{word}{between}{x}"), + (true, false) => format!("{word}{between}{x}{between_chunk}{recurse_result}"), + (false, true) => format!("{x}{between}{word}"), + (false, false) => format!("{x}{between}{word}{between_chunk}{recurse_result}"), } } }