translate/
lib.rs

1#[cfg(test)]
2mod tests {
3    #[test]
4    fn it_works() {
5        assert_eq!(2 + 2, 4);
6    }
7}
8
9pub fn tr(index: usize, lang: String) -> String {
10    let fr = ["bonjour", "tout", "le monde"];
11    let en = ["hello", "all", "the world"];
12
13    if index >= fr.len() {
14        return String::from("Not Found");
15    }
16
17    if lang == "fr" {
18        String::from(fr[index])
19    } else {
20        String::from(en[index])
21    }
22}