Documentation ¶
Index ¶
- Constants
- type Calendar
- func (c Calendar) FmtDateFull(t time.Time) (string, error)
- func (c Calendar) FmtDateLong(t time.Time) (string, error)
- func (c Calendar) FmtDateMedium(t time.Time) (string, error)
- func (c Calendar) FmtDateShort(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeFull(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeLong(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeMedium(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeShort(t time.Time) (string, error)
- func (c Calendar) FmtTimeFull(t time.Time) (string, error)
- func (c Calendar) FmtTimeLong(t time.Time) (string, error)
- func (c Calendar) FmtTimeMedium(t time.Time) (string, error)
- func (c Calendar) FmtTimeShort(t time.Time) (string, error)
- func (c Calendar) Format(datetime time.Time, pattern string) (string, error)
- type CalendarDateFormat
- type CalendarDayFormatNameValue
- type CalendarDayFormatNames
- type CalendarFormatNames
- type CalendarFormats
- type CalendarMonthFormatNameValue
- type CalendarMonthFormatNames
- type CalendarPeriodFormatNameValue
- type CalendarPeriodFormatNames
- type Currencies
- type Currency
- type Languages
- type Locale
- type LocaleDisplayPattern
- type Number
- func (n Number) FmtCurrency(currency string, number float64) (formatted string, err error)
- func (n Number) FmtCurrencyAccounting(currency string, number float64) (formatted string, err error)
- func (n Number) FmtCurrencyAccountingWhole(currency string, number float64) (formatted string, err error)
- func (n Number) FmtCurrencyWhole(currency string, number float64) (formatted string, err error)
- func (n Number) FmtNumber(number float64) string
- func (n Number) FmtNumberWhole(number float64) string
- func (n Number) FmtPercent(number float64) string
- type NumberFormats
- type Plural
- type PluralData
- type PluralOperands
- type Symbols
- type Territories
Constants ¶
const ( DateFormatFull = iota DateFormatLong DateFormatMedium DateFormatShort TimeFormatFull TimeFormatLong TimeFormatMedium TimeFormatShort DateTimeFormatFull DateTimeFormatLong DateTimeFormatMedium DateTimeFormatShort )
Standard Formats for Dates, Times & DateTimes These are the options to pass to the Format method.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calendar ¶
type Calendar struct { Formats CalendarFormats FormatNames CalendarFormatNames }
Calendar is populated with the CLDR calendar data
func (Calendar) FmtDateFull ¶
FmtDateFull returns the full date format for the calendar
func (Calendar) FmtDateLong ¶
FmtDateLong returns the full date format for the calendar
func (Calendar) FmtDateMedium ¶
FmtDateMedium returns the full date format for the calendar
func (Calendar) FmtDateShort ¶
FmtDateShort returns the full date format for the calendar
func (Calendar) FmtDateTimeFull ¶
FmtDateTimeFull returns the full date format for the calendar
func (Calendar) FmtDateTimeLong ¶
FmtDateTimeLong returns the full date format for the calendar
func (Calendar) FmtDateTimeMedium ¶
FmtDateTimeMedium returns the full date format for the calendar
func (Calendar) FmtDateTimeShort ¶
FmtDateTimeShort returns the full date format for the calendar
func (Calendar) FmtTimeFull ¶
FmtTimeFull returns the full date format for the calendar
func (Calendar) FmtTimeLong ¶
FmtTimeLong returns the full date format for the calendar
func (Calendar) FmtTimeMedium ¶
FmtTimeMedium returns the full date format for the calendar
func (Calendar) FmtTimeShort ¶
FmtTimeShort returns the full date format for the calendar
type CalendarDateFormat ¶
type CalendarDateFormat struct{ Full, Long, Medium, Short string }
CalendarDateFormat holds different date format strings
type CalendarDayFormatNameValue ¶
type CalendarDayFormatNameValue struct {
Sun, Mon, Tue, Wed, Thu, Fri, Sat string
}
CalendarDayFormatNameValue has a localized string for each day of the week
type CalendarDayFormatNames ¶
type CalendarDayFormatNames struct { Abbreviated CalendarDayFormatNameValue Narrow CalendarDayFormatNameValue Short CalendarDayFormatNameValue Wide CalendarDayFormatNameValue }
CalendarDayFormatNames is the different forms of days
type CalendarFormatNames ¶
type CalendarFormatNames struct { Months CalendarMonthFormatNames Days CalendarDayFormatNames Periods CalendarPeriodFormatNames }
CalendarFormatNames contains various data related to localized names for calendar items
type CalendarFormats ¶
type CalendarFormats struct { Date CalendarDateFormat Time CalendarDateFormat DateTime CalendarDateFormat GMT string }
CalendarFormats is populated with the CLDR calendar data
type CalendarMonthFormatNameValue ¶
type CalendarMonthFormatNameValue struct {
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec string
}
CalendarMonthFormatNameValue has a localized string for each month
type CalendarMonthFormatNames ¶
type CalendarMonthFormatNames struct { Abbreviated CalendarMonthFormatNameValue Narrow CalendarMonthFormatNameValue Short CalendarMonthFormatNameValue Wide CalendarMonthFormatNameValue }
CalendarMonthFormatNames is the different forms of months
type CalendarPeriodFormatNameValue ¶
type CalendarPeriodFormatNameValue struct {
AM, PM string
}
CalendarPeriodFormatNameValue has a localized string for each time period
type CalendarPeriodFormatNames ¶
type CalendarPeriodFormatNames struct { Abbreviated CalendarPeriodFormatNameValue Narrow CalendarPeriodFormatNameValue Short CalendarPeriodFormatNameValue Wide CalendarPeriodFormatNameValue }
CalendarPeriodFormatNames are the different forms of time periods
type Currencies ¶
Currencies maps a currency code (e.g. "USD") to a Currency
type Locale ¶
type Locale struct { Locale string Number Number Calendar Calendar Plural Plural Languages Languages Territories Territories Display LocaleDisplayPattern }
Locale has all the relevant information from the CLDR for a locale
type LocaleDisplayPattern ¶
LocaleDisplayPattern indicates how to display locales, e.g. Language (Region), using placeholders {0} ({1})
type Number ¶
type Number struct { Symbols Symbols Formats NumberFormats Currencies Currencies }
Number contains information required for locale-specific number formatting
func (Number) FmtCurrency ¶
FmtCurrency takes a float number and a currency key and returns a string with a properly formatted currency amount with the correct currency symbol. If a symbol cannot be found for the reqested currency, the the key is used instead. If the currency key requested is not recognized, it is used as the symbol, and an error is returned with the formatted string.
func (Number) FmtCurrencyAccounting ¶
func (n Number) FmtCurrencyAccounting(currency string, number float64) (formatted string, err error)
FmtCurrencyAccounting is the same as FmtCurrency, but using the accounting format in the CLDR. If the accounting format is missing, it falls back on the standard format (the same one used in FmtCurrency).
func (Number) FmtCurrencyAccountingWhole ¶
func (n Number) FmtCurrencyAccountingWhole(currency string, number float64) (formatted string, err error)
FmtCurrencyAccountingWhole is the accounting equivalent of FmtCurrencyWhole. It falls back on the standard format if the accounting format is missing.
func (Number) FmtCurrencyWhole ¶
FmtCurrencyWhole does exactly what FmtCurrency does, but it leaves off any decimal places. AKA, it would return $100 rather than $100.00.
func (Number) FmtNumber ¶
FmtNumber takes a float number and returns a properly formatted string representation of that number according to the locale's number format.
func (Number) FmtNumberWhole ¶
FmtNumberWhole does exactly what FormatNumber does, but it leaves off any decimal places. AKA, it would return 100 rather than 100.01.
func (Number) FmtPercent ¶
FmtPercent takes a float number and returns a properly formatted string representation of that number as a percentage according to the locale's percentage format.
type NumberFormats ¶
type NumberFormats struct { Decimal string Currency string CurrencyAccounting string Percent string }
NumberFormats contains the different format strings from the CLDR
type Plural ¶
type Plural struct { Cardinal PluralData Ordinal PluralData }
Plural contains both cardinal and ordinal plural data from the CLDR
type PluralData ¶
type PluralData struct { Forms []plural.Form Func func(ops *PluralOperands) plural.Form }
PluralData contains information about the plural forms for the locale and how to get plural operators
type PluralOperands ¶
type PluralOperands struct { N float64 // absolute value of the source number (integer and decimals) I int64 // integer digits of n V int64 // number of visible fraction digits in n, with trailing zeros W int64 // number of visible fraction digits in n, without trailing zeros F int64 // visible fractional digits in n, with trailing zeros T int64 // visible fractional digits in n, without trailing zeros }
PluralOperands is a representation of http://unicode.org/reports/tr35/tr35-numbers.html#Operands
func NewOperands ¶
func NewOperands(number interface{}) (*PluralOperands, error)
NewOperands returns the operands for number.
func (*PluralOperands) NEqualsAny ¶
func (o *PluralOperands) NEqualsAny(any ...int64) bool
NEqualsAny returns true if o represents an integer equal to any of the arguments.
func (*PluralOperands) NInRange ¶
func (o *PluralOperands) NInRange(from, to int64) bool
NInRange returns true if o represents an integer in the closed interval [from, to].
func (*PluralOperands) NModEqualsAny ¶
func (o *PluralOperands) NModEqualsAny(mod int64, any ...int64) bool
NModEqualsAny returns true if o represents an integer equal to any of the arguments modulo mod.
func (*PluralOperands) NModInRange ¶
func (o *PluralOperands) NModInRange(mod, from, to int64) bool
NModInRange returns true if o represents an integer in the closed interval [from, to] modulo mod.
type Territories ¶
Territories maps a territory code to the localized name of the territory
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Code generated by make_resources.go; DO NOT EDIT Code generated by make_resources.go; DO NOT EDIT.
|
Code generated by make_resources.go; DO NOT EDIT Code generated by make_resources.go; DO NOT EDIT. |
currency
Code generated by make_resources.go; DO NOT EDIT.
|
Code generated by make_resources.go; DO NOT EDIT. |
internal/locales
Code generated by make_resources.go; DO NOT EDIT.
|
Code generated by make_resources.go; DO NOT EDIT. |
language
Code generated by make_resources.go; DO NOT EDIT.
|
Code generated by make_resources.go; DO NOT EDIT. |
territory
Code generated by make_resources.go; DO NOT EDIT.
|
Code generated by make_resources.go; DO NOT EDIT. |