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 currencyNegativePrefix 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 'en_GB' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6},
50 pluralsRange: []locales.PluralRule{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 currencyNegativePrefix: "(",
60 currencyNegativeSuffix: ")",
61 monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
62 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
63 monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
64 daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
65 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
66 daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"},
67 daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
68 periodsAbbreviated: []string{"am", "pm"},
69 periodsNarrow: []string{"a", "p"},
70 periodsWide: []string{"am", "pm"},
71 erasAbbreviated: []string{"BC", "AD"},
72 erasNarrow: []string{"B", "A"},
73 erasWide: []string{"Before Christ", "Anno Domini"},
74 timezones: map[string]string{"HEPM": "St. Pierre & Miquelon Daylight Time", "ACWST": "Australian Central Western Standard Time", "MEZ": "Central European Standard Time", "ART": "Argentina Standard Time", "CDT": "Central Daylight Time", "HEEG": "East Greenland Summer Time", "ACST": "Australian Central Standard Time", "PDT": "Pacific Daylight Time", "AEST": "Australian Eastern Standard Time", "AEDT": "Australian Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "CHADT": "Chatham Daylight Time", "HNCU": "Cuba Standard Time", "MYT": "Malaysia Time", "JDT": "Japan Daylight Time", "ARST": "Argentina Summer Time", "COST": "Colombia Summer Time", "WART": "Western Argentina Standard Time", "VET": "Venezuela Time", "ADT": "Atlantic Daylight Time", "HAT": "Newfoundland Daylight Time", "HKST": "Hong Kong Summer Time", "BT": "Bhutan Time", "HNEG": "East Greenland Standard Time", "WESZ": "Western European Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "NZST": "New Zealand Standard Time", "TMT": "Turkmenistan Standard Time", "OEZ": "Eastern European Standard Time", "LHST": "Lord Howe Standard Time", "JST": "Japan Standard Time", "IST": "India Standard Time", "WAT": "West Africa Standard Time", "COT": "Colombia Standard Time", "HECU": "Cuba Daylight Time", "WITA": "Central Indonesia Time", "ECT": "Ecuador Time", "WEZ": "Western European Standard Time", "AWST": "Australian Western Standard Time", "WIT": "Eastern Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMST": "Turkmenistan Summer Time", "LHDT": "Lord Howe Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "AST": "Atlantic Standard Time", "SRT": "Suriname Time", "MESZ": "Central European Summer Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "GFT": "French Guiana Time", "EDT": "Eastern Daylight Time", "∅∅∅": "Amazon Summer Time", "ChST": "Chamorro Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CST": "Central Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNOG": "West Greenland Standard Time", "AKST": "Alaska Standard Time", "SGT": "Singapore Standard Time", "CHAST": "Chatham Standard Time", "MST": "Macau Standard Time", "MDT": "Macau Summer Time", "UYST": "Uruguay Summer Time", "HEOG": "West Greenland Summer Time", "GYT": "Guyana Time", "AKDT": "Alaska Daylight Time", "ACDT": "Australian Central Daylight Time", "CAT": "Central Africa Time", "WIB": "Western Indonesia Time", "UYT": "Uruguay Standard Time", "NZDT": "New Zealand Daylight Time", "OESZ": "Eastern European Summer Time", "SAST": "South Africa Standard Time", "PST": "Pacific Standard Time", "BOT": "Bolivia Time", "AWDT": "Australian Western Daylight Time", "WAST": "West Africa Summer Time", "CLST": "Chile Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "HNT": "Newfoundland Standard Time", "EST": "Eastern Standard Time", "GMT": "Greenwich Mean Time", "HNPMX": "Mexican Pacific Standard Time", "EAT": "East Africa Time"},
78 // Locale returns the current translators string locale
79 func (en *en_GB) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'en_GB'
84 func (en *en_GB) PluralsCardinal() []locales.PluralRule {
85 return en.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GB'
89 func (en *en_GB) PluralsOrdinal() []locales.PluralRule {
90 return en.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'en_GB'
94 func (en *en_GB) PluralsRange() []locales.PluralRule {
95 return en.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GB'
99 func (en *en_GB) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
104 if i == 1 && v == 0 {
105 return locales.PluralRuleOne
108 return locales.PluralRuleOther
111 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GB'
112 func (en *en_GB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
115 nMod10 := math.Mod(n, 10)
116 nMod100 := math.Mod(n, 100)
118 if nMod10 == 1 && nMod100 != 11 {
119 return locales.PluralRuleOne
120 } else if nMod10 == 2 && nMod100 != 12 {
121 return locales.PluralRuleTwo
122 } else if nMod10 == 3 && nMod100 != 13 {
123 return locales.PluralRuleFew
126 return locales.PluralRuleOther
129 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GB'
130 func (en *en_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
131 return locales.PluralRuleOther
134 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
135 func (en *en_GB) MonthAbbreviated(month time.Month) string {
136 return en.monthsAbbreviated[month]
139 // MonthsAbbreviated returns the locales abbreviated months
140 func (en *en_GB) MonthsAbbreviated() []string {
141 return en.monthsAbbreviated[1:]
144 // MonthNarrow returns the locales narrow month given the 'month' provided
145 func (en *en_GB) MonthNarrow(month time.Month) string {
146 return en.monthsNarrow[month]
149 // MonthsNarrow returns the locales narrow months
150 func (en *en_GB) MonthsNarrow() []string {
151 return en.monthsNarrow[1:]
154 // MonthWide returns the locales wide month given the 'month' provided
155 func (en *en_GB) MonthWide(month time.Month) string {
156 return en.monthsWide[month]
159 // MonthsWide returns the locales wide months
160 func (en *en_GB) MonthsWide() []string {
161 return en.monthsWide[1:]
164 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
165 func (en *en_GB) WeekdayAbbreviated(weekday time.Weekday) string {
166 return en.daysAbbreviated[weekday]
169 // WeekdaysAbbreviated returns the locales abbreviated weekdays
170 func (en *en_GB) WeekdaysAbbreviated() []string {
171 return en.daysAbbreviated
174 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
175 func (en *en_GB) WeekdayNarrow(weekday time.Weekday) string {
176 return en.daysNarrow[weekday]
179 // WeekdaysNarrow returns the locales narrow weekdays
180 func (en *en_GB) WeekdaysNarrow() []string {
184 // WeekdayShort returns the locales short weekday given the 'weekday' provided
185 func (en *en_GB) WeekdayShort(weekday time.Weekday) string {
186 return en.daysShort[weekday]
189 // WeekdaysShort returns the locales short weekdays
190 func (en *en_GB) WeekdaysShort() []string {
194 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
195 func (en *en_GB) WeekdayWide(weekday time.Weekday) string {
196 return en.daysWide[weekday]
199 // WeekdaysWide returns the locales wide weekdays
200 func (en *en_GB) WeekdaysWide() []string {
204 // Decimal returns the decimal point of number
205 func (en *en_GB) Decimal() string {
209 // Group returns the group of number
210 func (en *en_GB) Group() string {
214 // Group returns the minus sign of number
215 func (en *en_GB) Minus() string {
219 // FmtNumber returns 'num' with digits/precision of 'v' for 'en_GB' and handles both Whole and Real numbers based on 'v'
220 func (en *en_GB) FmtNumber(num float64, v uint64) string {
222 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
223 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
226 b := make([]byte, 0, l)
228 for i := len(s) - 1; i >= 0; i-- {
231 b = append(b, en.decimal[0])
238 b = append(b, en.group[0])
249 b = append(b, en.minus[0])
253 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
254 b[i], b[j] = b[j], b[i]
260 // FmtPercent returns 'num' with digits/precision of 'v' for 'en_GB' and handles both Whole and Real numbers based on 'v'
261 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
262 func (en *en_GB) FmtPercent(num float64, v uint64) string {
263 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 b := make([]byte, 0, l)
267 for i := len(s) - 1; i >= 0; i-- {
270 b = append(b, en.decimal[0])
278 b = append(b, en.minus[0])
282 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
283 b[i], b[j] = b[j], b[i]
286 b = append(b, en.percent...)
291 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GB'
292 func (en *en_GB) FmtCurrency(num float64, v uint64, currency currency.Type) string {
294 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
295 symbol := en.currencies[currency]
296 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
299 b := make([]byte, 0, l)
301 for i := len(s) - 1; i >= 0; i-- {
304 b = append(b, en.decimal[0])
311 b = append(b, en.group[0])
321 for j := len(symbol) - 1; j >= 0; j-- {
322 b = append(b, symbol[j])
326 b = append(b, en.minus[0])
330 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
331 b[i], b[j] = b[j], b[i]
337 b = append(b, en.decimal...)
340 for i := 0; i < 2-int(v); i++ {
348 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GB'
349 // in accounting notation.
350 func (en *en_GB) FmtAccounting(num float64, v uint64, currency currency.Type) string {
352 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
353 symbol := en.currencies[currency]
354 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
357 b := make([]byte, 0, l)
359 for i := len(s) - 1; i >= 0; i-- {
362 b = append(b, en.decimal[0])
369 b = append(b, en.group[0])
381 for j := len(symbol) - 1; j >= 0; j-- {
382 b = append(b, symbol[j])
385 b = append(b, en.currencyNegativePrefix[0])
389 for j := len(symbol) - 1; j >= 0; j-- {
390 b = append(b, symbol[j])
396 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
397 b[i], b[j] = b[j], b[i]
403 b = append(b, en.decimal...)
406 for i := 0; i < 2-int(v); i++ {
412 b = append(b, en.currencyNegativeSuffix...)
418 // FmtDateShort returns the short date representation of 't' for 'en_GB'
419 func (en *en_GB) FmtDateShort(t time.Time) string {
421 b := make([]byte, 0, 32)
427 b = strconv.AppendInt(b, int64(t.Day()), 10)
428 b = append(b, []byte{0x2f}...)
434 b = strconv.AppendInt(b, int64(t.Month()), 10)
436 b = append(b, []byte{0x2f}...)
439 b = strconv.AppendInt(b, int64(t.Year()), 10)
441 b = strconv.AppendInt(b, int64(-t.Year()), 10)
447 // FmtDateMedium returns the medium date representation of 't' for 'en_GB'
448 func (en *en_GB) FmtDateMedium(t time.Time) string {
450 b := make([]byte, 0, 32)
452 b = strconv.AppendInt(b, int64(t.Day()), 10)
453 b = append(b, []byte{0x20}...)
454 b = append(b, en.monthsAbbreviated[t.Month()]...)
455 b = append(b, []byte{0x20}...)
458 b = strconv.AppendInt(b, int64(t.Year()), 10)
460 b = strconv.AppendInt(b, int64(-t.Year()), 10)
466 // FmtDateLong returns the long date representation of 't' for 'en_GB'
467 func (en *en_GB) FmtDateLong(t time.Time) string {
469 b := make([]byte, 0, 32)
471 b = strconv.AppendInt(b, int64(t.Day()), 10)
472 b = append(b, []byte{0x20}...)
473 b = append(b, en.monthsWide[t.Month()]...)
474 b = append(b, []byte{0x20}...)
477 b = strconv.AppendInt(b, int64(t.Year()), 10)
479 b = strconv.AppendInt(b, int64(-t.Year()), 10)
485 // FmtDateFull returns the full date representation of 't' for 'en_GB'
486 func (en *en_GB) FmtDateFull(t time.Time) string {
488 b := make([]byte, 0, 32)
490 b = append(b, en.daysWide[t.Weekday()]...)
491 b = append(b, []byte{0x2c, 0x20}...)
492 b = strconv.AppendInt(b, int64(t.Day()), 10)
493 b = append(b, []byte{0x20}...)
494 b = append(b, en.monthsWide[t.Month()]...)
495 b = append(b, []byte{0x20}...)
498 b = strconv.AppendInt(b, int64(t.Year()), 10)
500 b = strconv.AppendInt(b, int64(-t.Year()), 10)
506 // FmtTimeShort returns the short time representation of 't' for 'en_GB'
507 func (en *en_GB) FmtTimeShort(t time.Time) string {
509 b := make([]byte, 0, 32)
515 b = strconv.AppendInt(b, int64(t.Hour()), 10)
516 b = append(b, en.timeSeparator...)
522 b = strconv.AppendInt(b, int64(t.Minute()), 10)
527 // FmtTimeMedium returns the medium time representation of 't' for 'en_GB'
528 func (en *en_GB) FmtTimeMedium(t time.Time) string {
530 b := make([]byte, 0, 32)
536 b = strconv.AppendInt(b, int64(t.Hour()), 10)
537 b = append(b, en.timeSeparator...)
543 b = strconv.AppendInt(b, int64(t.Minute()), 10)
544 b = append(b, en.timeSeparator...)
550 b = strconv.AppendInt(b, int64(t.Second()), 10)
555 // FmtTimeLong returns the long time representation of 't' for 'en_GB'
556 func (en *en_GB) FmtTimeLong(t time.Time) string {
558 b := make([]byte, 0, 32)
564 b = strconv.AppendInt(b, int64(t.Hour()), 10)
565 b = append(b, en.timeSeparator...)
571 b = strconv.AppendInt(b, int64(t.Minute()), 10)
572 b = append(b, en.timeSeparator...)
578 b = strconv.AppendInt(b, int64(t.Second()), 10)
579 b = append(b, []byte{0x20}...)
587 // FmtTimeFull returns the full time representation of 't' for 'en_GB'
588 func (en *en_GB) FmtTimeFull(t time.Time) string {
590 b := make([]byte, 0, 32)
596 b = strconv.AppendInt(b, int64(t.Hour()), 10)
597 b = append(b, en.timeSeparator...)
603 b = strconv.AppendInt(b, int64(t.Minute()), 10)
604 b = append(b, en.timeSeparator...)
610 b = strconv.AppendInt(b, int64(t.Second()), 10)
611 b = append(b, []byte{0x20}...)
615 if btz, ok := en.timezones[tz]; ok {
616 b = append(b, btz...)