/home/a220/proj/radnelac/src/display/akan.rs
Line | Count | Source |
1 | | // This Source Code Form is subject to the terms of the Mozilla Public |
2 | | // License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | // file, You can obtain one at https://mozilla.org/MPL/2.0/. |
4 | | |
5 | | use crate::day_cycle::Akan; |
6 | | use crate::day_cycle::AkanPrefix; |
7 | | use crate::day_cycle::AkanStem; |
8 | | use crate::display::private::get_dict; |
9 | | use crate::display::text::prelude::Language; |
10 | | use std::fmt; |
11 | | |
12 | | impl fmt::Display for Akan { |
13 | 1.02k | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
14 | 1.02k | let dict = get_dict(Language::EN) |
15 | 1.02k | .akan_cycle |
16 | 1.02k | .as_ref() |
17 | 1.02k | .expect("Known to exist"); |
18 | | // Using names from Wikipedia |
19 | | // https://en.wikipedia.org/wiki/Akan_calendar |
20 | 1.02k | let prefix = match self.prefix() { |
21 | 212 | AkanPrefix::Nwona => dict.nwona, |
22 | 150 | AkanPrefix::Nkyi => dict.nkyi, |
23 | 152 | AkanPrefix::Kuru => dict.kuru, |
24 | 166 | AkanPrefix::Kwa => dict.kwa, |
25 | 156 | AkanPrefix::Mono => dict.mono, |
26 | 188 | AkanPrefix::Fo => dict.fo, |
27 | | }; |
28 | 1.02k | let stem = match self.stem() { |
29 | 172 | AkanStem::Wukuo => dict.wukuo, |
30 | 143 | AkanStem::Yaw => dict.yaw, |
31 | 162 | AkanStem::Fie => match self.prefix() { |
32 | 23 | AkanPrefix::Fo => dict.fie, |
33 | 139 | _ => dict.afie, |
34 | | }, |
35 | 157 | AkanStem::Memene => dict.memene, |
36 | 98 | AkanStem::Kwasi => dict.kwasi, |
37 | 134 | AkanStem::Dwo => dict.dwo, |
38 | 158 | AkanStem::Bene => dict.bene, |
39 | | }; |
40 | 1.02k | write!(f, "{}-{}", prefix, stem) |
41 | 1.02k | } |
42 | | } |