-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlocale_enumer.go
121 lines (108 loc) · 3.68 KB
/
locale_enumer.go
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
// Code generated by "enumer -type=Locale -linecomment -json"; DO NOT EDIT.
//
package azuretexttospeech
import (
"encoding/json"
"fmt"
)
const _LocaleName = "ar-EGar-SAbg-BGca-EScs-CZda-DKde-ATde-CHde-DEel-GRen-AUen-CAen-GBen-IEen-INen-USes-ESes-MXet-EEfi-FIfr-CAfr-CHfr-FRga-IEhe-ILhi-INhr-HRhu-HUid-IDit-ITja-JPko-KRlt-LTlv-LVmt-MTmr-INms-MYnb-NOnl-NLpl-PLpt-BRpt-PTro-ROru-RUsk-SKsl-SIsv-SEta-INte-INth-THtr-TRvi-VNzh-CNzh-HKzh-TW"
var _LocaleIndex = [...]uint16{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275}
func (i Locale) String() string {
if i < 0 || i >= Locale(len(_LocaleIndex)-1) {
return fmt.Sprintf("Locale(%d)", i)
}
return _LocaleName[_LocaleIndex[i]:_LocaleIndex[i+1]]
}
var _LocaleValues = []Locale{0, 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}
var _LocaleNameToValueMap = map[string]Locale{
_LocaleName[0:5]: 0,
_LocaleName[5:10]: 1,
_LocaleName[10:15]: 2,
_LocaleName[15:20]: 3,
_LocaleName[20:25]: 4,
_LocaleName[25:30]: 5,
_LocaleName[30:35]: 6,
_LocaleName[35:40]: 7,
_LocaleName[40:45]: 8,
_LocaleName[45:50]: 9,
_LocaleName[50:55]: 10,
_LocaleName[55:60]: 11,
_LocaleName[60:65]: 12,
_LocaleName[65:70]: 13,
_LocaleName[70:75]: 14,
_LocaleName[75:80]: 15,
_LocaleName[80:85]: 16,
_LocaleName[85:90]: 17,
_LocaleName[90:95]: 18,
_LocaleName[95:100]: 19,
_LocaleName[100:105]: 20,
_LocaleName[105:110]: 21,
_LocaleName[110:115]: 22,
_LocaleName[115:120]: 23,
_LocaleName[120:125]: 24,
_LocaleName[125:130]: 25,
_LocaleName[130:135]: 26,
_LocaleName[135:140]: 27,
_LocaleName[140:145]: 28,
_LocaleName[145:150]: 29,
_LocaleName[150:155]: 30,
_LocaleName[155:160]: 31,
_LocaleName[160:165]: 32,
_LocaleName[165:170]: 33,
_LocaleName[170:175]: 34,
_LocaleName[175:180]: 35,
_LocaleName[180:185]: 36,
_LocaleName[185:190]: 37,
_LocaleName[190:195]: 38,
_LocaleName[195:200]: 39,
_LocaleName[200:205]: 40,
_LocaleName[205:210]: 41,
_LocaleName[210:215]: 42,
_LocaleName[215:220]: 43,
_LocaleName[220:225]: 44,
_LocaleName[225:230]: 45,
_LocaleName[230:235]: 46,
_LocaleName[235:240]: 47,
_LocaleName[240:245]: 48,
_LocaleName[245:250]: 49,
_LocaleName[250:255]: 50,
_LocaleName[255:260]: 51,
_LocaleName[260:265]: 52,
_LocaleName[265:270]: 53,
_LocaleName[270:275]: 54,
}
// LocaleString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func LocaleString(s string) (Locale, error) {
if val, ok := _LocaleNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Locale values", s)
}
// LocaleValues returns all values of the enum
func LocaleValues() []Locale {
return _LocaleValues
}
// IsALocale returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Locale) IsALocale() bool {
for _, v := range _LocaleValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for Locale
func (i Locale) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for Locale
func (i *Locale) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("Locale should be a string, got %s", data)
}
var err error
*i, err = LocaleString(s)
return err
}