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 'pt_PT' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
51 pluralsRange: []locales.PluralRule{2, 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", "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", "\u200b", "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"},
60 currencyPositiveSuffix: " ",
61 currencyNegativePrefix: "(",
62 currencyNegativeSuffix: " )",
63 monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"},
64 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65 monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"},
66 daysAbbreviated: []string{"domingo", "segunda", "terça", "quarta", "quinta", "sexta", "sábado"},
67 daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"},
68 daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"},
69 daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"},
70 periodsAbbreviated: []string{"a.m.", "p.m."},
71 periodsNarrow: []string{"a.m.", "p.m."},
72 periodsWide: []string{"da manhã", "da tarde"},
73 erasAbbreviated: []string{"a.E.C.", "E.C."},
74 erasNarrow: []string{"", ""},
75 erasWide: []string{"", ""},
76 timezones: map[string]string{"BT": "Hora do Butão", "MYT": "Hora da Malásia", "MEZ": "Hora padrão da Europa Central", "LHST": "Hora padrão de Lord Howe", "WART": "Hora padrão da Argentina Ocidental", "ARST": "Hora de verão da Argentina", "AKST": "Hora padrão do Alasca", "WAST": "Hora de verão da África Ocidental", "WESZ": "Hora de verão da Europa Ocidental", "HNPM": "Hora padrão de São Pedro e Miquelão", "VET": "Hora da Venezuela", "MESZ": "Hora de verão da Europa Central", "NZDT": "Hora de verão da Nova Zelândia", "AEST": "Hora padrão da Austrália Oriental", "HNEG": "Hora padrão da Gronelândia Oriental", "HEEG": "Hora de verão da Gronelândia Oriental", "GMT": "Hora de Greenwich", "HNPMX": "Hora padrão do Pacífico Mexicano", "ART": "Hora padrão da Argentina", "HNT": "Hora padrão da Terra Nova", "AWDT": "Hora de verão da Austrália Ocidental", "HAST": "Hora padrão do Havai e Aleutas", "HNNOMX": "Hora padrão do Noroeste do México", "JST": "Hora padrão do Japão", "ECT": "Hora do Equador", "PDT": "Hora de verão do Pacífico", "CAT": "Hora da África Central", "CHADT": "Hora de verão do Chatham", "MDT": "Hora de verão de Macau", "AWST": "Hora padrão da Austrália Ocidental", "UYT": "Hora padrão do Uruguai", "HENOMX": "Hora de verão do Noroeste do México", "WITA": "Hora da Indonésia Central", "OEZ": "Hora padrão da Europa Oriental", "HNOG": "Hora padrão da Gronelândia Ocidental", "WAT": "Hora padrão da África Ocidental", "CLT": "Hora padrão do Chile", "COT": "Hora padrão da Colômbia", "COST": "Hora de verão da Colômbia", "CHAST": "Hora padrão do Chatham", "CDT": "Hora de verão Central", "MST": "Hora padrão de Macau", "ACWST": "Hora padrão da Austrália Central Ocidental", "LHDT": "Hora de verão de Lord Howe", "IST": "Hora padrão da Índia", "HKST": "Hora de verão de Hong Kong", "WEZ": "Hora padrão da Europa Ocidental", "WIB": "Hora da Indonésia Ocidental", "PST": "Hora padrão do Pacífico", "BOT": "Hora da Bolívia", "CST": "Hora padrão Central", "JDT": "Hora de verão do Japão", "ADT": "Hora de verão do Atlântico", "EAT": "Hora da África Oriental", "EST": "Hora padrão Oriental", "GYT": "Hora da Guiana", "∅∅∅": "Hora de verão do Peru", "HNCU": "Hora padrão de Cuba", "ACWDT": "Hora de verão da Austrália Central Ocidental", "WIT": "Hora da Indonésia Oriental", "TMT": "Hora padrão do Turquemenistão", "TMST": "Hora de verão do Turquemenistão", "OESZ": "Hora de verão da Europa Oriental", "EDT": "Hora de verão Oriental", "ACDT": "Hora de verão da Austrália Central", "HEPM": "Hora de verão de São Pedro e Miquelão", "SRT": "Hora do Suriname", "NZST": "Hora padrão da Nova Zelândia", "SAST": "Hora da África do Sul", "HAT": "Hora de verão da Terra Nova", "CLST": "Hora de verão do Chile", "ChST": "Hora padrão do Chamorro", "HEPMX": "Hora de verão do Pacífico Mexicano", "HADT": "Hora de verão do Havai e Aleutas", "WARST": "Hora de verão da Argentina Ocidental", "AEDT": "Hora de verão da Austrália Oriental", "GFT": "Hora da Guiana Francesa", "HKT": "Hora padrão de Hong Kong", "AKDT": "Hora de verão do Alasca", "SGT": "Hora padrão de Singapura", "HECU": "Hora de verão de Cuba", "UYST": "Hora de verão do Uruguai", "HEOG": "Hora de verão da Gronelândia Ocidental", "AST": "Hora padrão do Atlântico", "ACST": "Hora padrão da Austrália Central"},
80 // Locale returns the current translators string locale
81 func (pt *pt_PT) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'pt_PT'
86 func (pt *pt_PT) PluralsCardinal() []locales.PluralRule {
87 return pt.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_PT'
91 func (pt *pt_PT) PluralsOrdinal() []locales.PluralRule {
92 return pt.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'pt_PT'
96 func (pt *pt_PT) PluralsRange() []locales.PluralRule {
97 return pt.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_PT'
101 func (pt *pt_PT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
106 if i >= 0 && i <= 1 {
107 return locales.PluralRuleOne
110 return locales.PluralRuleOther
113 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_PT'
114 func (pt *pt_PT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
115 return locales.PluralRuleOther
118 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_PT'
119 func (pt *pt_PT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
121 start := pt.CardinalPluralRule(num1, v1)
122 end := pt.CardinalPluralRule(num2, v2)
124 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
125 return locales.PluralRuleOne
126 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
127 return locales.PluralRuleOther
128 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
129 return locales.PluralRuleOne
132 return locales.PluralRuleOther
136 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
137 func (pt *pt_PT) MonthAbbreviated(month time.Month) string {
138 return pt.monthsAbbreviated[month]
141 // MonthsAbbreviated returns the locales abbreviated months
142 func (pt *pt_PT) MonthsAbbreviated() []string {
143 return pt.monthsAbbreviated[1:]
146 // MonthNarrow returns the locales narrow month given the 'month' provided
147 func (pt *pt_PT) MonthNarrow(month time.Month) string {
148 return pt.monthsNarrow[month]
151 // MonthsNarrow returns the locales narrow months
152 func (pt *pt_PT) MonthsNarrow() []string {
153 return pt.monthsNarrow[1:]
156 // MonthWide returns the locales wide month given the 'month' provided
157 func (pt *pt_PT) MonthWide(month time.Month) string {
158 return pt.monthsWide[month]
161 // MonthsWide returns the locales wide months
162 func (pt *pt_PT) MonthsWide() []string {
163 return pt.monthsWide[1:]
166 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
167 func (pt *pt_PT) WeekdayAbbreviated(weekday time.Weekday) string {
168 return pt.daysAbbreviated[weekday]
171 // WeekdaysAbbreviated returns the locales abbreviated weekdays
172 func (pt *pt_PT) WeekdaysAbbreviated() []string {
173 return pt.daysAbbreviated
176 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
177 func (pt *pt_PT) WeekdayNarrow(weekday time.Weekday) string {
178 return pt.daysNarrow[weekday]
181 // WeekdaysNarrow returns the locales narrow weekdays
182 func (pt *pt_PT) WeekdaysNarrow() []string {
186 // WeekdayShort returns the locales short weekday given the 'weekday' provided
187 func (pt *pt_PT) WeekdayShort(weekday time.Weekday) string {
188 return pt.daysShort[weekday]
191 // WeekdaysShort returns the locales short weekdays
192 func (pt *pt_PT) WeekdaysShort() []string {
196 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
197 func (pt *pt_PT) WeekdayWide(weekday time.Weekday) string {
198 return pt.daysWide[weekday]
201 // WeekdaysWide returns the locales wide weekdays
202 func (pt *pt_PT) WeekdaysWide() []string {
206 // Decimal returns the decimal point of number
207 func (pt *pt_PT) Decimal() string {
211 // Group returns the group of number
212 func (pt *pt_PT) Group() string {
216 // Group returns the minus sign of number
217 func (pt *pt_PT) Minus() string {
221 // FmtNumber returns 'num' with digits/precision of 'v' for 'pt_PT' and handles both Whole and Real numbers based on 'v'
222 func (pt *pt_PT) FmtNumber(num float64, v uint64) string {
224 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
225 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
228 b := make([]byte, 0, l)
230 for i := len(s) - 1; i >= 0; i-- {
233 b = append(b, pt.decimal[0])
240 for j := len(pt.group) - 1; j >= 0; j-- {
241 b = append(b, pt.group[j])
253 b = append(b, pt.minus[0])
257 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
258 b[i], b[j] = b[j], b[i]
264 // FmtPercent returns 'num' with digits/precision of 'v' for 'pt_PT' and handles both Whole and Real numbers based on 'v'
265 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
266 func (pt *pt_PT) FmtPercent(num float64, v uint64) string {
267 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
269 b := make([]byte, 0, l)
271 for i := len(s) - 1; i >= 0; i-- {
274 b = append(b, pt.decimal[0])
282 b = append(b, pt.minus[0])
286 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
287 b[i], b[j] = b[j], b[i]
290 b = append(b, pt.percent...)
295 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_PT'
296 func (pt *pt_PT) FmtCurrency(num float64, v uint64, currency currency.Type) string {
298 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
299 symbol := pt.currencies[currency]
300 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
303 b := make([]byte, 0, l)
305 for i := len(s) - 1; i >= 0; i-- {
308 b = append(b, pt.decimal[0])
315 for j := len(pt.group) - 1; j >= 0; j-- {
316 b = append(b, pt.group[j])
328 b = append(b, pt.minus[0])
332 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
333 b[i], b[j] = b[j], b[i]
339 b = append(b, pt.decimal...)
342 for i := 0; i < 2-int(v); i++ {
347 b = append(b, pt.currencyPositiveSuffix...)
349 b = append(b, symbol...)
354 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_PT'
355 // in accounting notation.
356 func (pt *pt_PT) FmtAccounting(num float64, v uint64, currency currency.Type) string {
358 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
359 symbol := pt.currencies[currency]
360 l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
363 b := make([]byte, 0, l)
365 for i := len(s) - 1; i >= 0; i-- {
368 b = append(b, pt.decimal[0])
375 for j := len(pt.group) - 1; j >= 0; j-- {
376 b = append(b, pt.group[j])
389 b = append(b, pt.currencyNegativePrefix[0])
394 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
395 b[i], b[j] = b[j], b[i]
401 b = append(b, pt.decimal...)
404 for i := 0; i < 2-int(v); i++ {
410 b = append(b, pt.currencyNegativeSuffix...)
411 b = append(b, symbol...)
414 b = append(b, pt.currencyPositiveSuffix...)
415 b = append(b, symbol...)
421 // FmtDateShort returns the short date representation of 't' for 'pt_PT'
422 func (pt *pt_PT) FmtDateShort(t time.Time) string {
424 b := make([]byte, 0, 32)
430 b = strconv.AppendInt(b, int64(t.Day()), 10)
431 b = append(b, []byte{0x2f}...)
437 b = strconv.AppendInt(b, int64(t.Month()), 10)
439 b = append(b, []byte{0x2f}...)
442 b = append(b, strconv.Itoa(t.Year())[2:]...)
444 b = append(b, strconv.Itoa(t.Year())[1:]...)
450 // FmtDateMedium returns the medium date representation of 't' for 'pt_PT'
451 func (pt *pt_PT) FmtDateMedium(t time.Time) string {
453 b := make([]byte, 0, 32)
459 b = strconv.AppendInt(b, int64(t.Day()), 10)
460 b = append(b, []byte{0x2f}...)
466 b = strconv.AppendInt(b, int64(t.Month()), 10)
468 b = append(b, []byte{0x2f}...)
471 b = strconv.AppendInt(b, int64(t.Year()), 10)
473 b = strconv.AppendInt(b, int64(-t.Year()), 10)
479 // FmtDateLong returns the long date representation of 't' for 'pt_PT'
480 func (pt *pt_PT) FmtDateLong(t time.Time) string {
482 b := make([]byte, 0, 32)
484 b = strconv.AppendInt(b, int64(t.Day()), 10)
485 b = append(b, []byte{0x20, 0x64, 0x65}...)
486 b = append(b, []byte{0x20}...)
487 b = append(b, pt.monthsWide[t.Month()]...)
488 b = append(b, []byte{0x20, 0x64, 0x65}...)
489 b = append(b, []byte{0x20}...)
492 b = strconv.AppendInt(b, int64(t.Year()), 10)
494 b = strconv.AppendInt(b, int64(-t.Year()), 10)
500 // FmtDateFull returns the full date representation of 't' for 'pt_PT'
501 func (pt *pt_PT) FmtDateFull(t time.Time) string {
503 b := make([]byte, 0, 32)
505 b = append(b, pt.daysWide[t.Weekday()]...)
506 b = append(b, []byte{0x2c, 0x20}...)
507 b = strconv.AppendInt(b, int64(t.Day()), 10)
508 b = append(b, []byte{0x20, 0x64, 0x65}...)
509 b = append(b, []byte{0x20}...)
510 b = append(b, pt.monthsWide[t.Month()]...)
511 b = append(b, []byte{0x20, 0x64, 0x65}...)
512 b = append(b, []byte{0x20}...)
515 b = strconv.AppendInt(b, int64(t.Year()), 10)
517 b = strconv.AppendInt(b, int64(-t.Year()), 10)
523 // FmtTimeShort returns the short time representation of 't' for 'pt_PT'
524 func (pt *pt_PT) FmtTimeShort(t time.Time) string {
526 b := make([]byte, 0, 32)
532 b = strconv.AppendInt(b, int64(t.Hour()), 10)
533 b = append(b, pt.timeSeparator...)
539 b = strconv.AppendInt(b, int64(t.Minute()), 10)
544 // FmtTimeMedium returns the medium time representation of 't' for 'pt_PT'
545 func (pt *pt_PT) FmtTimeMedium(t time.Time) string {
547 b := make([]byte, 0, 32)
553 b = strconv.AppendInt(b, int64(t.Hour()), 10)
554 b = append(b, pt.timeSeparator...)
560 b = strconv.AppendInt(b, int64(t.Minute()), 10)
561 b = append(b, pt.timeSeparator...)
567 b = strconv.AppendInt(b, int64(t.Second()), 10)
572 // FmtTimeLong returns the long time representation of 't' for 'pt_PT'
573 func (pt *pt_PT) FmtTimeLong(t time.Time) string {
575 b := make([]byte, 0, 32)
581 b = strconv.AppendInt(b, int64(t.Hour()), 10)
582 b = append(b, pt.timeSeparator...)
588 b = strconv.AppendInt(b, int64(t.Minute()), 10)
589 b = append(b, pt.timeSeparator...)
595 b = strconv.AppendInt(b, int64(t.Second()), 10)
596 b = append(b, []byte{0x20}...)
604 // FmtTimeFull returns the full time representation of 't' for 'pt_PT'
605 func (pt *pt_PT) FmtTimeFull(t time.Time) string {
607 b := make([]byte, 0, 32)
613 b = strconv.AppendInt(b, int64(t.Hour()), 10)
614 b = append(b, pt.timeSeparator...)
620 b = strconv.AppendInt(b, int64(t.Minute()), 10)
621 b = append(b, pt.timeSeparator...)
627 b = strconv.AppendInt(b, int64(t.Second()), 10)
628 b = append(b, []byte{0x20}...)
632 if btz, ok := pt.timezones[tz]; ok {
633 b = append(b, btz...)