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_fr() -> Locale<'static> {
29 serde_json::de::from_str(include_str!("fr.json")).unwrap()
30}
31#[cfg(any(feature = "serde", test))]
32pub fn get_nl() -> Locale<'static> {
33 serde_json::de::from_str(include_str!("nl.json")).unwrap()
34}
35#[cfg(any(feature = "serde", test))]
36pub fn get_all() -> impl Iterator<Item = (&'static str, Locale<'static>)> {
37 [
38 ("en", get_en()),
39 ("en_fuck", get_en_fuck()),
40 ("de", get_de()),
41 ("ru", get_ru()),
42 ("it", get_it()),
43 ("fr", get_fr()),
44 ("nl", get_nl()),
45 ]
46 .into_iter()
47}
48
49#[derive(Debug, Clone, Default)]
59#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
60#[non_exhaustive]
61pub struct Locale<'a> {
62 pub bot_disclaimer: Cow<'a, str>,
63 pub notes: Notes<'a>,
64 pub format: Format<'a>,
65}
66
67#[derive(Debug, Clone, Default)]
68#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
69#[non_exhaustive]
70pub struct Notes<'a> {
71 pub tower: Cow<'a, str>,
72 pub tower_mult: Cow<'a, str>,
73 pub digits: Cow<'a, str>,
74 pub digits_mult: Cow<'a, str>,
75 pub approx: Cow<'a, str>,
76 pub approx_mult: Cow<'a, str>,
77 pub round: Cow<'a, str>,
78 pub round_mult: Cow<'a, str>,
79 pub too_big: Cow<'a, str>,
80 pub too_big_mult: Cow<'a, str>,
81 pub remove: Cow<'a, str>,
82 pub tetration: Cow<'a, str>,
83 pub no_post: Cow<'a, str>,
84 pub mention: Cow<'a, str>,
85 pub limit_hit: Option<Cow<'a, str>>,
86 pub write_out_unsupported: Option<Cow<'a, str>>,
87 pub nested_used: Option<Cow<'a, str>>,
88}
89
90#[derive(Debug, Clone, Default)]
91#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
92#[non_exhaustive]
93pub struct Format<'a> {
94 pub capitalize_calc: bool,
95 pub termial: Cow<'a, str>,
96 pub factorial: Cow<'a, str>,
97 pub uple: Cow<'a, str>,
98 pub sub: Cow<'a, str>,
99 pub negative: Cow<'a, str>,
100 pub num_overrides: HashMap<i32, Cow<'a, str>>,
101 pub force_num: bool,
102 pub nest: Cow<'a, str>,
103 pub rough_number: Cow<'a, str>,
104 pub exact: Cow<'a, str>,
105 pub rough: Cow<'a, str>,
106 pub approx: Cow<'a, str>,
107 pub digits: Cow<'a, str>,
108 pub order: Cow<'a, str>,
109 pub all_that: Cow<'a, str>,
110 pub number_format: NumFormat,
111}
112
113#[derive(Debug, Clone)]
114#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
115#[non_exhaustive]
116pub struct NumFormat {
117 pub decimal: char,
118}
119
120impl Default for NumFormat {
121 fn default() -> Self {
122 NumFormat { decimal: '.' }
123 }
124}