bitcoin_string/translation.rs
1crate::ix!();
2
3//-------------------------------------------[.cpp/bitcoin/src/util/translation.h]
4
5/**
6 | Bilingual messages:
7 |
8 | - in GUI: user's native language + untranslated
9 | (i.e. English)
10 |
11 | - in log and stderr: untranslated only
12 |
13 */
14#[derive(Default)]
15pub struct BilingualStr {
16 original: String,
17 translated: String,
18}
19
20impl AddAssign<&BilingualStr> for BilingualStr {
21
22 #[inline]fn add_assign(&mut self, other: &BilingualStr) {
23 todo!();
24 /*
25 original += rhs.original;
26 translated += rhs.translated;
27 return *this;
28 */
29 }
30}
31
32impl BilingualStr {
33
34 pub fn empty(&self) -> bool {
35
36 todo!();
37 /*
38 return original.empty();
39 */
40 }
41
42 pub fn clear(&mut self) {
43
44 todo!();
45 /*
46 original.clear();
47 translated.clear();
48 */
49 }
50}
51
52impl Add<&BilingualStr> for BilingualStr {
53
54 type Output = BilingualStr;
55
56 fn add(self, other: &BilingualStr) -> Self::Output {
57 todo!();
58 /*
59 lhs += rhs;
60 return lhs;
61 */
62 }
63}
64
65impl From<&str> for BilingualStr {
66 fn from(x: &str) -> Self {
67 untranslated(x)
68 }
69}
70
71/**
72 | Mark a bilingual_str as untranslated
73 |
74 */
75#[inline] pub fn untranslated(original: &str) -> BilingualStr {
76
77 todo!();
78 /*
79 return {original, original};
80 */
81}
82
83pub mod tinyformat {
84
85 use super::*;
86
87 pub fn format<Args>(
88 fmt: &BilingualStr,
89 args: &Args) -> BilingualStr {
90
91 todo!();
92 /*
93 return bilingual_str{format(fmt.original, args...), format(fmt.translated, args...)};
94 */
95 }
96}
97
98/**
99 | Translate a message to the native language
100 | of the user.
101 |
102 */
103lazy_static!{
104 /*
105 const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
106 */
107}
108
109/**
110 | Translation function.
111 |
112 | If no translation function is set, simply
113 | return the input.
114 |
115 */
116lazy_static!{
117 /*
118 inline bilingual_str _(const char* psz)
119 {
120 return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};
121 }
122 */
123}