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_nl() -> Locale<'static> {
29    serde_json::de::from_str(include_str!("nl.json")).unwrap()
30}
31#[cfg(any(feature = "serde", test))]
32pub fn get_all() -> impl Iterator<Item = (&'static str, Locale<'static>)> {
33    [
34        ("en", get_en()),
35        ("en_fuck", get_en_fuck()),
36        ("de", get_de()),
37        ("ru", get_ru()),
38        ("it", get_it()),
39        ("nl", get_nl()),
40    ]
41    .into_iter()
42}
43
44#[derive(Debug, Clone)]
45#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
46pub struct Locale<'a> {
47    pub bot_disclaimer: Cow<'a, str>,
48    pub notes: Notes<'a>,
49    pub format: Format<'a>,
50}
51#[derive(Debug, Clone)]
52#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
53pub struct Notes<'a> {
54    pub tower: Cow<'a, str>,
55    pub tower_mult: Cow<'a, str>,
56    pub digits: Cow<'a, str>,
57    pub digits_mult: Cow<'a, str>,
58    pub approx: Cow<'a, str>,
59    pub approx_mult: Cow<'a, str>,
60    pub round: Cow<'a, str>,
61    pub round_mult: Cow<'a, str>,
62    pub too_big: Cow<'a, str>,
63    pub too_big_mult: Cow<'a, str>,
64    pub remove: Cow<'a, str>,
65    pub tetration: Cow<'a, str>,
66    pub no_post: Cow<'a, str>,
67    pub mention: Cow<'a, str>,
68    pub limit_hit: Option<Cow<'a, str>>,
69    pub write_out_unsupported: Option<Cow<'a, str>>,
70}
71
72#[derive(Debug, Clone)]
73#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
74pub struct Format<'a> {
75    pub capitalize_calc: bool,
76    pub termial: Cow<'a, str>,
77    pub factorial: Cow<'a, str>,
78    pub uple: Cow<'a, str>,
79    pub sub: Cow<'a, str>,
80    pub negative: Cow<'a, str>,
81    pub num_overrides: HashMap<i32, Cow<'a, str>>,
82    pub force_num: bool,
83    pub nest: Cow<'a, str>,
84    pub rough_number: Cow<'a, str>,
85    pub exact: Cow<'a, str>,
86    pub rough: Cow<'a, str>,
87    pub approx: Cow<'a, str>,
88    pub digits: Cow<'a, str>,
89    pub order: Cow<'a, str>,
90    pub all_that: Cow<'a, str>,
91    pub number_format: NumFormat,
92}
93
94#[derive(Debug, Clone)]
95#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
96pub struct NumFormat {
97    pub decimal: char,
98}