Skip to main content

factorion_lib/
locale.rs

1#![doc = include_str!("../Locales.md")]
2use std::{borrow::Cow, collections::HashMap};
3
4#[cfg(any(feature = "serde", test))]
5use serde::{Deserialize, Serialize};
6
7#[cfg(any(feature = "serde", test))]
8pub fn get_en() -> Locale<'static> {
9    serde_json::de::from_str(include_str!("en.json")).unwrap()
10}
11#[cfg(any(feature = "serde", test))]
12pub fn get_en_fuck() -> Locale<'static> {
13    serde_json::de::from_str(include_str!("en_fuck.json")).unwrap()
14}
15#[cfg(any(feature = "serde", test))]
16pub fn get_de() -> Locale<'static> {
17    serde_json::de::from_str(include_str!("de.json")).unwrap()
18}
19#[cfg(any(feature = "serde", test))]
20pub fn get_ru() -> Locale<'static> {
21    serde_json::de::from_str(include_str!("ru.json")).unwrap()
22}
23#[cfg(any(feature = "serde", test))]
24pub fn get_it() -> Locale<'static> {
25    serde_json::de::from_str(include_str!("it.json")).unwrap()
26}
27#[cfg(any(feature = "serde", test))]
28pub fn get_all() -> impl Iterator<Item = (&'static str, Locale<'static>)> {
29    [
30        ("en", get_en()),
31        ("en_fuck", get_en_fuck()),
32        ("de", get_de()),
33        ("ru", get_ru()),
34        ("it", get_it()),
35    ]
36    .into_iter()
37}
38
39#[derive(Debug, Clone)]
40#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
41pub struct Locale<'a> {
42    pub bot_disclaimer: Cow<'a, str>,
43    pub notes: Notes<'a>,
44    pub format: Format<'a>,
45}
46#[derive(Debug, Clone)]
47#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
48pub struct Notes<'a> {
49    pub tower: Cow<'a, str>,
50    pub tower_mult: Cow<'a, str>,
51    pub digits: Cow<'a, str>,
52    pub digits_mult: Cow<'a, str>,
53    pub approx: Cow<'a, str>,
54    pub approx_mult: Cow<'a, str>,
55    pub round: Cow<'a, str>,
56    pub round_mult: Cow<'a, str>,
57    pub too_big: Cow<'a, str>,
58    pub too_big_mult: Cow<'a, str>,
59    pub remove: Cow<'a, str>,
60    pub tetration: Cow<'a, str>,
61    pub no_post: Cow<'a, str>,
62    pub mention: Cow<'a, str>,
63    pub limit_hit: Option<Cow<'a, str>>,
64    pub write_out_unsupported: Option<Cow<'a, str>>,
65}
66
67#[derive(Debug, Clone)]
68#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
69pub struct Format<'a> {
70    pub capitalize_calc: bool,
71    pub termial: Cow<'a, str>,
72    pub factorial: Cow<'a, str>,
73    pub uple: Cow<'a, str>,
74    pub sub: Cow<'a, str>,
75    pub negative: Cow<'a, str>,
76    pub num_overrides: HashMap<i32, Cow<'a, str>>,
77    pub force_num: bool,
78    pub nest: Cow<'a, str>,
79    pub rough_number: Cow<'a, str>,
80    pub exact: Cow<'a, str>,
81    pub rough: Cow<'a, str>,
82    pub approx: Cow<'a, str>,
83    pub digits: Cow<'a, str>,
84    pub order: Cow<'a, str>,
85    pub all_that: Cow<'a, str>,
86    pub number_format: NumFormat,
87}
88
89#[derive(Debug, Clone)]
90#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
91pub struct NumFormat {
92    pub decimal: char,
93}