Documentation ¶
Overview ¶
Package compactnumber allows for localized CLDR compact number formatting.
Code generated by https://github.com/nkall/compactnumber at 2019-10-20 13:43:16.072781 -0700 PDT m=+0.107571706. DO NOT EDIT. Based on https://github.com/unicode-cldr/cldr-numbers-modern version 36
Do not edit this file manually! Instead, follow the "Generating Compact Forms" guide in the README.
Index ¶
Constants ¶
const ( // No compaction, e.g. 17,000,000. None = CompactType("None") // Long-form compaction, e.g. 17 million. Long = CompactType("Long") // Short-form compaction, e.g. 17M. Short = CompactType("Short") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompactType ¶
type CompactType string
CompactType is an enum used to specify compaction settings.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter is a struct containing a method to format an integer based on the specified language and compaction type.
func NewFormatter ¶
func NewFormatter(lang string, compactType CompactType) Formatter
NewFormatter creates a new formatter based on the specified language and compaction type.
func (*Formatter) Format ¶
Format takes in an integer and options and formats it according to the formatter's locale and compaction settings. Note: this method truncates numbers and does not support fractions (e.g. 11.5M).
Documented in CLDR spec: http://www.unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats