timeago/languages/
french.rs1use super::super::{Language, TimeUnit};
2
3#[derive(Default)]
4pub struct French;
5impl Language for French {
6 fn clone_boxed(&self) -> super::super::BoxedLanguage {
7 Box::new(Self {})
8 }
9 fn too_low(&self) -> &'static str {
10 "maintenant"
11 }
12 fn too_high(&self) -> &'static str {
13 "ancien"
14 }
15 fn ago(&self) -> &'static str {
16 "il y a"
17 }
18 fn get_word(&self, tu: TimeUnit, x: u64) -> &'static str {
19 use TimeUnit::*;
20 if x == 1 {
21 match tu {
22 Nanoseconds => "nanoseconde",
23 Microseconds => "microseconde",
24 Milliseconds => "milliseconde",
25 Seconds => "seconde",
26 Minutes => "minute",
27 Hours => "heure",
28 Days => "jour",
29 Weeks => "semaine",
30 Months => "mois",
31 Years => "année",
32 }
33 } else {
34 match tu {
35 Nanoseconds => "nanosecondes",
36 Microseconds => "microsecondes",
37 Milliseconds => "milisecondes",
38 Seconds => "secondes",
39 Minutes => "minutes",
40 Hours => "heures",
41 Days => "jours",
42 Weeks => "semaines",
43 Months => "mois",
44 Years => "ans",
45 }
46 }
47 }
48 fn place_ago_before(&self) -> bool {
49 true
50 }
51}
52
53#[test]
54fn test() {
55 use super::super::Formatter;
56 use std::time::Duration;
57 let f = Formatter::with_language(French);
58 assert_eq!(f.convert(Duration::from_secs(60)), "il y a 1 minute");
59}