1package vo_001 2 3import ( 4 "math" 5 "strconv" 6 "time" 7 8 "github.com/go-playground/locales" 9 "github.com/go-playground/locales/currency" 10) 11 12type vo_001 struct { 13 locale string 14 pluralsCardinal []locales.PluralRule 15 pluralsOrdinal []locales.PluralRule 16 pluralsRange []locales.PluralRule 17 decimal string 18 group string 19 minus string 20 percent string 21 perMille string 22 timeSeparator string 23 inifinity string 24 currencies []string // idx = enum of currency code 25 monthsAbbreviated []string 26 monthsNarrow []string 27 monthsWide []string 28 daysAbbreviated []string 29 daysNarrow []string 30 daysShort []string 31 daysWide []string 32 periodsAbbreviated []string 33 periodsNarrow []string 34 periodsShort []string 35 periodsWide []string 36 erasAbbreviated []string 37 erasNarrow []string 38 erasWide []string 39 timezones map[string]string 40} 41 42// New returns a new instance of translator for the 'vo_001' locale 43func New() locales.Translator { 44 return &vo_001{ 45 locale: "vo_001", 46 pluralsCardinal: []locales.PluralRule{2, 6}, 47 pluralsOrdinal: nil, 48 pluralsRange: nil, 49 timeSeparator: ":", 50 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, 51 monthsAbbreviated: []string{"", "yan", "feb", "mäz", "prl", "may", "yun", "yul", "gst", "set", "ton", "nov", "dek"}, 52 monthsNarrow: []string{"", "Y", "F", "M", "P", "M", "Y", "Y", "G", "S", "T", "N", "D"}, 53 monthsWide: []string{"", "yanul", "febul", "mäzul", "prilul", "mayul", "yunul", "yulul", "gustul", "setul", "tobul", "novul", "dekul"}, 54 daysAbbreviated: []string{"su.", "mu.", "tu.", "ve.", "dö.", "fr.", "zä."}, 55 daysNarrow: []string{"S", "M", "T", "V", "D", "F", "Z"}, 56 daysWide: []string{"sudel", "mudel", "tudel", "vedel", "dödel", "fridel", "zädel"}, 57 erasAbbreviated: []string{"b. t. kr.", "p. t. kr."}, 58 erasNarrow: []string{"", ""}, 59 erasWide: []string{"b. t. kr.", "p. t. kr."}, 60 timezones: map[string]string{"EAT": "EAT", "ART": "ART", "WAST": "WAST", "EDT": "EDT", "AST": "AST", "WAT": "WAT", "AKST": "AKST", "WARST": "WARST", "HNT": "HNT", "TMT": "TMT", "HAST": "HAST", "CDT": "CDT", "AWDT": "AWDT", "HNEG": "HNEG", "MDT": "MDT", "CAT": "CAT", "COST": "COST", "HNCU": "HNCU", "HECU": "HECU", "HEPMX": "HEPMX", "SAST": "SAST", "BT": "BT", "JST": "JST", "ACST": "ACST", "MST": "MST", "CLT": "CLT", "WIT": "WIT", "CHAST": "CHAST", "GMT": "GMT", "WIB": "WIB", "HAT": "HAT", "HADT": "HADT", "MYT": "MYT", "HNOG": "HNOG", "EST": "EST", "SRT": "SRT", "CLST": "CLST", "CST": "CST", "JDT": "JDT", "PDT": "PDT", "AEDT": "AEDT", "MESZ": "MESZ", "IST": "IST", "HNPM": "HNPM", "OEZ": "OEZ", "UYST": "UYST", "CHADT": "CHADT", "WITA": "WITA", "HNPMX": "HNPMX", "SGT": "SGT", "ECT": "ECT", "WART": "WART", "HENOMX": "HENOMX", "OESZ": "OESZ", "AKDT": "AKDT", "MEZ": "MEZ", "ADT": "ADT", "WESZ": "WESZ", "NZDT": "NZDT", "VET": "VET", "HEPM": "HEPM", "COT": "COT", "UYT": "UYT", "AEST": "AEST", "WEZ": "WEZ", "NZST": "NZST", "HEOG": "HEOG", "ARST": "ARST", "∅∅∅": "∅∅∅", "ChST": "ChST", "PST": "PST", "LHDT": "LHDT", "AWST": "AWST", "GFT": "GFT", "ACDT": "ACDT", "ACWDT": "ACWDT", "HEEG": "HEEG", "HNNOMX": "HNNOMX", "TMST": "TMST", "BOT": "BOT", "ACWST": "ACWST", "GYT": "GYT", "HKT": "HKT", "HKST": "HKST", "LHST": "LHST"}, 61 } 62} 63 64// Locale returns the current translators string locale 65func (vo *vo_001) Locale() string { 66 return vo.locale 67} 68 69// PluralsCardinal returns the list of cardinal plural rules associated with 'vo_001' 70func (vo *vo_001) PluralsCardinal() []locales.PluralRule { 71 return vo.pluralsCardinal 72} 73 74// PluralsOrdinal returns the list of ordinal plural rules associated with 'vo_001' 75func (vo *vo_001) PluralsOrdinal() []locales.PluralRule { 76 return vo.pluralsOrdinal 77} 78 79// PluralsRange returns the list of range plural rules associated with 'vo_001' 80func (vo *vo_001) PluralsRange() []locales.PluralRule { 81 return vo.pluralsRange 82} 83 84// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vo_001' 85func (vo *vo_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { 86 87 n := math.Abs(num) 88 89 if n == 1 { 90 return locales.PluralRuleOne 91 } 92 93 return locales.PluralRuleOther 94} 95 96// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vo_001' 97func (vo *vo_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 98 return locales.PluralRuleUnknown 99} 100 101// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vo_001' 102func (vo *vo_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 103 return locales.PluralRuleUnknown 104} 105 106// MonthAbbreviated returns the locales abbreviated month given the 'month' provided 107func (vo *vo_001) MonthAbbreviated(month time.Month) string { 108 return vo.monthsAbbreviated[month] 109} 110 111// MonthsAbbreviated returns the locales abbreviated months 112func (vo *vo_001) MonthsAbbreviated() []string { 113 return vo.monthsAbbreviated[1:] 114} 115 116// MonthNarrow returns the locales narrow month given the 'month' provided 117func (vo *vo_001) MonthNarrow(month time.Month) string { 118 return vo.monthsNarrow[month] 119} 120 121// MonthsNarrow returns the locales narrow months 122func (vo *vo_001) MonthsNarrow() []string { 123 return vo.monthsNarrow[1:] 124} 125 126// MonthWide returns the locales wide month given the 'month' provided 127func (vo *vo_001) MonthWide(month time.Month) string { 128 return vo.monthsWide[month] 129} 130 131// MonthsWide returns the locales wide months 132func (vo *vo_001) MonthsWide() []string { 133 return vo.monthsWide[1:] 134} 135 136// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided 137func (vo *vo_001) WeekdayAbbreviated(weekday time.Weekday) string { 138 return vo.daysAbbreviated[weekday] 139} 140 141// WeekdaysAbbreviated returns the locales abbreviated weekdays 142func (vo *vo_001) WeekdaysAbbreviated() []string { 143 return vo.daysAbbreviated 144} 145 146// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided 147func (vo *vo_001) WeekdayNarrow(weekday time.Weekday) string { 148 return vo.daysNarrow[weekday] 149} 150 151// WeekdaysNarrow returns the locales narrow weekdays 152func (vo *vo_001) WeekdaysNarrow() []string { 153 return vo.daysNarrow 154} 155 156// WeekdayShort returns the locales short weekday given the 'weekday' provided 157func (vo *vo_001) WeekdayShort(weekday time.Weekday) string { 158 return vo.daysShort[weekday] 159} 160 161// WeekdaysShort returns the locales short weekdays 162func (vo *vo_001) WeekdaysShort() []string { 163 return vo.daysShort 164} 165 166// WeekdayWide returns the locales wide weekday given the 'weekday' provided 167func (vo *vo_001) WeekdayWide(weekday time.Weekday) string { 168 return vo.daysWide[weekday] 169} 170 171// WeekdaysWide returns the locales wide weekdays 172func (vo *vo_001) WeekdaysWide() []string { 173 return vo.daysWide 174} 175 176// Decimal returns the decimal point of number 177func (vo *vo_001) Decimal() string { 178 return vo.decimal 179} 180 181// Group returns the group of number 182func (vo *vo_001) Group() string { 183 return vo.group 184} 185 186// Group returns the minus sign of number 187func (vo *vo_001) Minus() string { 188 return vo.minus 189} 190 191// FmtNumber returns 'num' with digits/precision of 'v' for 'vo_001' and handles both Whole and Real numbers based on 'v' 192func (vo *vo_001) FmtNumber(num float64, v uint64) string { 193 194 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 195} 196 197// FmtPercent returns 'num' with digits/precision of 'v' for 'vo_001' and handles both Whole and Real numbers based on 'v' 198// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 199func (vo *vo_001) FmtPercent(num float64, v uint64) string { 200 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 201} 202 203// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vo_001' 204func (vo *vo_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { 205 206 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 207 symbol := vo.currencies[currency] 208 return string(append(append([]byte{}, symbol...), s...)) 209} 210 211// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vo_001' 212// in accounting notation. 213func (vo *vo_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { 214 215 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 216 symbol := vo.currencies[currency] 217 return string(append(append([]byte{}, symbol...), s...)) 218} 219 220// FmtDateShort returns the short date representation of 't' for 'vo_001' 221func (vo *vo_001) FmtDateShort(t time.Time) string { 222 223 b := make([]byte, 0, 32) 224 225 if t.Year() > 0 { 226 b = strconv.AppendInt(b, int64(t.Year()), 10) 227 } else { 228 b = strconv.AppendInt(b, int64(-t.Year()), 10) 229 } 230 231 b = append(b, []byte{0x2d}...) 232 233 if t.Month() < 10 { 234 b = append(b, '0') 235 } 236 237 b = strconv.AppendInt(b, int64(t.Month()), 10) 238 239 b = append(b, []byte{0x2d}...) 240 241 if t.Day() < 10 { 242 b = append(b, '0') 243 } 244 245 b = strconv.AppendInt(b, int64(t.Day()), 10) 246 247 return string(b) 248} 249 250// FmtDateMedium returns the medium date representation of 't' for 'vo_001' 251func (vo *vo_001) FmtDateMedium(t time.Time) string { 252 253 b := make([]byte, 0, 32) 254 255 if t.Year() > 0 { 256 b = strconv.AppendInt(b, int64(t.Year()), 10) 257 } else { 258 b = strconv.AppendInt(b, int64(-t.Year()), 10) 259 } 260 261 b = append(b, []byte{0x20}...) 262 b = append(b, vo.monthsAbbreviated[t.Month()]...) 263 b = append(b, []byte{0x2e, 0x20}...) 264 b = strconv.AppendInt(b, int64(t.Day()), 10) 265 266 return string(b) 267} 268 269// FmtDateLong returns the long date representation of 't' for 'vo_001' 270func (vo *vo_001) FmtDateLong(t time.Time) string { 271 272 b := make([]byte, 0, 32) 273 274 if t.Year() > 0 { 275 b = strconv.AppendInt(b, int64(t.Year()), 10) 276 } else { 277 b = strconv.AppendInt(b, int64(-t.Year()), 10) 278 } 279 280 b = append(b, []byte{0x20}...) 281 b = append(b, vo.monthsWide[t.Month()]...) 282 b = append(b, []byte{0x20}...) 283 b = strconv.AppendInt(b, int64(t.Day()), 10) 284 285 return string(b) 286} 287 288// FmtDateFull returns the full date representation of 't' for 'vo_001' 289func (vo *vo_001) FmtDateFull(t time.Time) string { 290 291 b := make([]byte, 0, 32) 292 293 if t.Year() > 0 { 294 b = strconv.AppendInt(b, int64(t.Year()), 10) 295 } else { 296 b = strconv.AppendInt(b, int64(-t.Year()), 10) 297 } 298 299 b = append(b, []byte{0x20}...) 300 b = append(b, vo.monthsWide[t.Month()]...) 301 b = append(b, []byte{0x61}...) 302 b = append(b, []byte{0x20, 0x64}...) 303 b = append(b, []byte{0x2e, 0x20}...) 304 b = strconv.AppendInt(b, int64(t.Day()), 10) 305 b = append(b, []byte{0x69, 0x64}...) 306 307 return string(b) 308} 309 310// FmtTimeShort returns the short time representation of 't' for 'vo_001' 311func (vo *vo_001) FmtTimeShort(t time.Time) string { 312 313 b := make([]byte, 0, 32) 314 315 if t.Hour() < 10 { 316 b = append(b, '0') 317 } 318 319 b = strconv.AppendInt(b, int64(t.Hour()), 10) 320 b = append(b, vo.timeSeparator...) 321 322 if t.Minute() < 10 { 323 b = append(b, '0') 324 } 325 326 b = strconv.AppendInt(b, int64(t.Minute()), 10) 327 328 return string(b) 329} 330 331// FmtTimeMedium returns the medium time representation of 't' for 'vo_001' 332func (vo *vo_001) FmtTimeMedium(t time.Time) string { 333 334 b := make([]byte, 0, 32) 335 336 if t.Hour() < 10 { 337 b = append(b, '0') 338 } 339 340 b = strconv.AppendInt(b, int64(t.Hour()), 10) 341 b = append(b, vo.timeSeparator...) 342 343 if t.Minute() < 10 { 344 b = append(b, '0') 345 } 346 347 b = strconv.AppendInt(b, int64(t.Minute()), 10) 348 b = append(b, vo.timeSeparator...) 349 350 if t.Second() < 10 { 351 b = append(b, '0') 352 } 353 354 b = strconv.AppendInt(b, int64(t.Second()), 10) 355 356 return string(b) 357} 358 359// FmtTimeLong returns the long time representation of 't' for 'vo_001' 360func (vo *vo_001) FmtTimeLong(t time.Time) string { 361 362 b := make([]byte, 0, 32) 363 364 if t.Hour() < 10 { 365 b = append(b, '0') 366 } 367 368 b = strconv.AppendInt(b, int64(t.Hour()), 10) 369 b = append(b, vo.timeSeparator...) 370 371 if t.Minute() < 10 { 372 b = append(b, '0') 373 } 374 375 b = strconv.AppendInt(b, int64(t.Minute()), 10) 376 b = append(b, vo.timeSeparator...) 377 378 if t.Second() < 10 { 379 b = append(b, '0') 380 } 381 382 b = strconv.AppendInt(b, int64(t.Second()), 10) 383 b = append(b, []byte{0x20}...) 384 385 tz, _ := t.Zone() 386 b = append(b, tz...) 387 388 return string(b) 389} 390 391// FmtTimeFull returns the full time representation of 't' for 'vo_001' 392func (vo *vo_001) FmtTimeFull(t time.Time) string { 393 394 b := make([]byte, 0, 32) 395 396 if t.Hour() < 10 { 397 b = append(b, '0') 398 } 399 400 b = strconv.AppendInt(b, int64(t.Hour()), 10) 401 b = append(b, vo.timeSeparator...) 402 403 if t.Minute() < 10 { 404 b = append(b, '0') 405 } 406 407 b = strconv.AppendInt(b, int64(t.Minute()), 10) 408 b = append(b, vo.timeSeparator...) 409 410 if t.Second() < 10 { 411 b = append(b, '0') 412 } 413 414 b = strconv.AppendInt(b, int64(t.Second()), 10) 415 b = append(b, []byte{0x20}...) 416 417 tz, _ := t.Zone() 418 419 if btz, ok := vo.timezones[tz]; ok { 420 b = append(b, btz...) 421 } else { 422 b = append(b, tz...) 423 } 424 425 return string(b) 426} 427