8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
25 currencies []string // idx = enum of currency code
26 currencyPositiveSuffix string
27 currencyNegativeSuffix string
28 monthsAbbreviated []string
31 daysAbbreviated []string
35 periodsAbbreviated []string
36 periodsNarrow []string
39 erasAbbreviated []string
42 timezones map[string]string
45 // New returns a new instance of translator for the 'hsb' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 3, 4, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
59 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", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "zł", "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", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
61 currencyPositiveSuffix: " ",
62 currencyNegativeSuffix: " ",
63 monthsAbbreviated: []string{"", "jan.", "feb.", "měr.", "apr.", "mej.", "jun.", "jul.", "awg.", "sep.", "okt.", "now.", "dec."},
64 monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"},
65 monthsWide: []string{"", "januara", "februara", "měrca", "apryla", "meje", "junija", "julija", "awgusta", "septembra", "oktobra", "nowembra", "decembra"},
66 daysAbbreviated: []string{"nje", "pón", "wut", "srj", "štw", "pja", "sob"},
67 daysNarrow: []string{"n", "p", "w", "s", "š", "p", "s"},
68 daysShort: []string{"nj", "pó", "wu", "sr", "št", "pj", "so"},
69 daysWide: []string{"njedźela", "póndźela", "wutora", "srjeda", "štwórtk", "pjatk", "sobota"},
70 periodsAbbreviated: []string{"dopołdnja", "popołdnju"},
71 periodsNarrow: []string{"dop.", "pop."},
72 periodsWide: []string{"dopołdnja", "popołdnju"},
73 erasAbbreviated: []string{"př.Chr.n.", "po Chr.n."},
74 erasNarrow: []string{"", ""},
75 erasWide: []string{"před Chrystowym narodźenjom", "po Chrystowym narodźenju"},
76 timezones: map[string]string{"WART": "zapadoargentinski standardny čas", "WARST": "zapadoargentinski lětni čas", "WESZ": "zapadoeuropski lětni čas", "HNPM": "standardny čas kupow St. Pierre a Miquelon", "CDT": "sewjeroameriski centralny lětni čas", "ACWST": "srjedźozapadny awstralski standardny čas", "MDT": "MDT", "WITA": "srjedźoindoneski čas", "OEZ": "wuchodoeuropski standardny čas", "IST": "indiski čas", "CLST": "chilski lětni čas", "ACST": "srjedźoawstralski standardny čas", "HNCU": "kubaski standardny čas", "HADT": "hawaiisko-aleutski lětni čas", "MST": "MST", "HNNOMX": "mexiski sewjerozapadny standardny čas", "LHST": "standardny čas kupy Lord-Howe", "EAT": "wuchodoafriski čas", "HNT": "nowofundlandski standardny čas", "HKST": "Hongkongski lětni čas", "ChST": "chamorroski čas", "CLT": "chilski standardny čas", "NZDT": "nowoseelandski lětni čas", "AST": "atlantiski standardny čas", "HNEG": "wuchodogrönlandski standardny čas", "EST": "sewjeroameriski wuchodny standardny čas", "EDT": "sewjeroameriski wuchodny lětni čas", "HECU": "kubaski lětni čas", "NZST": "nowoseelandski standardny čas", "OESZ": "wuchodoeuropski lětni čas", "GYT": "guyanski čas", "SGT": "Singapurski čas", "CAT": "centralnoafriski čas", "CHADT": "chathamski lětni čas", "HEPMX": "mexiski pacifiski lětni čas", "UYST": "uruguayski lětni čas", "JST": "japanski standardny čas", "LHDT": "lětni čas kupy Lord-Howe", "COT": "kolumbiski standardny čas", "HKT": "Hongkongski standardny čas", "∅∅∅": "Amaconaski lětni čas", "WEZ": "zapadoeuropski standardny čas", "ART": "argentinski standardny čas", "PST": "sewjeroameriski pacifiski standardny čas", "PDT": "sewjeroameriski pacifiski lětni čas", "AWDT": "zapadoawstralski lětni čas", "MEZ": "srjedźoeuropski standardny čas", "WIB": "zapadoindoneski čas", "BOT": "boliwiski čas", "AWST": "zapadoawstralski standardny čas", "HAST": "hawaiisko-aleutski standardny čas", "BT": "bhutanski čas", "VET": "venezuelski čas", "HNOG": "zapadogrönlandski standardny čas", "ARST": "argentinski lětni čas", "HEOG": "zapadogrönlandski lětni čas", "HEEG": "wuchodogrönlandski lětni čas", "AKST": "alaskaski standardny čas", "CST": "sewjeroameriski centralny standardny čas", "UYT": "uruguayski standardny čas", "AEDT": "wuchodoawstralski lětni čas", "WAST": "zapadoafriski lětni čas", "HEPM": "lětni čas kupow St. Pierre a Miquelon", "ACWDT": "sjedźozapadny awstralski lětni čas", "ADT": "atlantiski lětni čas", "ACDT": "srjedźoawstralski lětni čas", "CHAST": "chathamski standardny čas", "SRT": "surinamski čas", "MYT": "malajziski čas", "SAST": "južnoafriski čas", "COST": "kolumbiski lětni čas", "GFT": "francoskoguyanski čas", "ECT": "ekwadorski čas", "MESZ": "srjedźoeuropski lětni čas", "WAT": "zapadoafriski standardny čas", "AKDT": "alaskaski lětni čas", "HNPMX": "mexiski pacifiski standardny čas", "WIT": "wuchodoindoneski", "HENOMX": "mexiski sewjerozapadny lětni čas", "JDT": "japanski lětni čas", "AEST": "wuchodoawstralski standardny čas", "HAT": "nowofundlandski lětni čas", "GMT": "Greenwichski čas", "TMT": "turkmenski standardny čas", "TMST": "turkmenski lětni čas"},
80 // Locale returns the current translators string locale
81 func (hsb *hsb) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'hsb'
86 func (hsb *hsb) PluralsCardinal() []locales.PluralRule {
87 return hsb.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'hsb'
91 func (hsb *hsb) PluralsOrdinal() []locales.PluralRule {
92 return hsb.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'hsb'
96 func (hsb *hsb) PluralsRange() []locales.PluralRule {
97 return hsb.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hsb'
101 func (hsb *hsb) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
109 if (v == 0 && iMod100 == 1) || (fMod100 == 1) {
110 return locales.PluralRuleOne
111 } else if (v == 0 && iMod100 == 2) || (fMod100 == 2) {
112 return locales.PluralRuleTwo
113 } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (fMod100 >= 3 && fMod100 <= 4) {
114 return locales.PluralRuleFew
117 return locales.PluralRuleOther
120 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hsb'
121 func (hsb *hsb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
122 return locales.PluralRuleOther
125 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hsb'
126 func (hsb *hsb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
127 return locales.PluralRuleUnknown
130 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
131 func (hsb *hsb) MonthAbbreviated(month time.Month) string {
132 return hsb.monthsAbbreviated[month]
135 // MonthsAbbreviated returns the locales abbreviated months
136 func (hsb *hsb) MonthsAbbreviated() []string {
137 return hsb.monthsAbbreviated[1:]
140 // MonthNarrow returns the locales narrow month given the 'month' provided
141 func (hsb *hsb) MonthNarrow(month time.Month) string {
142 return hsb.monthsNarrow[month]
145 // MonthsNarrow returns the locales narrow months
146 func (hsb *hsb) MonthsNarrow() []string {
147 return hsb.monthsNarrow[1:]
150 // MonthWide returns the locales wide month given the 'month' provided
151 func (hsb *hsb) MonthWide(month time.Month) string {
152 return hsb.monthsWide[month]
155 // MonthsWide returns the locales wide months
156 func (hsb *hsb) MonthsWide() []string {
157 return hsb.monthsWide[1:]
160 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
161 func (hsb *hsb) WeekdayAbbreviated(weekday time.Weekday) string {
162 return hsb.daysAbbreviated[weekday]
165 // WeekdaysAbbreviated returns the locales abbreviated weekdays
166 func (hsb *hsb) WeekdaysAbbreviated() []string {
167 return hsb.daysAbbreviated
170 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
171 func (hsb *hsb) WeekdayNarrow(weekday time.Weekday) string {
172 return hsb.daysNarrow[weekday]
175 // WeekdaysNarrow returns the locales narrow weekdays
176 func (hsb *hsb) WeekdaysNarrow() []string {
177 return hsb.daysNarrow
180 // WeekdayShort returns the locales short weekday given the 'weekday' provided
181 func (hsb *hsb) WeekdayShort(weekday time.Weekday) string {
182 return hsb.daysShort[weekday]
185 // WeekdaysShort returns the locales short weekdays
186 func (hsb *hsb) WeekdaysShort() []string {
190 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
191 func (hsb *hsb) WeekdayWide(weekday time.Weekday) string {
192 return hsb.daysWide[weekday]
195 // WeekdaysWide returns the locales wide weekdays
196 func (hsb *hsb) WeekdaysWide() []string {
200 // Decimal returns the decimal point of number
201 func (hsb *hsb) Decimal() string {
205 // Group returns the group of number
206 func (hsb *hsb) Group() string {
210 // Group returns the minus sign of number
211 func (hsb *hsb) Minus() string {
215 // FmtNumber returns 'num' with digits/precision of 'v' for 'hsb' and handles both Whole and Real numbers based on 'v'
216 func (hsb *hsb) FmtNumber(num float64, v uint64) string {
218 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
219 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
222 b := make([]byte, 0, l)
224 for i := len(s) - 1; i >= 0; i-- {
227 b = append(b, hsb.decimal[0])
234 b = append(b, hsb.group[0])
245 b = append(b, hsb.minus[0])
249 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
250 b[i], b[j] = b[j], b[i]
256 // FmtPercent returns 'num' with digits/precision of 'v' for 'hsb' and handles both Whole and Real numbers based on 'v'
257 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
258 func (hsb *hsb) FmtPercent(num float64, v uint64) string {
259 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
261 b := make([]byte, 0, l)
263 for i := len(s) - 1; i >= 0; i-- {
266 b = append(b, hsb.decimal[0])
274 b = append(b, hsb.minus[0])
278 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
279 b[i], b[j] = b[j], b[i]
282 b = append(b, hsb.percentSuffix...)
284 b = append(b, hsb.percent...)
289 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hsb'
290 func (hsb *hsb) FmtCurrency(num float64, v uint64, currency currency.Type) string {
292 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
293 symbol := hsb.currencies[currency]
294 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
297 b := make([]byte, 0, l)
299 for i := len(s) - 1; i >= 0; i-- {
302 b = append(b, hsb.decimal[0])
309 b = append(b, hsb.group[0])
320 b = append(b, hsb.minus[0])
324 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
325 b[i], b[j] = b[j], b[i]
331 b = append(b, hsb.decimal...)
334 for i := 0; i < 2-int(v); i++ {
339 b = append(b, hsb.currencyPositiveSuffix...)
341 b = append(b, symbol...)
346 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hsb'
347 // in accounting notation.
348 func (hsb *hsb) FmtAccounting(num float64, v uint64, currency currency.Type) string {
350 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
351 symbol := hsb.currencies[currency]
352 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
355 b := make([]byte, 0, l)
357 for i := len(s) - 1; i >= 0; i-- {
360 b = append(b, hsb.decimal[0])
367 b = append(b, hsb.group[0])
379 b = append(b, hsb.minus[0])
384 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
385 b[i], b[j] = b[j], b[i]
391 b = append(b, hsb.decimal...)
394 for i := 0; i < 2-int(v); i++ {
400 b = append(b, hsb.currencyNegativeSuffix...)
401 b = append(b, symbol...)
404 b = append(b, hsb.currencyPositiveSuffix...)
405 b = append(b, symbol...)
411 // FmtDateShort returns the short date representation of 't' for 'hsb'
412 func (hsb *hsb) FmtDateShort(t time.Time) string {
414 b := make([]byte, 0, 32)
416 b = strconv.AppendInt(b, int64(t.Day()), 10)
417 b = append(b, []byte{0x2e}...)
418 b = strconv.AppendInt(b, int64(t.Month()), 10)
419 b = append(b, []byte{0x2e}...)
422 b = append(b, strconv.Itoa(t.Year())[2:]...)
424 b = append(b, strconv.Itoa(t.Year())[1:]...)
430 // FmtDateMedium returns the medium date representation of 't' for 'hsb'
431 func (hsb *hsb) FmtDateMedium(t time.Time) string {
433 b := make([]byte, 0, 32)
435 b = strconv.AppendInt(b, int64(t.Day()), 10)
436 b = append(b, []byte{0x2e}...)
437 b = strconv.AppendInt(b, int64(t.Month()), 10)
438 b = append(b, []byte{0x2e}...)
441 b = strconv.AppendInt(b, int64(t.Year()), 10)
443 b = strconv.AppendInt(b, int64(-t.Year()), 10)
449 // FmtDateLong returns the long date representation of 't' for 'hsb'
450 func (hsb *hsb) FmtDateLong(t time.Time) string {
452 b := make([]byte, 0, 32)
454 b = strconv.AppendInt(b, int64(t.Day()), 10)
455 b = append(b, []byte{0x2e, 0x20}...)
456 b = append(b, hsb.monthsWide[t.Month()]...)
457 b = append(b, []byte{0x20}...)
460 b = strconv.AppendInt(b, int64(t.Year()), 10)
462 b = strconv.AppendInt(b, int64(-t.Year()), 10)
468 // FmtDateFull returns the full date representation of 't' for 'hsb'
469 func (hsb *hsb) FmtDateFull(t time.Time) string {
471 b := make([]byte, 0, 32)
473 b = append(b, hsb.daysWide[t.Weekday()]...)
474 b = append(b, []byte{0x2c, 0x20}...)
475 b = strconv.AppendInt(b, int64(t.Day()), 10)
476 b = append(b, []byte{0x2e, 0x20}...)
477 b = append(b, hsb.monthsWide[t.Month()]...)
478 b = append(b, []byte{0x20}...)
481 b = strconv.AppendInt(b, int64(t.Year()), 10)
483 b = strconv.AppendInt(b, int64(-t.Year()), 10)
489 // FmtTimeShort returns the short time representation of 't' for 'hsb'
490 func (hsb *hsb) FmtTimeShort(t time.Time) string {
492 b := make([]byte, 0, 32)
494 b = strconv.AppendInt(b, int64(t.Hour()), 10)
495 b = append(b, hsb.timeSeparator...)
501 b = strconv.AppendInt(b, int64(t.Minute()), 10)
502 b = append(b, []byte{0x20, 0x68, 0x6f, 0x64, 0xc5, 0xba}...)
503 b = append(b, []byte{0x2e}...)
508 // FmtTimeMedium returns the medium time representation of 't' for 'hsb'
509 func (hsb *hsb) FmtTimeMedium(t time.Time) string {
511 b := make([]byte, 0, 32)
513 b = strconv.AppendInt(b, int64(t.Hour()), 10)
514 b = append(b, hsb.timeSeparator...)
520 b = strconv.AppendInt(b, int64(t.Minute()), 10)
521 b = append(b, hsb.timeSeparator...)
527 b = strconv.AppendInt(b, int64(t.Second()), 10)
532 // FmtTimeLong returns the long time representation of 't' for 'hsb'
533 func (hsb *hsb) FmtTimeLong(t time.Time) string {
535 b := make([]byte, 0, 32)
537 b = strconv.AppendInt(b, int64(t.Hour()), 10)
538 b = append(b, hsb.timeSeparator...)
544 b = strconv.AppendInt(b, int64(t.Minute()), 10)
545 b = append(b, hsb.timeSeparator...)
551 b = strconv.AppendInt(b, int64(t.Second()), 10)
552 b = append(b, []byte{0x20}...)
560 // FmtTimeFull returns the full time representation of 't' for 'hsb'
561 func (hsb *hsb) FmtTimeFull(t time.Time) string {
563 b := make([]byte, 0, 32)
565 b = strconv.AppendInt(b, int64(t.Hour()), 10)
566 b = append(b, hsb.timeSeparator...)
572 b = strconv.AppendInt(b, int64(t.Minute()), 10)
573 b = append(b, hsb.timeSeparator...)
579 b = strconv.AppendInt(b, int64(t.Second()), 10)
580 b = append(b, []byte{0x20}...)
584 if btz, ok := hsb.timezones[tz]; ok {
585 b = append(b, btz...)