1include!(concat!(env!("OUT_DIR"), "/english.rs"));
2
3#[must_use]
6pub fn english(key: &str) -> &str {
7 ENGLISH
8 .binary_search_by(|(listed, _)| listed.cmp(&key))
9 .map_or(key, |index| ENGLISH[index].1)
10}
11
12#[cfg(test)]
13mod tests {
14 use super::*;
15
16 #[test]
17 fn reads_the_source_language_file_and_writes_a_missing_key_as_itself() {
18 assert_eq!(
19 english("notice.correct_fields"),
20 "Please correct the {count} highlighted fields."
21 );
22 assert_eq!(
23 english("validation.money.invalid"),
24 "must be an amount such as 149.90"
25 );
26 assert_eq!(english("notice.nothing"), "notice.nothing");
27 }
28}