1package localescompressed 2 3import ( 4 "time" 5 6 "github.com/gohugoio/locales" 7 "github.com/gohugoio/locales/currency" 8) 9 10// The following Functions are for overriding, debugging or developing 11// with a Translator Locale 12// Locale returns the string value of the translator 13func (ln *localen) Locale() string { 14 return ln.fnLocale(ln) 15} 16 17// returns an array of cardinal plural rules associated 18// with this translator 19func (ln *localen) PluralsCardinal() []locales.PluralRule { 20 return ln.fnPluralsCardinal(ln) 21} 22 23// returns an array of ordinal plural rules associated 24// with this translator 25func (ln *localen) PluralsOrdinal() []locales.PluralRule { 26 return ln.fnPluralsOrdinal(ln) 27} 28 29// returns an array of range plural rules associated 30// with this translator 31func (ln *localen) PluralsRange() []locales.PluralRule { 32 return ln.pluralsRange 33} 34 35// returns the cardinal PluralRule given 'num' and digits/precision of 'v' for locale 36func (ln *localen) CardinalPluralRule(num float64, v uint64) locales.PluralRule { 37 return ln.fnCardinalPluralRule(ln, num, v) 38} 39 40// returns the ordinal PluralRule given 'num' and digits/precision of 'v' for locale 41func (ln *localen) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 42 return ln.fnOrdinalPluralRule(ln, num, v) 43} 44 45// returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for locale 46func (ln *localen) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 47 return ln.fnRangePluralRule(ln, num1, v1, num2, v2) 48} 49 50// returns the locales abbreviated month given the 'month' provided 51func (ln *localen) MonthAbbreviated(month time.Month) string { 52 return ln.fnMonthAbbreviated(ln, month) 53} 54 55// returns the locales abbreviated months 56func (ln *localen) MonthsAbbreviated() []string { 57 return ln.monthsAbbreviated 58} 59 60// returns the locales narrow month given the 'month' provided 61func (ln *localen) MonthNarrow(month time.Month) string { 62 return ln.monthsNarrow[month] 63} 64 65// returns the locales narrow months 66func (ln *localen) MonthsNarrow() []string { 67 return ln.monthsNarrow[1:] 68} 69 70// returns the locales wide month given the 'month' provided 71func (ln *localen) MonthWide(month time.Month) string { 72 return ln.monthsWide[month] 73} 74 75// returns the locales wide months 76func (ln *localen) MonthsWide() []string { 77 return ln.monthsWide[1:] 78} 79 80// returns the locales abbreviated weekday given the 'weekday' provided 81func (ln *localen) WeekdayAbbreviated(weekday time.Weekday) string { 82 return ln.fnWeekdayAbbreviated(ln, weekday) 83} 84 85// returns the locales abbreviated weekdays 86func (ln *localen) WeekdaysAbbreviated() []string { 87 return ln.daysAbbreviated 88} 89 90// returns the locales narrow weekday given the 'weekday' provided 91func (ln *localen) WeekdayNarrow(weekday time.Weekday) string { 92 return ln.daysNarrow[weekday] 93} 94 95// WeekdaysNarrowreturns the locales narrow weekdays 96func (ln *localen) WeekdaysNarrow() []string { 97 return ln.daysNarrow 98} 99 100// returns the locales short weekday given the 'weekday' provided 101func (ln *localen) WeekdayShort(weekday time.Weekday) string { 102 return ln.daysShort[weekday] 103} 104 105// returns the locales short weekdays 106func (ln *localen) WeekdaysShort() []string { 107 return ln.daysShort 108} 109 110// returns the locales wide weekday given the 'weekday' provided 111func (ln *localen) WeekdayWide(weekday time.Weekday) string { 112 return ln.daysWide[weekday] 113} 114 115// returns the locales wide weekdays 116func (ln *localen) WeekdaysWide() []string { 117 return ln.daysWide 118} 119 120// The following Functions are common Formatting functionsfor the Translator's Locale 121// returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v' 122func (ln *localen) FmtNumber(num float64, v uint64) string { 123 return ln.fnFmtNumber(ln, num, v) 124} 125 126// returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v' 127// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 128func (ln *localen) FmtPercent(num float64, v uint64) string { 129 return ln.fnFmtPercent(ln, num, v) 130} 131 132// returns the currency representation of 'num' with digits/precision of 'v' for locale 133func (ln *localen) FmtCurrency(num float64, v uint64, currency currency.Type) string { 134 return ln.fnFmtCurrency(ln, num, v, currency) 135} 136 137// returns the currency representation of 'num' with digits/precision of 'v' for locale 138// in accounting notation. 139func (ln *localen) FmtAccounting(num float64, v uint64, currency currency.Type) string { 140 return ln.fnFmtAccounting(ln, num, v, currency) 141} 142 143// returns the short date representation of 't' for locale 144func (ln *localen) FmtDateShort(t time.Time) string { 145 return ln.fnFmtDateShort(ln, t) 146} 147 148// returns the medium date representation of 't' for locale 149func (ln *localen) FmtDateMedium(t time.Time) string { 150 return ln.fnFmtDateMedium(ln, t) 151} 152 153// returns the long date representation of 't' for locale 154func (ln *localen) FmtDateLong(t time.Time) string { 155 return ln.fnFmtDateLong(ln, t) 156} 157 158// returns the full date representation of 't' for locale 159func (ln *localen) FmtDateFull(t time.Time) string { 160 return ln.fnFmtDateFull(ln, t) 161} 162 163// returns the short time representation of 't' for locale 164func (ln *localen) FmtTimeShort(t time.Time) string { 165 return ln.fnFmtTimeShort(ln, t) 166} 167 168// returns the medium time representation of 't' for locale 169func (ln *localen) FmtTimeMedium(t time.Time) string { 170 return ln.fnFmtTimeMedium(ln, t) 171} 172 173// returns the long time representation of 't' for locale 174func (ln *localen) FmtTimeLong(t time.Time) string { 175 return ln.fnFmtTimeLong(ln, t) 176} 177 178// returns the full time representation of 't' for locale 179func (ln *localen) FmtTimeFull(t time.Time) string { 180 return ln.fnFmtTimeFull(ln, t) 181} 182