locales

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F

func F(n float64, v uint64) (f int64)

F returns the visible fractional digits in N, with trailing zeros.

func T

func T(n float64, v uint64) (t int64)

T returns the visible fractional digits in N, without trailing zeros.

func W

func W(n float64, v uint64) (w int64)

W returns the number of visible fraction digits in N, without trailing zeros.

Types

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 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

	// returns the locales abbreviated month given the 'month' provided
	MonthAbbreviated(month time.Month) string

	// returns the locales abbreviated months
	MonthsAbbreviated() []string

	// returns the locales narrow month given the 'month' provided
	MonthNarrow(month time.Month) string

	// returns the locales narrow months
	MonthsNarrow() []string

	// returns the locales wide month given the 'month' provided
	MonthWide(month time.Month) string

	// returns the locales wide months
	MonthsWide() []string

	// returns the locales abbreviated weekday given the 'weekday' provided
	WeekdayAbbreviated(weekday time.Weekday) string

	// returns the locales abbreviated weekdays
	WeekdaysAbbreviated() []string

	// returns the locales narrow weekday given the 'weekday' provided
	WeekdayNarrow(weekday time.Weekday) string

	// WeekdaysNarrowreturns the locales narrow weekdays
	WeekdaysNarrow() []string

	// returns the locales short weekday given the 'weekday' provided
	WeekdayShort(weekday time.Weekday) string

	// returns the locales short weekdays
	WeekdaysShort() []string

	// returns the locales wide weekday given the 'weekday' provided
	WeekdayWide(weekday time.Weekday) string

	// returns the locales wide weekdays
	WeekdaysWide() []string

	// returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v'
	FmtNumber(num float64, v uint64) string

	// returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v'
	// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
	FmtPercent(num float64, v uint64) string

	// returns the currency representation of 'num' with digits/precision of 'v' for locale
	FmtCurrency(num float64, v uint64, currency currency.Type) string

	// returns the currency representation of 'num' with digits/precision of 'v' for locale
	// in accounting notation.
	FmtAccounting(num float64, v uint64, currency currency.Type) 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
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL