File tree 1 file changed +27
-14
lines changed
1 file changed +27
-14
lines changed Original file line number Diff line number Diff line change 1
1
package conf
2
2
3
+ import "encoding/json"
4
+
3
5
const (
4
6
// Available themes
5
7
ThemeDefault = ThemeCxd
@@ -14,34 +16,45 @@ const (
14
16
LocaleEnUS = "en-US"
15
17
)
16
18
17
- type Theme = option
18
-
19
- type Local = option
20
-
21
- type option struct {
19
+ type Theme struct {
22
20
Value string `json:"value"`
23
21
Label string `json:"label"`
24
- Dict any `json:"-"`
22
+ }
23
+
24
+ type Local struct {
25
+ Value string `json:"value"`
26
+ Label string `json:"label"`
27
+ Dict json.RawMessage `json:"-"`
25
28
}
26
29
27
30
func RegularThemes (themes []Theme ) {
28
31
for i := range themes {
29
- themes [i ] = themes [i ].regular (ThemeDefault )
32
+ themes [i ] = themes [i ].regular ()
30
33
}
31
34
}
32
35
33
36
func RegularLocales (langs []Local ) {
34
37
for i := range langs {
35
- langs [i ] = langs [i ].regular (LocaleDefault )
38
+ langs [i ] = langs [i ].regular ()
39
+ }
40
+ }
41
+
42
+ func (t Theme ) regular () Theme {
43
+ if t .Value == "" {
44
+ t .Value = ThemeDefault
45
+ }
46
+ if t .Label == "" {
47
+ t .Label = t .Value
36
48
}
49
+ return t
37
50
}
38
51
39
- func (o option ) regular (placeholder string ) option {
40
- if o .Value == "" {
41
- o .Value = placeholder
52
+ func (l Local ) regular () Local {
53
+ if l .Value == "" {
54
+ l .Value = LocaleDefault
42
55
}
43
- if o .Label == "" {
44
- o .Label = o .Value
56
+ if l .Label == "" {
57
+ l .Label = l .Value
45
58
}
46
- return o
59
+ return l
47
60
}
You can’t perform that action at this time.
0 commit comments