Documentation
¶
Index ¶
- Constants
- Variables
- func F(n float64, v uint64) (f int64)
- func FmtAccounting(t CurrencyWithNumberTranslator, level CurrencyLevel, currency currency.Type, ...) string
- func FmtCurrency(t CurrencyWithNumberTranslator, level CurrencyLevel, currency currency.Type, ...) string
- func FormatNumber(value interface{}, precision int, minus, thousand string, decimalStr string) string
- func FormatNumberString(x string, precision int, minus, thousand string, decimalStr string) string
- func FormatNumberT(t Translator, value interface{}, precision int) string
- func FormatTime(t TimeTranslator, format string, T time.Time) string
- func FormatTimeEra(t TimeTranslator, format string, T time.Time, eraScore int8) string
- func T(n float64, v uint64) (t int64)
- func UnformatNumber(t Translator, n string, precision int) string
- func W(n float64, v uint64) (w int64)
- type CounterFormat
- type Currency
- type CurrencyAccountingFormatterByExp
- type CurrencyAccountingFormatterByExpPlural
- type CurrencyFormat
- type CurrencyFormatters
- func (f *CurrencyFormatters) Accounting(t CurrencyWithNumberTranslator, level CurrencyLevel, cur *Currency, ...) string
- func (f *CurrencyFormatters) Currency(t CurrencyWithNumberTranslator, level CurrencyLevel, cur *Currency, ...) string
- func (f *CurrencyFormatters) Dump(pkg string, out io.Writer)
- func (f *CurrencyFormatters) Format(cf *NumberFormatProperties, t CurrencyWithNumberTranslator, cur *Currency, ...) string
- func (f *CurrencyFormatters) Get(defaul *NumberFormatProperties, ...) (cf *NumberFormatProperties, n decimal.Decimal)
- func (f *CurrencyFormatters) GetAccounting(level CurrencyLevel, num decimal.Decimal) (cf *NumberFormatProperties, n decimal.Decimal)
- func (f *CurrencyFormatters) GetCurrency(level CurrencyLevel, num decimal.Decimal) (cf *NumberFormatProperties, n decimal.Decimal)
- func (f *CurrencyFormatters) IsZero() bool
- type CurrencyLevel
- type CurrencySpec
- type CurrencySymbolLevel
- type CurrencySymbols
- type CurrencyTranslator
- type CurrencyWithNumberTranslator
- type Direction
- type DurationMode
- type DurationSpec
- type DurationSpecPair
- type DurationSpecValue
- type DurationTranslator
- type DurationValue
- type Gender
- type JoinType
- type ListJoinToken
- type ListPattern
- type ListPatternSpec
- type ListPatterns
- func (p *ListPatterns) And(w io.Writer, itens ...string)
- func (p *ListPatterns) AndS(itens ...string) string
- func (p *ListPatterns) Do(w io.Writer, typ JoinType, itens ...string)
- func (p *ListPatterns) DoS(typ JoinType, itens ...string) string
- func (p *ListPatterns) Or(w io.Writer, itens ...string)
- func (p *ListPatterns) OrS(itens ...string) string
- func (f *ListPatterns) ToSlice() [][]string
- type MiscPatterns
- type NumberFlag
- type NumberFormatOptions
- type NumberFormatProperties
- func (f NumberFormatProperties) Dump(pkg string, out io.Writer)
- func (f *NumberFormatProperties) Format(value decimal.Decimal, opts NumberFormatOptions) string
- func (f *NumberFormatProperties) FormatAny(value any, opts NumberFormatOptions) (s string, err error)
- func (f *NumberFormatProperties) FormatS(s string, opts NumberFormatOptions) (ret string)
- func (p *NumberFormatProperties) Parse(value string) (err error)
- func (f NumberFormatProperties) String() string
- type NumberFormatter
- type NumberPatternProperties
- func (f NumberPatternProperties) Dump(pkg string, out io.Writer)
- func (f *NumberPatternProperties) Format(value decimal.Decimal, opts NumberFormatOptions) (ret string)
- func (f *NumberPatternProperties) FormatS(s string, opts NumberFormatOptions) (ret string)
- func (f NumberPatternProperties) Neg() NumberPatternProperties
- func (p *NumberPatternProperties) Parse(pattern string) (err error)
- func (f *NumberPatternProperties) Template(opts NumberFormatOptions) (prefix, suffix string, precision int)
- type NumberSpec
- type NumberTranslator
- type PluralRule
- type TimeRangeValue
- type TimeSpec
- func (t *TimeSpec) ErasAbbreviated() []string
- func (t *TimeSpec) ErasNarrow() []string
- func (t *TimeSpec) ErasWide() []string
- func (t *TimeSpec) MonthAbbreviated(m time.Month) string
- func (t *TimeSpec) MonthNarrow(m time.Month) string
- func (t *TimeSpec) MonthWide(m time.Month) string
- func (t *TimeSpec) MonthsAbbreviated() []string
- func (t *TimeSpec) MonthsNarrow() []string
- func (t *TimeSpec) MonthsWide() []string
- func (t *TimeSpec) PeriodsAbbreviated() []string
- func (t *TimeSpec) PeriodsNarrow() []string
- func (t *TimeSpec) PeriodsShort() []string
- func (t *TimeSpec) PeriodsWide() []string
- func (t *TimeSpec) TimeSeparator() string
- func (t *TimeSpec) Timezones() map[string]string
- func (t *TimeSpec) WeekdayAbbreviated(d time.Weekday) string
- func (t *TimeSpec) WeekdayNarrow(d time.Weekday) string
- func (t *TimeSpec) WeekdayShort(d time.Weekday) string
- func (t *TimeSpec) WeekdayWide(d time.Weekday) string
- func (t *TimeSpec) WeekdaysAbbreviated() []string
- func (t *TimeSpec) WeekdaysNarrow() []string
- func (t *TimeSpec) WeekdaysShort() []string
- func (t *TimeSpec) WeekdaysWide() []string
- type TimeTranslator
- type TimeValue
- type TimestampFormat
- func (f TimestampFormat) Clear(flag TimestampFormat) TimestampFormat
- func (f *TimestampFormat) EraScore() int8
- func (f TimestampFormat) Format(Tr TimeTranslator, t time.Time) string
- func (f TimestampFormat) FormatSep(Tr TimeTranslator, t time.Time, dateTimeSep string) string
- func (f TimestampFormat) Has(flag TimestampFormat) bool
- func (f TimestampFormat) Layout() TimestampFormat
- func (f TimestampFormat) Layouts(t TimeTranslator) (s []string)
- func (f *TimestampFormat) Parse(s string)
- func (f *TimestampFormat) ParseAppend(p string)
- func (f *TimestampFormat) ParseAppendArray(p ...string)
- func (f TimestampFormat) Set(flag TimestampFormat) TimestampFormat
- func (f *TimestampFormat) String() string
- func (f TimestampFormat) Toggle(flag TimestampFormat) TimestampFormat
- type Translator
- type TranslatorSpec
Constants ¶
const ( DurationShort DurationMode = iota DurationLong HoursInDay = 24 HoursInMonth = HoursInDay * 30 HoursInYear = HoursInMonth * 12 )
Variables ¶
var ( DefaultAndListJoinPattern = NewListPattern("{0} and {1}", "{0}, {1}", "{0}, {1}", "{0} and {1}") DefaultOrListJoinPattern = NewListPattern("{0} or {1}", "{0}, {1}", "{0}, {1}", "{0} or {1}") )
var ComputedNumberFormatOptions = NumberFormatOptions{
Decimal: ".",
Group: "",
Minus: "-",
}
var DefaultDurationSpec = DurationSpec{ LongSep: " ", ShortSep: "", Year: DurationSpecPair{ Masculine, &CounterFormat{ Other: "%vY", Per: "%v/Y", }, &CounterFormat{ "Years", "%d year", "%d years", "%v per year", }, }, Month: DurationSpecPair{ Masculine, &CounterFormat{ Other: "%vM", Per: "%v/M", }, &CounterFormat{ "Months", "%d month", "%d months", "%v per month", }, }, Day: DurationSpecPair{ Masculine, &CounterFormat{ Other: "%vd", Per: "%v/d", }, &CounterFormat{ "Days", "%d day", "%d days", "%v per day", }, }, Hour: DurationSpecPair{ Masculine, &CounterFormat{ Other: "%dh", Per: "%v/h", }, &CounterFormat{ "Hours", "%d hour", "%d hours", "%v per hour", }, }, Minute: DurationSpecPair{ Masculine, &CounterFormat{ Other: "%dm", Per: "%v/m", }, &CounterFormat{ "minutes", "%d minute", "%d minutes", "%v per minute", }, }, Second: DurationSpecPair{ Masculine, &CounterFormat{ Label: "sec", Other: "%vs", Per: "%v/s", }, &CounterFormat{ "Seconds", "%v second", "%v seconds", "%v per second", }, }, }
var NumberForamtters = map[reflect.Type]NumberFormatter{ reflect.TypeOf(big.Rat{}): func(value interface{}, precision int, minus, thousand string, decimalStr string) string { var rat, _ = value.(*big.Rat) if rat == nil { var v2 any = value rat = v2.(*big.Rat) } if precision > 0 { return value.(*big.Rat).FloatString(precision) } else { return value.(*big.Rat).String() } }, reflect.TypeOf(decimal.Decimal{}): func(value interface{}, precision int, minus, thousand string, decimalStr string) string { if precision > 0 { return value.(*decimal.Decimal).StringFixed(int32(precision)) } else { return value.(*decimal.Decimal).String() } }, }
Functions ¶
func FmtAccounting ¶
func FmtAccounting(t CurrencyWithNumberTranslator, level CurrencyLevel, currency currency.Type, num decimal.Decimal, precision int) string
FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt' in accounting notation.
func FmtCurrency ¶
func FmtCurrency(t CurrencyWithNumberTranslator, level CurrencyLevel, currency currency.Type, num decimal.Decimal, precision int) string
FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt'
func FormatNumber ¶
func FormatNumber(value interface{}, precision int, minus, thousand string, decimalStr string) string
FormatNumber is a base function of the library which formats a number with custom precision and separators. FormatNumber supports various types of value by runtime reflection. If you don't need runtime type evaluation, please refer to FormatNumberInt or FormatNumberFloat64. (supported value types : int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64, *big.Rat) (also supported value types : decimal.Decimal, *decimal.Decimal *apd.Decimal)
func FormatNumberString ¶
func FormatNumberT ¶
func FormatNumberT(t Translator, value interface{}, precision int) string
func FormatTime ¶
func FormatTime(t TimeTranslator, format string, T time.Time) string
func FormatTimeEra ¶
func UnformatNumber ¶
func UnformatNumber(t Translator, n string, precision int) string
UnformatNumber takes a string of the number to strip currency info on and precision for decimals. It pulls the currency descripter from the LocaleInfo map and uses it to return an unformatted value based on thous sep and decimal sep
Types ¶
type CounterFormat ¶
type CounterFormat struct {
Label, One, Other, Per string
}
func (*CounterFormat) Get ¶
func (f *CounterFormat) Get(qnt uint64, defaul ...*CounterFormat) (v string)
func (*CounterFormat) GetF ¶
func (f *CounterFormat) GetF(qnt float64, defaul ...*CounterFormat) (v string)
func (*CounterFormat) Perf ¶
func (f *CounterFormat) Perf(qnt any) (v string)
type Currency ¶
type Currency struct {
Names map[PluralRule]string
Symbols CurrencySymbols
}
type CurrencyAccountingFormatterByExp ¶
type CurrencyAccountingFormatterByExp struct {
CurrencyFmt map[uint8]*CurrencyAccountingFormatterByExpPlural
AccountingFmt map[uint8]*CurrencyAccountingFormatterByExpPlural
}
type CurrencyAccountingFormatterByExpPlural ¶
type CurrencyAccountingFormatterByExpPlural struct {
Rules map[PluralRule]*NumberFormatProperties
}
type CurrencyFormat ¶
type CurrencyFormat struct {
Raw string
ThousandsLen int
DigitsLen int
SecondaryThousandsLen int
MinDecimalLen int
SymbolDirection Direction
SymbolPrefix string
SymbolSuffix string
Prefix string
Suffix string
}
func (*CurrencyFormat) Exec ¶
func (f *CurrencyFormat) Exec(symbol, value string) string
func (*CurrencyFormat) Format ¶
func (f *CurrencyFormat) Format(t NumberTranslator, cur *Currency, num string, v uint64) string
Format returns the currency representation of 'num' with digits/precision of 'v' for '{{ .Locale }}'
func (*CurrencyFormat) Parse ¶
func (f *CurrencyFormat) Parse(numberFormat string)
type CurrencyFormatters ¶
type CurrencyFormatters struct {
CurrencyFmt,
AccountingFmt *NumberFormatProperties
Short CurrencyAccountingFormatterByExp
}
func (*CurrencyFormatters) Accounting ¶
func (f *CurrencyFormatters) Accounting(t CurrencyWithNumberTranslator, level CurrencyLevel, cur *Currency, num decimal.Decimal, v int) string
func (*CurrencyFormatters) Currency ¶
func (f *CurrencyFormatters) Currency(t CurrencyWithNumberTranslator, level CurrencyLevel, cur *Currency, num decimal.Decimal, v int) string
func (*CurrencyFormatters) Format ¶
func (f *CurrencyFormatters) Format(cf *NumberFormatProperties, t CurrencyWithNumberTranslator, cur *Currency, num decimal.Decimal, precision int) string
func (*CurrencyFormatters) Get ¶
func (f *CurrencyFormatters) Get(defaul *NumberFormatProperties, short map[uint8]*CurrencyAccountingFormatterByExpPlural, level CurrencyLevel, num decimal.Decimal) (cf *NumberFormatProperties, n decimal.Decimal)
func (*CurrencyFormatters) GetAccounting ¶
func (f *CurrencyFormatters) GetAccounting(level CurrencyLevel, num decimal.Decimal) (cf *NumberFormatProperties, n decimal.Decimal)
func (*CurrencyFormatters) GetCurrency ¶
func (f *CurrencyFormatters) GetCurrency(level CurrencyLevel, num decimal.Decimal) (cf *NumberFormatProperties, n decimal.Decimal)
func (*CurrencyFormatters) IsZero ¶
func (f *CurrencyFormatters) IsZero() bool
type CurrencyLevel ¶
type CurrencyLevel uint8
const ( CurrencyLong CurrencyLevel = iota CurrencyShort )
type CurrencySpec ¶
type CurrencySpec struct {
CurrenciesValue []Currency
Formatters *CurrencyFormatters
}
func (*CurrencySpec) Currencies ¶
func (c *CurrencySpec) Currencies() []Currency
func (*CurrencySpec) CurrencyFormatters ¶
func (c *CurrencySpec) CurrencyFormatters() *CurrencyFormatters
type CurrencySymbolLevel ¶
type CurrencySymbolLevel uint8
const ( CurrencySymbolStd CurrencySymbolLevel = 1 + iota CurrencySymbolISO CurrencySymbolName CurrencySymbolNarrow )
type CurrencySymbols ¶
type CurrencyTranslator ¶
type CurrencyTranslator interface {
Currencies() []Currency
CurrencyFormatters() *CurrencyFormatters
}
type CurrencyWithNumberTranslator ¶
type CurrencyWithNumberTranslator interface {
CurrencyTranslator
NumberTranslator
}
type DurationMode ¶
type DurationMode uint8
type DurationSpec ¶
type DurationSpec struct {
LongSep, ShortSep string
Century DurationSpecPair
Decade DurationSpecPair
Year DurationSpecPair
Month DurationSpecPair
Week DurationSpecPair
Day DurationSpecPair
Hour DurationSpecPair
Minute DurationSpecPair
Second DurationSpecPair
Millisecond DurationSpecPair
Microsecond DurationSpecPair
Nanosecond DurationSpecPair
}
func (*DurationSpec) Format ¶
func (d *DurationSpec) Format(mode DurationMode, dur time.Duration) string
type DurationSpecPair ¶
type DurationSpecPair struct {
Gender Gender
Short, Long *CounterFormat
}
func (*DurationSpecPair) Of ¶
func (p *DurationSpecPair) Of(mode DurationMode) *CounterFormat
type DurationSpecValue ¶
type DurationSpecValue struct {
D time.Duration
Spec *DurationSpec
}
type DurationTranslator ¶
type DurationTranslator interface {
GetDurationSpec() *DurationSpec
}
type DurationValue ¶
type DurationValue struct {
Translator Translator
Value time.Duration
}
type ListJoinToken ¶
type ListJoinToken uint8
const ( ListJoinA ListJoinToken = iota ListJoinSep ListJoinB )
func (ListJoinToken) String ¶
func (t ListJoinToken) String() string
type ListPattern ¶
type ListPattern struct {
Two,
Start,
Middle,
End *ListPatternSpec
}
func NewListPattern ¶
func NewListPattern(two, start, middle, end string) *ListPattern
func NewListPatternFromSlice ¶
func NewListPatternFromSlice(def []string) *ListPattern
func (*ListPattern) ToSlice ¶
func (p *ListPattern) ToSlice() []string
type ListPatternSpec ¶
type ListPatternSpec struct {
Pattern string
Sep string
Tokens [3]ListJoinToken
}
func NewListPatternSpec ¶
func NewListPatternSpec(pattern string) *ListPatternSpec
func (*ListPatternSpec) Format ¶
func (s *ListPatternSpec) Format(itens ...string) string
func (*ListPatternSpec) String ¶
func (s *ListPatternSpec) String() string
type ListPatterns ¶
type ListPatterns struct {
AndP, OrP *ListPattern
}
func NewListPatternsFromSlice ¶
func NewListPatternsFromSlice(s [][]string) *ListPatterns
func (*ListPatterns) AndS ¶
func (p *ListPatterns) AndS(itens ...string) string
func (*ListPatterns) OrS ¶
func (p *ListPatterns) OrS(itens ...string) string
func (*ListPatterns) ToSlice ¶
func (f *ListPatterns) ToSlice() [][]string
type MiscPatterns ¶
type MiscPatterns struct {
Approximately,
AtLeast,
AtMost,
Range string
}
type NumberFlag ¶
type NumberFlag uint8
const ( PercentNumber NumberFlag = 1 + iota MilleNumber CurrencyNumber )
type NumberFormatOptions ¶
type NumberFormatProperties ¶
type NumberFormatProperties struct {
Pos,
Neg NumberPatternProperties
}
func MustParseNumberFormatPatterns ¶
func MustParseNumberFormatPatterns(pattern string) *NumberFormatProperties
func (NumberFormatProperties) Dump ¶
func (f NumberFormatProperties) Dump(pkg string, out io.Writer)
func (*NumberFormatProperties) Format ¶
func (f *NumberFormatProperties) Format(value decimal.Decimal, opts NumberFormatOptions) string
func (*NumberFormatProperties) FormatAny ¶
func (f *NumberFormatProperties) FormatAny(value any, opts NumberFormatOptions) (s string, err error)
func (*NumberFormatProperties) FormatS ¶
func (f *NumberFormatProperties) FormatS(s string, opts NumberFormatOptions) (ret string)
func (*NumberFormatProperties) Parse ¶
func (p *NumberFormatProperties) Parse(value string) (err error)
func (NumberFormatProperties) String ¶
func (f NumberFormatProperties) String() string
type NumberFormatter ¶
type NumberPatternProperties ¶
type NumberPatternProperties struct {
// Pattern Raw pattern value
Pattern string
Prefix string
Padding,
ScientificNotation string
// MinimumIntegerDigits non-negative integer Number value indicating the minimum integer
// digits to be used. Numbers will be padded with leading zeroes if necessary.
MinimumIntegerDigits,
MinimumFractionDigits,
MaximumFractionDigits,
MinimumSignificantDigits,
MaximumSignificantDigits,
PrimaryGroupingSize,
SecondaryGroupingSize int
Suffix string
// RoundIncrement Decimal round increment or null
RoundIncrement float64
Type NumberFlag
CurrencySymbol CurrencySymbolLevel
DivExp uint8
}
func (NumberPatternProperties) Dump ¶
func (f NumberPatternProperties) Dump(pkg string, out io.Writer)
func (*NumberPatternProperties) Format ¶
func (f *NumberPatternProperties) Format(value decimal.Decimal, opts NumberFormatOptions) (ret string)
func (*NumberPatternProperties) FormatS ¶
func (f *NumberPatternProperties) FormatS(s string, opts NumberFormatOptions) (ret string)
func (NumberPatternProperties) Neg ¶
func (f NumberPatternProperties) Neg() NumberPatternProperties
func (*NumberPatternProperties) Parse ¶
func (p *NumberPatternProperties) Parse(pattern string) (err error)
*
- format( pattern ) *
- @pattern [String] raw pattern for numbers. *
- Return the formatted number.
- ref: http://www.unicode.org/reports/tr35/tr35-numbers.html
func (*NumberPatternProperties) Template ¶
func (f *NumberPatternProperties) Template(opts NumberFormatOptions) (prefix, suffix string, precision int)
type NumberSpec ¶
type NumberSpec struct {
GroupValue,
DecimalValue,
MinusValue string
}
func (*NumberSpec) Decimal ¶
func (n *NumberSpec) Decimal() string
func (*NumberSpec) Group ¶
func (n *NumberSpec) Group() string
func (*NumberSpec) Minus ¶
func (n *NumberSpec) Minus() string
type NumberTranslator ¶
type PluralRule ¶
type PluralRule int
PluralRule denotes the type of plural rules
const ( PluralRuleUnknown PluralRule = iota PluralRuleZero // zero PluralRuleOne // one - singular PluralRuleTwo // two - dual PluralRuleFew // few - paucal PluralRuleMany // many - also used for fractions if they have a separate class PluralRuleOther // other - required—general plural form—also used if the language only has a single form )
PluralRule's
func (PluralRule) String ¶
func (p PluralRule) String() string
String returns the string value of PluralRule
type TimeRangeValue ¶
type TimeRangeValue struct {
Translator Translator
Formatter TimestampFormat
From, To time.Time
}
func NewTimeRangeValue ¶
func NewTimeRangeValue(translator Translator, from time.Time, to time.Time) *TimeRangeValue
func NewdDateRangeValue ¶
func NewdDateRangeValue(translator Translator, from time.Time, to time.Time) *TimeRangeValue
func (TimeRangeValue) ToString ¶
func (t TimeRangeValue) ToString() string
type TimeSpec ¶
type TimeSpec struct {
Separator string
// returns the locales wide months
MonthsWideValue []string
// returns the locales abbreviated months
MonthsAbbreviatedValue []string
// returns the locales narrow months
MonthsNarrowValue []string
// returns the locales wide weekdays
WeekdaysWideValue []string
// returns the locales abbreviated weekdays
WeekdaysAbbreviatedValue []string
// WeekdaysNarrowreturns the locales narrow weekdays
WeekdaysNarrowValue []string
// returns the locales short weekdays
WeekdaysShortValue []string
PeriodsAbbreviatedValue []string
PeriodsShortValue []string
PeriodsNarrowValue []string
PeriodsWideValue []string
ErasWideValue []string
ErasAbbreviatedValue []string
ErasNarrowValue []string
TimezonesValue map[string]string
}
func (*TimeSpec) ErasAbbreviated ¶
func (*TimeSpec) ErasNarrow ¶
func (*TimeSpec) MonthsAbbreviated ¶
func (*TimeSpec) MonthsNarrow ¶
func (*TimeSpec) MonthsWide ¶
func (*TimeSpec) PeriodsAbbreviated ¶
func (*TimeSpec) PeriodsNarrow ¶
func (*TimeSpec) PeriodsShort ¶
func (*TimeSpec) PeriodsWide ¶
func (*TimeSpec) TimeSeparator ¶
func (*TimeSpec) WeekdaysAbbreviated ¶
func (*TimeSpec) WeekdaysNarrow ¶
func (*TimeSpec) WeekdaysShort ¶
func (*TimeSpec) WeekdaysWide ¶
type TimeTranslator ¶
type TimeTranslator interface {
TimeSeparator() string
// returns the locales wide months
MonthsWide() []string
MonthWide(time.Month) string
// returns the locales abbreviated months
MonthsAbbreviated() []string
MonthAbbreviated(time.Month) string
// returns the locales narrow months
MonthsNarrow() []string
MonthNarrow(time.Month) string
// returns the locales wide weekdays
WeekdaysWide() []string
WeekdayWide(d time.Weekday) string
// returns the locales abbreviated weekdays
WeekdaysAbbreviated() []string
WeekdayAbbreviated(d time.Weekday) string
// WeekdaysNarrowreturns the locales narrow weekdays
WeekdaysNarrow() []string
WeekdayNarrow(d time.Weekday) string
// returns the locales short weekdays
WeekdaysShort() []string
WeekdayShort(d time.Weekday) string
PeriodsAbbreviated() []string
PeriodsShort() []string
PeriodsWide() []string
PeriodsNarrow() []string
ErasWide() []string
ErasAbbreviated() []string
ErasNarrow() []string
Timezones() map[string]string
// returns the short date representation of 't' for locale
FmtDateShort(t time.Time) string
// returns the medium date representation of 't' for locale
FmtDateMedium(t time.Time) string
// returns the long date representation of 't' for locale
FmtDateLong(t time.Time) string
// returns the full date representation of 't' for locale
FmtDateFull(t time.Time) string
// returns the short time representation of 't' for locale
FmtTimeShort(t time.Time) string
// returns the medium time representation of 't' for locale
FmtTimeMedium(t time.Time) string
// returns the long time representation of 't' for locale
FmtTimeLong(t time.Time) string
// returns the full time representation of 't' for locale
FmtTimeFull(t time.Time) string
// DateFullLayout returns the full date layout for '{{ .Locale }}'
DateFullLayout() string
// DateLongLayout returns the long date layout for '{{ .Locale }}'
DateLongLayout() string
// DateMediumLayout returns the medium date layout for '{{ .Locale }}'
DateMediumLayout() string
// DateShortLayout returns the short date layout for '{{ .Locale }}'
DateShortLayout() string
// TimeFullLayout returns the full time layout for '{{ .Locale }}'
TimeFullLayout() string
// TimeLongLayout returns the full long layout for '{{ .Locale }}'
TimeLongLayout() string
// TimeMediumLayout returns the medium time layout for '{{ .Locale }}'
TimeMediumLayout() string
// TimeShortLayout returns the short time layout for '{{ .Locale }}'
TimeShortLayout() string
}
type TimeValue ¶
type TimeValue struct {
Translator TimeTranslator
Formatter TimestampFormat
Value time.Time
}
func NewDateTimeValue ¶
func NewDateTimeValue(translator TimeTranslator, value time.Time) *TimeValue
func NewDateValue ¶
func NewDateValue(translator TimeTranslator, value time.Time) *TimeValue
func NewTimeValue ¶
func NewTimeValue(translator TimeTranslator, value time.Time) *TimeValue
type TimestampFormat ¶
type TimestampFormat uint8
const ( TFNone TimestampFormat = 0 TFDate TimestampFormat = 1 << iota TFTime TFFull TFLong TFMedium TFShort TFTimeFirst DateTime = TFDate | TFTime )
func (TimestampFormat) Clear ¶
func (f TimestampFormat) Clear(flag TimestampFormat) TimestampFormat
func (*TimestampFormat) EraScore ¶
func (f *TimestampFormat) EraScore() int8
func (TimestampFormat) Format ¶
func (f TimestampFormat) Format(Tr TimeTranslator, t time.Time) string
func (TimestampFormat) FormatSep ¶
func (f TimestampFormat) FormatSep(Tr TimeTranslator, t time.Time, dateTimeSep string) string
func (TimestampFormat) Has ¶
func (f TimestampFormat) Has(flag TimestampFormat) bool
func (TimestampFormat) Layout ¶
func (f TimestampFormat) Layout() TimestampFormat
func (TimestampFormat) Layouts ¶
func (f TimestampFormat) Layouts(t TimeTranslator) (s []string)
func (*TimestampFormat) Parse ¶
func (f *TimestampFormat) Parse(s string)
func (*TimestampFormat) ParseAppend ¶
func (f *TimestampFormat) ParseAppend(p string)
func (*TimestampFormat) ParseAppendArray ¶
func (f *TimestampFormat) ParseAppendArray(p ...string)
func (TimestampFormat) Set ¶
func (f TimestampFormat) Set(flag TimestampFormat) TimestampFormat
func (*TimestampFormat) String ¶
func (f *TimestampFormat) String() string
func (TimestampFormat) Toggle ¶
func (f TimestampFormat) Toggle(flag TimestampFormat) TimestampFormat
type Translator ¶
type Translator interface {
// Locale returns the string value of the translator
Locale() string
// returns an array of cardinal plural rules associated
// with this translator
PluralsCardinal() []PluralRule
// returns an array of ordinal plural rules associated
// with this translator
PluralsOrdinal() []PluralRule
// returns an array of range plural rules associated
// with this translator
PluralsRange() []PluralRule
// returns the cardinal PluralRule given 'num' and digits/precision of 'v' for locale
CardinalPluralRule(num float64, v uint64) PluralRule
// returns the ordinal PluralRule given 'num' and digits/precision of 'v' for locale
OrdinalPluralRule(num float64, v uint64) PluralRule
// returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for locale
RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) PluralRule
ListPatterns() *ListPatterns
GetMiscPatterns() *MiscPatterns
NumberTranslator
CurrencyTranslator
TimeTranslator
DurationTranslator
}
Translator encapsulates an instance of a locale NOTE: some values are returned as a []byte just in case the caller wishes to add more and can help avoid allocations; otherwise just cast as string
type TranslatorSpec ¶
type TranslatorSpec struct {
}
