pyc_shell/translator/lang/
mod.rs

1//! ## Languages
2//!
3//! `lang` are empty structs which must implement the Translator trait
4
5/*
6*
7*   Copyright (C) 2020 Christian Visintin - christian.visintin1997@gmail.com
8*
9* 	This file is part of "Pyc"
10*
11*   Pyc is free software: you can redistribute it and/or modify
12*   it under the terms of the GNU General Public License as published by
13*   the Free Software Foundation, either version 3 of the License, or
14*   (at your option) any later version.
15*
16*   Pyc is distributed in the hope that it will be useful,
17*   but WITHOUT ANY WARRANTY; without even the implied warranty of
18*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*   GNU General Public License for more details.
20*
21*   You should have received a copy of the GNU General Public License
22*   along with Pyc.  If not, see <http://www.gnu.org/licenses/>.
23*
24*/
25
26/// ### Language
27///
28/// Cyrillic alphabet language
29/// NOTE: add here new languages
30#[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
31pub enum Language {
32  Belarusian,
33  Bulgarian,
34  Russian,
35  Serbian,
36  Ukrainian,
37  Nil
38}
39
40/// ## Languages
41///
42/// Languages are empty structs which must implement the Translator trait
43
44//NOTE: languages are listed here
45pub(crate) struct Belarusian {}
46pub(crate) struct Bulgarian {}
47pub(crate) struct Russian {}
48pub(crate) struct Serbian {}
49pub(crate) struct Ukrainian {}
50pub(crate) struct Nil {}
51mod belarusian;
52mod bulgarian;
53mod russian;
54mod serbian;
55mod ukrainian;
56mod nil;
57
58impl ToString for Language {
59    fn to_string(&self) -> String {
60        match self {
61        Language::Belarusian => String::from("бел"),
62        Language::Bulgarian => String::from("блг"),
63        Language::Russian => String::from("рус"),
64        Language::Serbian => String::from("срб"),
65        Language::Ukrainian => String::from("укр"),
66        Language::Nil => String::from("nil")
67        }
68    }
69}
70
71#[cfg(test)]
72mod tests {
73
74  use super::*;
75
76  #[test]
77  fn test_translator_language_to_string() {
78    assert_eq!(Language::Belarusian.to_string(), String::from("бел"));
79    assert_eq!(Language::Bulgarian.to_string(), String::from("блг"));
80    assert_eq!(Language::Russian.to_string(), String::from("рус"));
81    assert_eq!(Language::Serbian.to_string(), String::from("срб"));
82    assert_eq!(Language::Ukrainian.to_string(), String::from("укр"));
83    assert_eq!(Language::Nil.to_string(), String::from("nil"));
84  }
85
86}