forked from goodsign/monday
-
Notifications
You must be signed in to change notification settings - Fork 3
/
locale.go
141 lines (137 loc) · 3.65 KB
/
locale.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package monday
// Locale identifies locales supported by 'monday' package.
// Monday uses ICU locale identifiers. See http://userguide.icu-project.org/locale
type Locale string
// Locale constants represent all locales that are currently supported by
// this package.
const (
LocaleEnUS = "en_US" // English (United States)
LocaleEnGB = "en_GB" // English (United Kingdom)
LocaleDaDK = "da_DK" // Danish (Denmark)
LocaleNlBE = "nl_BE" // Dutch (Belgium)
LocaleNlNL = "nl_NL" // Dutch (Netherlands)
LocaleFiFI = "fi_FI" // Finnish (Finland)
LocaleFrFR = "fr_FR" // French (France)
LocaleFrCA = "fr_CA" // French (Canada)
LocaleDeDE = "de_DE" // German (Germany)
LocaleHuHU = "hu_HU" // Hungarian (Hungary)
LocaleItIT = "it_IT" // Italian (Italy)
LocaleNnNO = "nn_NO" // Norwegian Nynorsk (Norway)
LocaleNbNO = "nb_NO" // Norwegian Bokmål (Norway)
LocalePlPL = "pl_PL" // Polish (Poland)
LocalePtPT = "pt_PT" // Portuguese (Portugal)
LocalePtBR = "pt_BR" // Portuguese (Brazil)
LocaleRoRO = "ro_RO" // Romanian (Romania)
LocaleRuRU = "ru_RU" // Russian (Russia)
LocaleEsES = "es_ES" // Spanish (Spain)
LocaleCaES = "ca_ES" // Catalan (Spain)
LocaleSvSE = "sv_SE" // Swedish (Sweden)
LocaleTrTR = "tr_TR" // Turkish (Turkey)
LocaleUkUA = "uk_UA" // Ukrainian (Ukraine)
LocaleBgBG = "bg_BG" // Bulgarian (Bulgaria)
LocaleZhCN = "zh_CN" // Chinese (Mainland)
LocaleZhTW = "zh_TW" // Chinese (Taiwan)
LocaleZhHK = "zh_HK" // Chinese (Hong Kong)
LocaleKoKR = "ko_KR" // Korean (Korea)
LocaleJaJP = "ja_JP" // Japanese (Japan)
LocaleElGR = "el_GR" // Greek (Greece)
LocaleIdID = "id_ID" // Indonesian (Indonesia)
LocaleFrGP = "fr_GP" // French (Guadeloupe)
LocaleFrLU = "fr_LU" // French (Luxembourg)
LocaleFrMQ = "fr_MQ" // French (Martinique)
LocaleFrRE = "fr_RE" // French (Reunion)
LocaleFrGF = "fr_GF" // French (French Guiana)
LocaleCsCZ = "cs_CZ" // Czech (Czech Republic)
LocaleSlSI = "sl_SI" // Slovenian (Slovenia)
LocaleLtLT = "lt_LT" // Lithuanian (Lithuania)
LocaleEtEE = "et_EE" // Estonian (Estonia)
LocaleHrHR = "hr_HR" // Croatian (Croatia)
LocaleLvLV = "lv_LV" // Latvian (Latvia)
LocaleSkSK = "sk_SK" // Slovak (Slovakia)
LocaleThTH = "th_TH" // Thai (Thailand)
LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan)
LocaleKkKZ = "kk_KZ" // Kazakh (Kazakhstan)
)
// ListLocales returns all locales supported by the package.
func ListLocales() []Locale {
return []Locale{
LocaleEnUS,
LocaleEnGB,
LocaleDaDK,
LocaleNlBE,
LocaleNlNL,
LocaleFiFI,
LocaleFrFR,
LocaleFrCA,
LocaleDeDE,
LocaleHuHU,
LocaleItIT,
LocaleNnNO,
LocaleNbNO,
LocalePlPL,
LocalePtPT,
LocalePtBR,
LocaleRoRO,
LocaleRuRU,
LocaleEsES,
LocaleCaES,
LocaleSvSE,
LocaleTrTR,
LocaleUkUA,
LocaleBgBG,
LocaleZhCN,
LocaleZhTW,
LocaleZhHK,
LocaleKoKR,
LocaleJaJP,
LocaleElGR,
LocaleFrGP,
LocaleFrLU,
LocaleFrMQ,
LocaleFrRE,
LocaleFrGF,
LocaleCsCZ,
LocaleSlSI,
LocaleLtLT,
LocaleEtEE,
LocaleHrHR,
LocaleLvLV,
LocaleSkSK,
LocaleThTH,
LocaleUzUZ,
LocaleKkKZ,
}
}
// FuzzyLocale returns a locale from a two-character language string.
func FuzzyLocale(lang string) Locale {
locs := map[string]Locale{
"bg": LocaleBgBG,
"ca": LocaleCaES,
"cs": LocaleCsCZ,
"da": LocaleDaDK,
"de": LocaleDeDE,
"el": LocaleElGR,
"en": LocaleEnUS,
"es": LocaleEsES,
"fi": LocaleFiFI,
"fr": LocaleFrFR,
"hu": LocaleHuHU,
"id": LocaleIdID,
"it": LocaleItIT,
"ja": LocaleJaJP,
"nb": LocaleNbNO,
"nl": LocaleNlNL,
"nn": LocaleNnNO,
"pl": LocalePlPL,
"pt": LocalePtBR,
"ro": LocaleRoRO,
"ru": LocaleRuRU,
"sv": LocaleSvSE,
"tr": LocaleTrTR,
"zh": LocaleZhCN,
}
if l, ok := locs[lang]; ok {
return l
}
return LocaleEnUS
}