-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.mprot
More file actions
196 lines (174 loc) · 5.99 KB
/
schema.mprot
File metadata and controls
196 lines (174 loc) · 5.99 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
package lxn
// Catalog holds messages for a single locale. It corresponds to a the contents
// of one or more translation files. If you'd like to format translated
// messages propery you need a dictionary, which also contains all the locale
// information.
struct Catalog {
LocaleID string `1`
Messages []Message `2`
}
// Dictionary is used to translate and format messages for the specified locale.
// It holds all the messages (like Catalog), but also contains all the information
// needed to format numbers and plurals in this locale.
struct Dictionary {
Locale Locale `1`
Messages []Message `2`
}
// Symbols holds all the symbols that are used to format a number in a specific locale.
struct Symbols {
Decimal string `1`
Group string `2`
Percent string `3`
Minus string `4`
Inf string `5`
Nan string `6`
Zero uint32 `7`
}
// NumberFormat holds all relevant information to format a number in a specific locale.
struct NumberFormat {
Symbols Symbols `1`
PositivePrefix string `2`
PositiveSuffix string `3`
NegativePrefix string `4`
NegativeSuffix string `5`
MinIntegerDigits int `6`
MinFractionDigits int `7`
MaxFractionDigits int `8`
PrimaryIntegerGrouping int `9`
SecondaryIntegerGrouping int `10`
FractionGrouping int `11`
}
// PluralCategory is an enumeration of supported plural types. Each plural category
// can have its own translation text.
enum PluralCategory {
Zero `0`
One `1`
Two `2`
Few `3`
Many `4`
Other `5`
}
// Operand represents an operand in a plural rule.
//
// https://unicode.org/reports/tr35/tr35-numbers.html#Operands
enum Operand {
AbsoluteValue `0` // n
IntegerDigits `1` // i
NumFracDigits `2` // v
NumFracDigitsNoZeros `3` // w
FracDigits `4` // f
FracDigitsNoZeros `5` // t
CompactDecExponent `6` // c, e
}
// Connective represents a logical connective for two plural rules. Two plural
// rules can be connected by a conjunction ('and' operator) or a disjunction
// ('or' operator). The conjunction binds more tightly.
enum Connective {
None `0`
Conjunction `1`
Disjunction `2`
}
// Range represents an integer range, where both bounds are inclusive.
// If the lower bound equals the upper bound, the range will collapse
// to a single value.
struct Range {
LowerBound int `1`
UpperBound int `2`
}
// PluralRule holds the data for a single plural rule. The Modulo field defines the
// modulo divisor for the operand. If Modulo is zero, no remainder has to be calculated.
//
// The plural rule could be connected with another rule. If so, the Connective field is
// set to the respective value (Conjunction or Disjunction). Otherwise the Connective
// field is set to None and there is no follow-up rule.
//
// Example for a plural rule: i%10=1..3
struct PluralRule {
Operand Operand `1`
Modulo int `2`
Negate bool `3`
Ranges []Range `4`
Connective Connective `5`
}
// Plural represents a single plural form. It holds a collection of plural rules
// for a specific plural category where all rules are connected with each other (see
// Rule and Connective).
struct Plural {
Category PluralCategory `1`
Rules []PluralRule `2`
}
// Locale holds the data which is necessary to format data in a region
// specific format.
struct Locale {
ID string `1`
DecimalFormat NumberFormat `2`
MoneyFormat NumberFormat `3`
PercentFormat NumberFormat `4`
CardinalPlurals []Plural `5`
OrdinalPlurals []Plural `6`
}
// Message holds the data for a single message. Each message consists of
// a list of fragments which has to be concatenated to receive the final
// message text. If the message does not contain any replacement variables,
// there will only be a single string fragment.
struct Message {
Section string `1`
Key string `2`
Text []string `3`
Replacements []Replacement `4`
}
// Replacement describes a variable piece of text in a message which will be replaced
// during runtime. The key defines the variable's name which will be passed in. The type
// contains more details about the particular replacement.
struct Replacement {
Key string `1`
TextPos int `2`
Type ReplacementType `3`
Details ReplacementDetails `4`
}
// ReplacementDetails holds the details for particular replacements. The special
// EmptyDetails branch indicates that there a no details for the replacement type.
union ReplacementDetails {
EmptyDetails `1`
MoneyDetails `2`
PluralDetails `3`
SelectDetails `4`
}
// ReplacementType describes the type of a replacement. Each type contains the details
// necessary to render the variable's value.
enum ReplacementType {
StringReplacement `1`
NumberReplacement `2`
PercentReplacement `3`
MoneyReplacement `4`
PluralReplacement `5`
SelectReplacement `6`
}
// PluralType is an enumeration for the types of a plural form.
enum PluralType {
Cardinal `0`
Ordinal `1`
}
// EmptyDetails describes a special type for a replacement that has no further
// details attached.
struct EmptyDetails {
}
// MoneyDetails contains the replacement details for amounts of money.
struct MoneyDetails {
Currency string `1`
}
// PluralDetails contains the replacement details for plurals. Depending on the
// variable, different text for each plural rule can be selected. It contains
// the variants for the supported plural categories and custom overwrites.
struct PluralDetails {
Type PluralType `1`
Variants map[PluralCategory]Message `2`
Custom map[int64]Message `3`
}
// SelectDetails contains the replacement details to select a text fragment
// depending on the given variable. The fallback is an optional value which
// describes the default case.
struct SelectDetails {
Cases map[string]Message `1`
Fallback string `2`
}