...

Source file src/github.com/go-playground/locales/mzn/mzn.go

Documentation: github.com/go-playground/locales/mzn

     1  package mzn
     2  
     3  import (
     4  	"math"
     5  	"strconv"
     6  	"time"
     7  
     8  	"github.com/go-playground/locales"
     9  	"github.com/go-playground/locales/currency"
    10  )
    11  
    12  type mzn struct {
    13  	locale             string
    14  	pluralsCardinal    []locales.PluralRule
    15  	pluralsOrdinal     []locales.PluralRule
    16  	pluralsRange       []locales.PluralRule
    17  	decimal            string
    18  	group              string
    19  	minus              string
    20  	percent            string
    21  	perMille           string
    22  	timeSeparator      string
    23  	inifinity          string
    24  	currencies         []string // idx = enum of currency code
    25  	monthsAbbreviated  []string
    26  	monthsNarrow       []string
    27  	monthsWide         []string
    28  	daysAbbreviated    []string
    29  	daysNarrow         []string
    30  	daysShort          []string
    31  	daysWide           []string
    32  	periodsAbbreviated []string
    33  	periodsNarrow      []string
    34  	periodsShort       []string
    35  	periodsWide        []string
    36  	erasAbbreviated    []string
    37  	erasNarrow         []string
    38  	erasWide           []string
    39  	timezones          map[string]string
    40  }
    41  
    42  // New returns a new instance of translator for the 'mzn' locale
    43  func New() locales.Translator {
    44  	return &mzn{
    45  		locale:            "mzn",
    46  		pluralsCardinal:   nil,
    47  		pluralsOrdinal:    nil,
    48  		pluralsRange:      nil,
    49  		timeSeparator:     ":",
    50  		currencies:        []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MRU", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "Db", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
    51  		monthsAbbreviated: []string{"", "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"},
    52  		monthsWide:        []string{"", "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"},
    53  		erasAbbreviated:   []string{"پ.م", "م."},
    54  		erasNarrow:        []string{"", ""},
    55  		erasWide:          []string{"قبل میلاد", "بعد میلاد"},
    56  		timezones:         map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "ADT", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "AST", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "CDT", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "CST", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "EDT", "EST": "EST", "GFT": "GFT", "GMT": "GMT", "GST": "GST", "GYT": "GYT", "HADT": "HADT", "HAST": "HAST", "HAT": "HAT", "HECU": "HECU", "HEEG": "HEEG", "HENOMX": "HENOMX", "HEOG": "HEOG", "HEPM": "HEPM", "HEPMX": "HEPMX", "HKST": "HKST", "HKT": "HKT", "HNCU": "HNCU", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNT": "HNT", "IST": "IST", "JDT": "JDT", "JST": "JST", "LHDT": "LHDT", "LHST": "LHST", "MDT": "MDT", "MESZ": "MESZ", "MEZ": "MEZ", "MST": "MST", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "OESZ", "OEZ": "OEZ", "PDT": "PDT", "PST": "PST", "SAST": "SAST", "SGT": "SGT", "SRT": "SRT", "TMST": "TMST", "TMT": "TMT", "UYST": "UYST", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "WART": "WART", "WAST": "WAST", "WAT": "WAT", "WESZ": "WESZ", "WEZ": "WEZ", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
    57  	}
    58  }
    59  
    60  // Locale returns the current translators string locale
    61  func (mzn *mzn) Locale() string {
    62  	return mzn.locale
    63  }
    64  
    65  // PluralsCardinal returns the list of cardinal plural rules associated with 'mzn'
    66  func (mzn *mzn) PluralsCardinal() []locales.PluralRule {
    67  	return mzn.pluralsCardinal
    68  }
    69  
    70  // PluralsOrdinal returns the list of ordinal plural rules associated with 'mzn'
    71  func (mzn *mzn) PluralsOrdinal() []locales.PluralRule {
    72  	return mzn.pluralsOrdinal
    73  }
    74  
    75  // PluralsRange returns the list of range plural rules associated with 'mzn'
    76  func (mzn *mzn) PluralsRange() []locales.PluralRule {
    77  	return mzn.pluralsRange
    78  }
    79  
    80  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mzn'
    81  func (mzn *mzn) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    82  	return locales.PluralRuleUnknown
    83  }
    84  
    85  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mzn'
    86  func (mzn *mzn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
    87  	return locales.PluralRuleUnknown
    88  }
    89  
    90  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mzn'
    91  func (mzn *mzn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
    92  	return locales.PluralRuleUnknown
    93  }
    94  
    95  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
    96  func (mzn *mzn) MonthAbbreviated(month time.Month) string {
    97  	return mzn.monthsAbbreviated[month]
    98  }
    99  
   100  // MonthsAbbreviated returns the locales abbreviated months
   101  func (mzn *mzn) MonthsAbbreviated() []string {
   102  	return mzn.monthsAbbreviated[1:]
   103  }
   104  
   105  // MonthNarrow returns the locales narrow month given the 'month' provided
   106  func (mzn *mzn) MonthNarrow(month time.Month) string {
   107  	return mzn.monthsNarrow[month]
   108  }
   109  
   110  // MonthsNarrow returns the locales narrow months
   111  func (mzn *mzn) MonthsNarrow() []string {
   112  	return nil
   113  }
   114  
   115  // MonthWide returns the locales wide month given the 'month' provided
   116  func (mzn *mzn) MonthWide(month time.Month) string {
   117  	return mzn.monthsWide[month]
   118  }
   119  
   120  // MonthsWide returns the locales wide months
   121  func (mzn *mzn) MonthsWide() []string {
   122  	return mzn.monthsWide[1:]
   123  }
   124  
   125  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   126  func (mzn *mzn) WeekdayAbbreviated(weekday time.Weekday) string {
   127  	return mzn.daysAbbreviated[weekday]
   128  }
   129  
   130  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   131  func (mzn *mzn) WeekdaysAbbreviated() []string {
   132  	return mzn.daysAbbreviated
   133  }
   134  
   135  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   136  func (mzn *mzn) WeekdayNarrow(weekday time.Weekday) string {
   137  	return mzn.daysNarrow[weekday]
   138  }
   139  
   140  // WeekdaysNarrow returns the locales narrow weekdays
   141  func (mzn *mzn) WeekdaysNarrow() []string {
   142  	return mzn.daysNarrow
   143  }
   144  
   145  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   146  func (mzn *mzn) WeekdayShort(weekday time.Weekday) string {
   147  	return mzn.daysShort[weekday]
   148  }
   149  
   150  // WeekdaysShort returns the locales short weekdays
   151  func (mzn *mzn) WeekdaysShort() []string {
   152  	return mzn.daysShort
   153  }
   154  
   155  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   156  func (mzn *mzn) WeekdayWide(weekday time.Weekday) string {
   157  	return mzn.daysWide[weekday]
   158  }
   159  
   160  // WeekdaysWide returns the locales wide weekdays
   161  func (mzn *mzn) WeekdaysWide() []string {
   162  	return mzn.daysWide
   163  }
   164  
   165  // Decimal returns the decimal point of number
   166  func (mzn *mzn) Decimal() string {
   167  	return mzn.decimal
   168  }
   169  
   170  // Group returns the group of number
   171  func (mzn *mzn) Group() string {
   172  	return mzn.group
   173  }
   174  
   175  // Group returns the minus sign of number
   176  func (mzn *mzn) Minus() string {
   177  	return mzn.minus
   178  }
   179  
   180  // FmtNumber returns 'num' with digits/precision of 'v' for 'mzn' and handles both Whole and Real numbers based on 'v'
   181  func (mzn *mzn) FmtNumber(num float64, v uint64) string {
   182  
   183  	return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   184  }
   185  
   186  // FmtPercent returns 'num' with digits/precision of 'v' for 'mzn' and handles both Whole and Real numbers based on 'v'
   187  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   188  func (mzn *mzn) FmtPercent(num float64, v uint64) string {
   189  	return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   190  }
   191  
   192  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mzn'
   193  func (mzn *mzn) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   194  
   195  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   196  	symbol := mzn.currencies[currency]
   197  	return string(append(append([]byte{}, symbol...), s...))
   198  }
   199  
   200  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mzn'
   201  // in accounting notation.
   202  func (mzn *mzn) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   203  
   204  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   205  	symbol := mzn.currencies[currency]
   206  	return string(append(append([]byte{}, symbol...), s...))
   207  }
   208  
   209  // FmtDateShort returns the short date representation of 't' for 'mzn'
   210  func (mzn *mzn) FmtDateShort(t time.Time) string {
   211  
   212  	b := make([]byte, 0, 32)
   213  
   214  	return string(b)
   215  }
   216  
   217  // FmtDateMedium returns the medium date representation of 't' for 'mzn'
   218  func (mzn *mzn) FmtDateMedium(t time.Time) string {
   219  
   220  	b := make([]byte, 0, 32)
   221  
   222  	return string(b)
   223  }
   224  
   225  // FmtDateLong returns the long date representation of 't' for 'mzn'
   226  func (mzn *mzn) FmtDateLong(t time.Time) string {
   227  
   228  	b := make([]byte, 0, 32)
   229  
   230  	return string(b)
   231  }
   232  
   233  // FmtDateFull returns the full date representation of 't' for 'mzn'
   234  func (mzn *mzn) FmtDateFull(t time.Time) string {
   235  
   236  	b := make([]byte, 0, 32)
   237  
   238  	return string(b)
   239  }
   240  
   241  // FmtTimeShort returns the short time representation of 't' for 'mzn'
   242  func (mzn *mzn) FmtTimeShort(t time.Time) string {
   243  
   244  	b := make([]byte, 0, 32)
   245  
   246  	return string(b)
   247  }
   248  
   249  // FmtTimeMedium returns the medium time representation of 't' for 'mzn'
   250  func (mzn *mzn) FmtTimeMedium(t time.Time) string {
   251  
   252  	b := make([]byte, 0, 32)
   253  
   254  	return string(b)
   255  }
   256  
   257  // FmtTimeLong returns the long time representation of 't' for 'mzn'
   258  func (mzn *mzn) FmtTimeLong(t time.Time) string {
   259  
   260  	b := make([]byte, 0, 32)
   261  
   262  	return string(b)
   263  }
   264  
   265  // FmtTimeFull returns the full time representation of 't' for 'mzn'
   266  func (mzn *mzn) FmtTimeFull(t time.Time) string {
   267  
   268  	b := make([]byte, 0, 32)
   269  
   270  	return string(b)
   271  }
   272  

View as plain text