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
24 currencies []string // idx = enum of currency code
25 currencyPositiveSuffix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
30 daysAbbreviated []string
34 periodsAbbreviated []string
35 periodsNarrow []string
38 erasAbbreviated []string
41 timezones map[string]string
44 // New returns a new instance of translator for the 'hr_HR' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 4, 6},
49 pluralsOrdinal: []locales.PluralRule{6},
50 pluralsRange: []locales.PluralRule{2, 4, 6},
58 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", "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", "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"},
59 currencyPositiveSuffix: " ",
60 currencyNegativeSuffix: " ",
61 monthsAbbreviated: []string{"", "sij", "velj", "ožu", "tra", "svi", "lip", "srp", "kol", "ruj", "lis", "stu", "pro"},
62 monthsNarrow: []string{"", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12."},
63 monthsWide: []string{"", "siječnja", "veljače", "ožujka", "travnja", "svibnja", "lipnja", "srpnja", "kolovoza", "rujna", "listopada", "studenoga", "prosinca"},
64 daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"},
65 daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"},
66 daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"},
67 daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"},
68 periodsAbbreviated: []string{"AM", "PM"},
69 periodsNarrow: []string{"AM", "PM"},
70 periodsWide: []string{"AM", "PM"},
71 erasAbbreviated: []string{"pr. Kr.", "po. Kr."},
72 erasNarrow: []string{"pr.n.e.", "AD"},
73 erasWide: []string{"prije Krista", "poslije Krista"},
74 timezones: map[string]string{"VET": "venezuelsko vrijeme", "ACDT": "srednjoaustralsko ljetno vrijeme", "WESZ": "zapadnoeuropsko ljetno vrijeme", "GMT": "univerzalno vrijeme", "MDT": "ljetno makaosko vrijeme", "TMST": "turkmenistansko ljetno vrijeme", "WART": "zapadno-argentinsko standardno vrijeme", "ChST": "standardno vrijeme Chamorra", "ADT": "atlantsko ljetno vrijeme", "EAT": "istočnoafričko vrijeme", "HEPMX": "meksičko pacifičko ljetno vrijeme", "UYST": "urugvajsko ljetno vrijeme", "MEZ": "srednjoeuropsko standardno vrijeme", "HAST": "havajsko-aleutsko standardno vrijeme", "NZST": "novozelandsko standardno vrijeme", "AEST": "istočnoaustralsko standardno vrijeme", "WAT": "zapadnoafričko standardno vrijeme", "COT": "kolumbijsko standardno vrijeme", "CLST": "čileansko ljetno vrijeme", "MESZ": "srednjoeuropsko ljetno vrijeme", "LHDT": "ljetno vrijeme otoka Lord Howe", "AEDT": "istočnoaustralsko ljetno vrijeme", "ARST": "argentinsko ljetno vrijeme", "EDT": "istočno ljetno vrijeme", "HECU": "kubansko ljetno vrijeme", "ACWDT": "australsko središnje zapadno ljetno vrijeme", "MYT": "malezijsko vrijeme", "OESZ": "istočnoeuropsko ljetno vrijeme", "HNEG": "istočnogrenlandsko standardno vrijeme", "HENOMX": "sjeverozapadno meksičko ljetno vrijeme", "GFT": "vrijeme Francuske Gvajane", "∅∅∅": "amazonsko ljetno vrijeme", "HEPM": "ljetno vrijeme za Sveti Petar i Mikelon", "PDT": "pacifičko ljetno vrijeme", "CST": "središnje standardno vrijeme", "WARST": "zapadno-argentinsko ljetno vrijeme", "JST": "japansko standardno vrijeme", "WAST": "zapadnoafričko ljetno vrijeme", "HNT": "newfoundlandsko standardno vrijeme", "CAT": "srednjoafričko vrijeme", "WIB": "zapadnoindonezijsko vrijeme", "AWDT": "zapadnoaustralsko ljetno vrijeme", "TMT": "turkmenistansko standardno vrijeme", "WITA": "srednjoindonezijsko vrijeme", "HKST": "hongkonško ljetno vrijeme", "AKST": "aljaško standardno vrijeme", "CHADT": "ljetno vrijeme Chathama", "COST": "kolumbijsko ljetno vrijeme", "SGT": "singapursko vrijeme", "CHAST": "standardno vrijeme Chathama", "MST": "standardno makaosko vrijeme", "ACWST": "australsko središnje zapadno standardno vrijeme", "SAST": "južnoafričko vrijeme", "HKT": "hongkonško standardno vrijeme", "HEEG": "istočnogrenlandsko ljetno vrijeme", "ACST": "srednjoaustralsko standardno vrijeme", "AWST": "zapadnoaustralsko standardno vrijeme", "OEZ": "istočnoeuropsko standardno vrijeme", "LHST": "standardno vrijeme otoka Lord Howe", "AST": "atlantsko standardno vrijeme", "ART": "argentinsko standardno vrijeme", "BOT": "bolivijsko vrijeme", "JDT": "japansko ljetno vrijeme", "HAT": "newfoundlandsko ljetno vrijeme", "AKDT": "aljaško ljetno vrijeme", "CDT": "središnje ljetno vrijeme", "HEOG": "zapadnogrenlandsko ljetno vrijeme", "PST": "pacifičko standardno vrijeme", "HNCU": "kubansko standardno vrijeme", "BT": "butansko vrijeme", "WIT": "istočnoindonezijsko vrijeme", "HADT": "havajsko-aleutsko ljetno vrijeme", "EST": "istočno standardno vrijeme", "GYT": "gvajansko vrijeme", "WEZ": "zapadnoeuropsko standardno vrijeme", "HNPM": "standardno vrijeme za Sveti Petar i Mikelon", "UYT": "urugvajsko standardno vrijeme", "NZDT": "novozelandsko ljetno vrijeme", "HNOG": "zapadnogrenlandsko standardno vrijeme", "CLT": "čileansko standardno vrijeme", "ECT": "ekvadorsko vrijeme", "HNPMX": "meksičko pacifičko standardno vrijeme", "SRT": "surinamsko vrijeme", "HNNOMX": "sjeverozapadno meksičko standardno vrijeme", "IST": "indijsko vrijeme"},
78 // Locale returns the current translators string locale
79 func (hr *hr_HR) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'hr_HR'
84 func (hr *hr_HR) PluralsCardinal() []locales.PluralRule {
85 return hr.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'hr_HR'
89 func (hr *hr_HR) PluralsOrdinal() []locales.PluralRule {
90 return hr.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'hr_HR'
94 func (hr *hr_HR) PluralsRange() []locales.PluralRule {
95 return hr.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hr_HR'
99 func (hr *hr_HR) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
109 if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
110 return locales.PluralRuleOne
111 } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) {
112 return locales.PluralRuleFew
115 return locales.PluralRuleOther
118 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hr_HR'
119 func (hr *hr_HR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
120 return locales.PluralRuleOther
123 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hr_HR'
124 func (hr *hr_HR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
126 start := hr.CardinalPluralRule(num1, v1)
127 end := hr.CardinalPluralRule(num2, v2)
129 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
130 return locales.PluralRuleOne
131 } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
132 return locales.PluralRuleFew
133 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
134 return locales.PluralRuleOther
135 } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
136 return locales.PluralRuleOne
137 } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
138 return locales.PluralRuleFew
139 } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
140 return locales.PluralRuleOther
141 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
142 return locales.PluralRuleOne
143 } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
144 return locales.PluralRuleFew
147 return locales.PluralRuleOther
151 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
152 func (hr *hr_HR) MonthAbbreviated(month time.Month) string {
153 return hr.monthsAbbreviated[month]
156 // MonthsAbbreviated returns the locales abbreviated months
157 func (hr *hr_HR) MonthsAbbreviated() []string {
158 return hr.monthsAbbreviated[1:]
161 // MonthNarrow returns the locales narrow month given the 'month' provided
162 func (hr *hr_HR) MonthNarrow(month time.Month) string {
163 return hr.monthsNarrow[month]
166 // MonthsNarrow returns the locales narrow months
167 func (hr *hr_HR) MonthsNarrow() []string {
168 return hr.monthsNarrow[1:]
171 // MonthWide returns the locales wide month given the 'month' provided
172 func (hr *hr_HR) MonthWide(month time.Month) string {
173 return hr.monthsWide[month]
176 // MonthsWide returns the locales wide months
177 func (hr *hr_HR) MonthsWide() []string {
178 return hr.monthsWide[1:]
181 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
182 func (hr *hr_HR) WeekdayAbbreviated(weekday time.Weekday) string {
183 return hr.daysAbbreviated[weekday]
186 // WeekdaysAbbreviated returns the locales abbreviated weekdays
187 func (hr *hr_HR) WeekdaysAbbreviated() []string {
188 return hr.daysAbbreviated
191 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
192 func (hr *hr_HR) WeekdayNarrow(weekday time.Weekday) string {
193 return hr.daysNarrow[weekday]
196 // WeekdaysNarrow returns the locales narrow weekdays
197 func (hr *hr_HR) WeekdaysNarrow() []string {
201 // WeekdayShort returns the locales short weekday given the 'weekday' provided
202 func (hr *hr_HR) WeekdayShort(weekday time.Weekday) string {
203 return hr.daysShort[weekday]
206 // WeekdaysShort returns the locales short weekdays
207 func (hr *hr_HR) WeekdaysShort() []string {
211 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
212 func (hr *hr_HR) WeekdayWide(weekday time.Weekday) string {
213 return hr.daysWide[weekday]
216 // WeekdaysWide returns the locales wide weekdays
217 func (hr *hr_HR) WeekdaysWide() []string {
221 // Decimal returns the decimal point of number
222 func (hr *hr_HR) Decimal() string {
226 // Group returns the group of number
227 func (hr *hr_HR) Group() string {
231 // Group returns the minus sign of number
232 func (hr *hr_HR) Minus() string {
236 // FmtNumber returns 'num' with digits/precision of 'v' for 'hr_HR' and handles both Whole and Real numbers based on 'v'
237 func (hr *hr_HR) FmtNumber(num float64, v uint64) string {
239 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
240 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
243 b := make([]byte, 0, l)
245 for i := len(s) - 1; i >= 0; i-- {
248 b = append(b, hr.decimal[0])
255 b = append(b, hr.group[0])
266 b = append(b, hr.minus[0])
270 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
271 b[i], b[j] = b[j], b[i]
277 // FmtPercent returns 'num' with digits/precision of 'v' for 'hr_HR' and handles both Whole and Real numbers based on 'v'
278 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
279 func (hr *hr_HR) FmtPercent(num float64, v uint64) string {
280 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
282 b := make([]byte, 0, l)
284 for i := len(s) - 1; i >= 0; i-- {
287 b = append(b, hr.decimal[0])
295 b = append(b, hr.minus[0])
299 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
300 b[i], b[j] = b[j], b[i]
303 b = append(b, hr.percent...)
308 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hr_HR'
309 func (hr *hr_HR) FmtCurrency(num float64, v uint64, currency currency.Type) string {
311 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
312 symbol := hr.currencies[currency]
313 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
316 b := make([]byte, 0, l)
318 for i := len(s) - 1; i >= 0; i-- {
321 b = append(b, hr.decimal[0])
328 b = append(b, hr.group[0])
339 b = append(b, hr.minus[0])
343 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
344 b[i], b[j] = b[j], b[i]
350 b = append(b, hr.decimal...)
353 for i := 0; i < 2-int(v); i++ {
358 b = append(b, hr.currencyPositiveSuffix...)
360 b = append(b, symbol...)
365 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hr_HR'
366 // in accounting notation.
367 func (hr *hr_HR) FmtAccounting(num float64, v uint64, currency currency.Type) string {
369 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
370 symbol := hr.currencies[currency]
371 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
374 b := make([]byte, 0, l)
376 for i := len(s) - 1; i >= 0; i-- {
379 b = append(b, hr.decimal[0])
386 b = append(b, hr.group[0])
398 b = append(b, hr.minus[0])
403 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
404 b[i], b[j] = b[j], b[i]
410 b = append(b, hr.decimal...)
413 for i := 0; i < 2-int(v); i++ {
419 b = append(b, hr.currencyNegativeSuffix...)
420 b = append(b, symbol...)
423 b = append(b, hr.currencyPositiveSuffix...)
424 b = append(b, symbol...)
430 // FmtDateShort returns the short date representation of 't' for 'hr_HR'
431 func (hr *hr_HR) FmtDateShort(t time.Time) string {
433 b := make([]byte, 0, 32)
439 b = strconv.AppendInt(b, int64(t.Day()), 10)
440 b = append(b, []byte{0x2e, 0x20}...)
446 b = strconv.AppendInt(b, int64(t.Month()), 10)
448 b = append(b, []byte{0x2e, 0x20}...)
451 b = strconv.AppendInt(b, int64(t.Year()), 10)
453 b = strconv.AppendInt(b, int64(-t.Year()), 10)
456 b = append(b, []byte{0x2e}...)
461 // FmtDateMedium returns the medium date representation of 't' for 'hr_HR'
462 func (hr *hr_HR) FmtDateMedium(t time.Time) string {
464 b := make([]byte, 0, 32)
466 b = strconv.AppendInt(b, int64(t.Day()), 10)
467 b = append(b, []byte{0x2e, 0x20}...)
468 b = append(b, hr.monthsAbbreviated[t.Month()]...)
469 b = append(b, []byte{0x20}...)
472 b = strconv.AppendInt(b, int64(t.Year()), 10)
474 b = strconv.AppendInt(b, int64(-t.Year()), 10)
477 b = append(b, []byte{0x2e}...)
482 // FmtDateLong returns the long date representation of 't' for 'hr_HR'
483 func (hr *hr_HR) FmtDateLong(t time.Time) string {
485 b := make([]byte, 0, 32)
487 b = strconv.AppendInt(b, int64(t.Day()), 10)
488 b = append(b, []byte{0x2e, 0x20}...)
489 b = append(b, hr.monthsWide[t.Month()]...)
490 b = append(b, []byte{0x20}...)
493 b = strconv.AppendInt(b, int64(t.Year()), 10)
495 b = strconv.AppendInt(b, int64(-t.Year()), 10)
498 b = append(b, []byte{0x2e}...)
503 // FmtDateFull returns the full date representation of 't' for 'hr_HR'
504 func (hr *hr_HR) FmtDateFull(t time.Time) string {
506 b := make([]byte, 0, 32)
508 b = append(b, hr.daysWide[t.Weekday()]...)
509 b = append(b, []byte{0x2c, 0x20}...)
510 b = strconv.AppendInt(b, int64(t.Day()), 10)
511 b = append(b, []byte{0x2e, 0x20}...)
512 b = append(b, hr.monthsWide[t.Month()]...)
513 b = append(b, []byte{0x20}...)
516 b = strconv.AppendInt(b, int64(t.Year()), 10)
518 b = strconv.AppendInt(b, int64(-t.Year()), 10)
521 b = append(b, []byte{0x2e}...)
526 // FmtTimeShort returns the short time representation of 't' for 'hr_HR'
527 func (hr *hr_HR) FmtTimeShort(t time.Time) string {
529 b := make([]byte, 0, 32)
535 b = strconv.AppendInt(b, int64(t.Hour()), 10)
536 b = append(b, hr.timeSeparator...)
542 b = strconv.AppendInt(b, int64(t.Minute()), 10)
547 // FmtTimeMedium returns the medium time representation of 't' for 'hr_HR'
548 func (hr *hr_HR) FmtTimeMedium(t time.Time) string {
550 b := make([]byte, 0, 32)
556 b = strconv.AppendInt(b, int64(t.Hour()), 10)
557 b = append(b, hr.timeSeparator...)
563 b = strconv.AppendInt(b, int64(t.Minute()), 10)
564 b = append(b, hr.timeSeparator...)
570 b = strconv.AppendInt(b, int64(t.Second()), 10)
575 // FmtTimeLong returns the long time representation of 't' for 'hr_HR'
576 func (hr *hr_HR) FmtTimeLong(t time.Time) string {
578 b := make([]byte, 0, 32)
584 b = strconv.AppendInt(b, int64(t.Hour()), 10)
585 b = append(b, hr.timeSeparator...)
591 b = strconv.AppendInt(b, int64(t.Minute()), 10)
592 b = append(b, hr.timeSeparator...)
598 b = strconv.AppendInt(b, int64(t.Second()), 10)
599 b = append(b, []byte{0x20}...)
607 // FmtTimeFull returns the full time representation of 't' for 'hr_HR'
608 func (hr *hr_HR) FmtTimeFull(t time.Time) string {
610 b := make([]byte, 0, 32)
616 b = strconv.AppendInt(b, int64(t.Hour()), 10)
617 b = append(b, hr.timeSeparator...)
623 b = strconv.AppendInt(b, int64(t.Minute()), 10)
624 b = append(b, hr.timeSeparator...)
630 b = strconv.AppendInt(b, int64(t.Second()), 10)
631 b = append(b, []byte{0x20, 0x28}...)
635 if btz, ok := hr.timezones[tz]; ok {
636 b = append(b, btz...)
641 b = append(b, []byte{0x29}...)