-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_path.rs
83 lines (83 loc) · 2.55 KB
/
example_path.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
pub trait Internationalize {
fn en(&self) -> Locale {
Locale::En
}
fn da(&self) -> Locale {
Locale::Da
}
}
/// Locale enum generated by "i18nify"
#[derive(Copy, Clone, Debug)]
pub enum Locale {
En,
Da,
}
#[allow(missing_docs)]
pub struct Type<'a>(pub &'a str);
#[allow(missing_docs)]
pub struct Two<'a>(pub &'a str);
#[allow(missing_docs)]
pub struct Name<'a>(pub &'a str);
#[allow(missing_docs)]
pub struct One<'a>(pub &'a str);
#[allow(missing_docs)]
pub struct Word<'a>(pub &'a str);
impl Locale {
#[allow(missing_docs)]
pub fn hello(self) -> String {
match self {
Locale::Da => format!("Hej, Verden!"),
Locale::En => format!("Hello, World!"),
}
}
#[allow(missing_docs)]
pub fn missing_interpolation_en(self, word_: Word<'_>) -> String {
match self {
Locale::En => format!("en foo",),
Locale::Da => format!("da foo {word}", word = word_.0),
}
}
#[allow(missing_docs)]
pub fn hello_newline(self) -> String {
match self {
Locale::Da => format!("Hej\nVerden!"),
Locale::En => format!("Hello\nWorld!"),
}
}
#[allow(missing_docs)]
pub fn two_placeholders(self, one_: One<'_>, two_: Two<'_>) -> String {
match self {
Locale::En => format!("en {one} {two}", one = one_.0, two = two_.0),
Locale::Da => format!("da {one} {two}", one = one_.0, two = two_.0),
}
}
#[allow(missing_docs)]
pub fn rust_keyword(self, type_: Type<'_>) -> String {
match self {
Locale::Da => format!("hva så {type}", type = type_.0),
Locale::En => format!("yo {type}", type = type_.0),
}
}
#[allow(missing_docs)]
pub fn duplicate_placeholders(self, name_: Name<'_>) -> String {
match self {
Locale::En => format!("Hey {name}. Is your name {name}?", name = name_.0),
Locale::Da => format!("Hej {name}. Er dit navn {name}?", name = name_.0),
}
}
#[allow(missing_docs)]
pub fn missing_interpolation_da(self, word_: Word<'_>) -> String {
match self {
Locale::Da => format!("da foo",),
Locale::En => format!("en foo {word}", word = word_.0),
}
}
#[allow(missing_docs)]
pub fn greeting(self, name_: Name<'_>) -> String {
match self {
Locale::En => format!("Hello {name}", name = name_.0),
Locale::Da => format!("Hej {name}", name = name_.0),
}
}
}
impl Internationalize for DocLocale {}