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 currencyNegativePrefix 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 'sr_Latn' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 4, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
51 pluralsRange: []locales.PluralRule{2, 4, 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", "KM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "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", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "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", "MX$", "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", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "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"},
60 currencyPositiveSuffix: " ",
61 currencyNegativePrefix: "(",
62 currencyNegativeSuffix: " )",
63 monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"},
64 monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"},
65 monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "jun", "jul", "avgust", "septembar", "oktobar", "novembar", "decembar"},
66 daysAbbreviated: []string{"ned", "pon", "uto", "sre", "čet", "pet", "sub"},
67 daysNarrow: []string{"n", "p", "u", "s", "č", "p", "s"},
68 daysShort: []string{"ne", "po", "ut", "sr", "če", "pe", "su"},
69 daysWide: []string{"nedelja", "ponedeljak", "utorak", "sreda", "četvrtak", "petak", "subota"},
70 periodsAbbreviated: []string{"pre podne", "po podne"},
71 periodsNarrow: []string{"a", "p"},
72 periodsWide: []string{"pre podne", "po podne"},
73 erasAbbreviated: []string{"p. n. e.", "n. e."},
74 erasNarrow: []string{"p.n.e.", "n.e."},
75 erasWide: []string{"pre nove ere", "nove ere"},
76 timezones: map[string]string{"LHST": "Lord Hov standardno vreme", "HNOG": "Zapadni Grenland standardno vreme", "ADT": "Atlantsko letnje računanje vremena", "WAST": "Zapadno-afričko letnje računanje vremena", "SAST": "Južno-afričko vreme", "HNCU": "Kuba standardno vreme", "MDT": "Makao letnje računanje vremena", "MYT": "Malezija vreme", "AKST": "Aljaska, standardno vreme", "COT": "Kolumbija standardno vreme", "GFT": "Francuska Gvajana vreme", "HAT": "Njufaundlend letnje računanje vremena", "MST": "Makao standardno vreme", "VET": "Venecuela vreme", "HNNOMX": "Severozapadni Meksiko standardno vreme", "GYT": "Gvajana vreme", "ChST": "Čamoro vreme", "HEPM": "Sen Pjer i Mikelon letnje računanje vremena", "∅∅∅": "Brazilija letnje računanje vremena", "HNT": "Njufaundlend standardno vreme", "BOT": "Bolivija vreme", "HADT": "Havajsko-aleutsko letnje računanje vremena", "OEZ": "Istočnoevropsko standardno vreme", "CLST": "Čile letnje računanje vremena", "CAT": "Centralno-afričko vreme", "HECU": "Kuba letnje računanje vremena", "ART": "Argentina standardno vreme", "EAT": "Istočno-afričko vreme", "JDT": "Japansko letnje računanje vremena", "AEDT": "Australijsko istočno letnje računanje vremena", "WAT": "Zapadno-afričko standardno vreme", "CLT": "Čile standardno vreme", "HKT": "Hong Kong standardno vreme", "SRT": "Surinam vreme", "UYT": "Urugvaj standardno vreme", "ACWDT": "Australijsko centralno zapadno letnje računanje vremena", "HKST": "Hong Kong letnje računanje vremena", "EST": "Severnoameričko istočno standardno vreme", "EDT": "Severnoameričko istočno letnje vreme", "ECT": "Ekvador vreme", "HNPMX": "Meksički Pacifik standardno vreme", "WIB": "Zapadno-indonezijsko vreme", "MEZ": "Srednjeevropsko standardno vreme", "WARST": "Zapadna Argentina letnje računanje vremena", "HENOMX": "Severozapadni Meksiko letnje računanje vremena", "WESZ": "Zapadnoevropsko letnje računanje vremena", "GMT": "Srednje vreme po Griniču", "CST": "Severnoameričko centralno standardno vreme", "NZST": "Novi Zeland standardno vreme", "PST": "Severnoameričko pacifičko standardno vreme", "CDT": "Severnoameričko centralno letnje vreme", "HEPMX": "Meksički Pacifik letnje računanje vremena", "AEST": "Australijsko istočno standardno vreme", "AKDT": "Aljaska, letnje računanje vremena", "TMST": "Turkmenistan letnje računanje vremena", "MESZ": "Srednjeevropsko letnje računanje vremena", "HAST": "Havajsko-aleutsko standardno vreme", "WART": "Zapadna Argentina standardno vreme", "WITA": "Centralno-indonezijsko vreme", "AWDT": "Australijsko zapadno letnje računanje vremena", "UYST": "Urugvaj letnje računanje vremena", "ACWST": "Australijsko centralno zapadno standardno vreme", "JST": "Japansko standardno vreme", "HNEG": "Istočni Grenland standardno vreme", "COST": "Kolumbija letnje računanje vremena", "AST": "Atlantsko standardno vreme", "ACDT": "Australijsko centralno letnje računanje vremena", "HNPM": "Sen Pjer i Mikelon standardno vreme", "BT": "Butan vreme", "IST": "Indijsko standardno vreme", "LHDT": "Lord Hov letnje računanje vremena", "OESZ": "Istočnoevropsko letnje računanje vremena", "PDT": "Severnoameričko pacifičko letnje vreme", "CHAST": "Čatam standardno vreme", "CHADT": "Čatam letnje računanje vremena", "AWST": "Australijsko zapadno standardno vreme", "SGT": "Singapur standardno vreme", "WEZ": "Zapadnoevropsko standardno vreme", "HEEG": "Istočni Grenland letnje računanje vremena", "ACST": "Australijsko centralno standardno vreme", "WIT": "Istočno-indonezijsko vreme", "TMT": "Turkmenistan standardno vreme", "HEOG": "Zapadni Grenland letnje računanje vremena", "NZDT": "Novi Zeland letnje računanje vremena", "ARST": "Argentina letnje računanje vremena"},
80 // Locale returns the current translators string locale
81 func (sr *sr_Latn) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn'
86 func (sr *sr_Latn) PluralsCardinal() []locales.PluralRule {
87 return sr.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn'
91 func (sr *sr_Latn) PluralsOrdinal() []locales.PluralRule {
92 return sr.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'sr_Latn'
96 func (sr *sr_Latn) PluralsRange() []locales.PluralRule {
97 return sr.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn'
101 func (sr *sr_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
111 if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
112 return locales.PluralRuleOne
113 } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) {
114 return locales.PluralRuleFew
117 return locales.PluralRuleOther
120 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn'
121 func (sr *sr_Latn) 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 'sr_Latn'
126 func (sr *sr_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
128 start := sr.CardinalPluralRule(num1, v1)
129 end := sr.CardinalPluralRule(num2, v2)
131 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
132 return locales.PluralRuleOne
133 } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
134 return locales.PluralRuleFew
135 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
136 return locales.PluralRuleOther
137 } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
138 return locales.PluralRuleOne
139 } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
140 return locales.PluralRuleFew
141 } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
142 return locales.PluralRuleOther
143 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
144 return locales.PluralRuleOne
145 } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
146 return locales.PluralRuleFew
149 return locales.PluralRuleOther
153 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
154 func (sr *sr_Latn) MonthAbbreviated(month time.Month) string {
155 return sr.monthsAbbreviated[month]
158 // MonthsAbbreviated returns the locales abbreviated months
159 func (sr *sr_Latn) MonthsAbbreviated() []string {
160 return sr.monthsAbbreviated[1:]
163 // MonthNarrow returns the locales narrow month given the 'month' provided
164 func (sr *sr_Latn) MonthNarrow(month time.Month) string {
165 return sr.monthsNarrow[month]
168 // MonthsNarrow returns the locales narrow months
169 func (sr *sr_Latn) MonthsNarrow() []string {
170 return sr.monthsNarrow[1:]
173 // MonthWide returns the locales wide month given the 'month' provided
174 func (sr *sr_Latn) MonthWide(month time.Month) string {
175 return sr.monthsWide[month]
178 // MonthsWide returns the locales wide months
179 func (sr *sr_Latn) MonthsWide() []string {
180 return sr.monthsWide[1:]
183 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
184 func (sr *sr_Latn) WeekdayAbbreviated(weekday time.Weekday) string {
185 return sr.daysAbbreviated[weekday]
188 // WeekdaysAbbreviated returns the locales abbreviated weekdays
189 func (sr *sr_Latn) WeekdaysAbbreviated() []string {
190 return sr.daysAbbreviated
193 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
194 func (sr *sr_Latn) WeekdayNarrow(weekday time.Weekday) string {
195 return sr.daysNarrow[weekday]
198 // WeekdaysNarrow returns the locales narrow weekdays
199 func (sr *sr_Latn) WeekdaysNarrow() []string {
203 // WeekdayShort returns the locales short weekday given the 'weekday' provided
204 func (sr *sr_Latn) WeekdayShort(weekday time.Weekday) string {
205 return sr.daysShort[weekday]
208 // WeekdaysShort returns the locales short weekdays
209 func (sr *sr_Latn) WeekdaysShort() []string {
213 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
214 func (sr *sr_Latn) WeekdayWide(weekday time.Weekday) string {
215 return sr.daysWide[weekday]
218 // WeekdaysWide returns the locales wide weekdays
219 func (sr *sr_Latn) WeekdaysWide() []string {
223 // Decimal returns the decimal point of number
224 func (sr *sr_Latn) Decimal() string {
228 // Group returns the group of number
229 func (sr *sr_Latn) Group() string {
233 // Group returns the minus sign of number
234 func (sr *sr_Latn) Minus() string {
238 // FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn' and handles both Whole and Real numbers based on 'v'
239 func (sr *sr_Latn) FmtNumber(num float64, v uint64) string {
241 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
242 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
245 b := make([]byte, 0, l)
247 for i := len(s) - 1; i >= 0; i-- {
250 b = append(b, sr.decimal[0])
257 b = append(b, sr.group[0])
268 b = append(b, sr.minus[0])
272 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
273 b[i], b[j] = b[j], b[i]
279 // FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Latn' and handles both Whole and Real numbers based on 'v'
280 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
281 func (sr *sr_Latn) FmtPercent(num float64, v uint64) string {
282 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
284 b := make([]byte, 0, l)
286 for i := len(s) - 1; i >= 0; i-- {
289 b = append(b, sr.decimal[0])
297 b = append(b, sr.minus[0])
301 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
302 b[i], b[j] = b[j], b[i]
305 b = append(b, sr.percent...)
310 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn'
311 func (sr *sr_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string {
313 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
314 symbol := sr.currencies[currency]
315 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
318 b := make([]byte, 0, l)
320 for i := len(s) - 1; i >= 0; i-- {
323 b = append(b, sr.decimal[0])
330 b = append(b, sr.group[0])
341 b = append(b, sr.minus[0])
345 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
346 b[i], b[j] = b[j], b[i]
352 b = append(b, sr.decimal...)
355 for i := 0; i < 2-int(v); i++ {
360 b = append(b, sr.currencyPositiveSuffix...)
362 b = append(b, symbol...)
367 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn'
368 // in accounting notation.
369 func (sr *sr_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string {
371 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
372 symbol := sr.currencies[currency]
373 l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3
376 b := make([]byte, 0, l)
378 for i := len(s) - 1; i >= 0; i-- {
381 b = append(b, sr.decimal[0])
388 b = append(b, sr.group[0])
400 b = append(b, sr.currencyNegativePrefix[0])
405 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
406 b[i], b[j] = b[j], b[i]
412 b = append(b, sr.decimal...)
415 for i := 0; i < 2-int(v); i++ {
421 b = append(b, sr.currencyNegativeSuffix...)
422 b = append(b, symbol...)
425 b = append(b, sr.currencyPositiveSuffix...)
426 b = append(b, symbol...)
432 // FmtDateShort returns the short date representation of 't' for 'sr_Latn'
433 func (sr *sr_Latn) FmtDateShort(t time.Time) string {
435 b := make([]byte, 0, 32)
437 b = strconv.AppendInt(b, int64(t.Day()), 10)
438 b = append(b, []byte{0x2e}...)
439 b = strconv.AppendInt(b, int64(t.Month()), 10)
440 b = append(b, []byte{0x2e}...)
443 b = append(b, strconv.Itoa(t.Year())[2:]...)
445 b = append(b, strconv.Itoa(t.Year())[1:]...)
448 b = append(b, []byte{0x2e}...)
453 // FmtDateMedium returns the medium date representation of 't' for 'sr_Latn'
454 func (sr *sr_Latn) FmtDateMedium(t time.Time) string {
456 b := make([]byte, 0, 32)
462 b = strconv.AppendInt(b, int64(t.Day()), 10)
463 b = append(b, []byte{0x2e}...)
469 b = strconv.AppendInt(b, int64(t.Month()), 10)
471 b = append(b, []byte{0x2e}...)
474 b = strconv.AppendInt(b, int64(t.Year()), 10)
476 b = strconv.AppendInt(b, int64(-t.Year()), 10)
479 b = append(b, []byte{0x2e}...)
484 // FmtDateLong returns the long date representation of 't' for 'sr_Latn'
485 func (sr *sr_Latn) FmtDateLong(t time.Time) string {
487 b := make([]byte, 0, 32)
493 b = strconv.AppendInt(b, int64(t.Day()), 10)
494 b = append(b, []byte{0x2e, 0x20}...)
495 b = append(b, sr.monthsWide[t.Month()]...)
496 b = append(b, []byte{0x20}...)
499 b = strconv.AppendInt(b, int64(t.Year()), 10)
501 b = strconv.AppendInt(b, int64(-t.Year()), 10)
504 b = append(b, []byte{0x2e}...)
509 // FmtDateFull returns the full date representation of 't' for 'sr_Latn'
510 func (sr *sr_Latn) FmtDateFull(t time.Time) string {
512 b := make([]byte, 0, 32)
514 b = append(b, sr.daysWide[t.Weekday()]...)
515 b = append(b, []byte{0x2c, 0x20}...)
521 b = strconv.AppendInt(b, int64(t.Day()), 10)
522 b = append(b, []byte{0x2e, 0x20}...)
523 b = append(b, sr.monthsWide[t.Month()]...)
524 b = append(b, []byte{0x20}...)
527 b = strconv.AppendInt(b, int64(t.Year()), 10)
529 b = strconv.AppendInt(b, int64(-t.Year()), 10)
532 b = append(b, []byte{0x2e}...)
537 // FmtTimeShort returns the short time representation of 't' for 'sr_Latn'
538 func (sr *sr_Latn) FmtTimeShort(t time.Time) string {
540 b := make([]byte, 0, 32)
546 b = strconv.AppendInt(b, int64(t.Hour()), 10)
547 b = append(b, sr.timeSeparator...)
553 b = strconv.AppendInt(b, int64(t.Minute()), 10)
558 // FmtTimeMedium returns the medium time representation of 't' for 'sr_Latn'
559 func (sr *sr_Latn) FmtTimeMedium(t time.Time) string {
561 b := make([]byte, 0, 32)
567 b = strconv.AppendInt(b, int64(t.Hour()), 10)
568 b = append(b, sr.timeSeparator...)
574 b = strconv.AppendInt(b, int64(t.Minute()), 10)
575 b = append(b, sr.timeSeparator...)
581 b = strconv.AppendInt(b, int64(t.Second()), 10)
586 // FmtTimeLong returns the long time representation of 't' for 'sr_Latn'
587 func (sr *sr_Latn) FmtTimeLong(t time.Time) string {
589 b := make([]byte, 0, 32)
595 b = strconv.AppendInt(b, int64(t.Hour()), 10)
596 b = append(b, sr.timeSeparator...)
602 b = strconv.AppendInt(b, int64(t.Minute()), 10)
603 b = append(b, sr.timeSeparator...)
609 b = strconv.AppendInt(b, int64(t.Second()), 10)
610 b = append(b, []byte{0x20}...)
618 // FmtTimeFull returns the full time representation of 't' for 'sr_Latn'
619 func (sr *sr_Latn) FmtTimeFull(t time.Time) string {
621 b := make([]byte, 0, 32)
627 b = strconv.AppendInt(b, int64(t.Hour()), 10)
628 b = append(b, sr.timeSeparator...)
634 b = strconv.AppendInt(b, int64(t.Minute()), 10)
635 b = append(b, sr.timeSeparator...)
641 b = strconv.AppendInt(b, int64(t.Second()), 10)
642 b = append(b, []byte{0x20}...)
646 if btz, ok := sr.timezones[tz]; ok {
647 b = append(b, btz...)