...

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

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

     1  package tzm_MA
     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 tzm_MA 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  	currencyPositiveSuffix string
    26  	currencyNegativeSuffix string
    27  	monthsAbbreviated      []string
    28  	monthsNarrow           []string
    29  	monthsWide             []string
    30  	daysAbbreviated        []string
    31  	daysNarrow             []string
    32  	daysShort              []string
    33  	daysWide               []string
    34  	periodsAbbreviated     []string
    35  	periodsNarrow          []string
    36  	periodsShort           []string
    37  	periodsWide            []string
    38  	erasAbbreviated        []string
    39  	erasNarrow             []string
    40  	erasWide               []string
    41  	timezones              map[string]string
    42  }
    43  
    44  // New returns a new instance of translator for the 'tzm_MA' locale
    45  func New() locales.Translator {
    46  	return &tzm_MA{
    47  		locale:                 "tzm_MA",
    48  		pluralsCardinal:        []locales.PluralRule{2, 6},
    49  		pluralsOrdinal:         nil,
    50  		pluralsRange:           nil,
    51  		decimal:                ",",
    52  		group:                  " ",
    53  		timeSeparator:          ":",
    54  		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", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CNY", "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", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "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", "MXN", "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", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
    55  		currencyPositiveSuffix: " ",
    56  		currencyNegativeSuffix: " ",
    57  		monthsAbbreviated:      []string{"", "Yen", "Yeb", "Mar", "Ibr", "May", "Yun", "Yul", "Ɣuc", "Cut", "Kṭu", "Nwa", "Duj"},
    58  		monthsNarrow:           []string{"", "Y", "Y", "M", "I", "M", "Y", "Y", "Ɣ", "C", "K", "N", "D"},
    59  		monthsWide:             []string{"", "Yennayer", "Yebrayer", "Mars", "Ibrir", "Mayyu", "Yunyu", "Yulyuz", "Ɣuct", "Cutanbir", "Kṭuber", "Nwanbir", "Dujanbir"},
    60  		daysAbbreviated:        []string{"Asa", "Ayn", "Asn", "Akr", "Akw", "Asm", "Asḍ"},
    61  		daysNarrow:             []string{"A", "A", "A", "A", "A", "A", "A"},
    62  		daysWide:               []string{"Asamas", "Aynas", "Asinas", "Akras", "Akwas", "Asimwas", "Asiḍyas"},
    63  		periodsAbbreviated:     []string{"Zdat azal", "Ḍeffir aza"},
    64  		periodsWide:            []string{"Zdat azal", "Ḍeffir aza"},
    65  		erasAbbreviated:        []string{"ZƐ", "ḌƐ"},
    66  		erasNarrow:             []string{"", ""},
    67  		erasWide:               []string{"Zdat Ɛisa (TAƔ)", "Ḍeffir Ɛisa (TAƔ)"},
    68  		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", "∅∅∅": "∅∅∅"},
    69  	}
    70  }
    71  
    72  // Locale returns the current translators string locale
    73  func (tzm *tzm_MA) Locale() string {
    74  	return tzm.locale
    75  }
    76  
    77  // PluralsCardinal returns the list of cardinal plural rules associated with 'tzm_MA'
    78  func (tzm *tzm_MA) PluralsCardinal() []locales.PluralRule {
    79  	return tzm.pluralsCardinal
    80  }
    81  
    82  // PluralsOrdinal returns the list of ordinal plural rules associated with 'tzm_MA'
    83  func (tzm *tzm_MA) PluralsOrdinal() []locales.PluralRule {
    84  	return tzm.pluralsOrdinal
    85  }
    86  
    87  // PluralsRange returns the list of range plural rules associated with 'tzm_MA'
    88  func (tzm *tzm_MA) PluralsRange() []locales.PluralRule {
    89  	return tzm.pluralsRange
    90  }
    91  
    92  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tzm_MA'
    93  func (tzm *tzm_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    94  
    95  	n := math.Abs(num)
    96  
    97  	if (n >= 0 && n <= 1) || (n >= 11 && n <= 99) {
    98  		return locales.PluralRuleOne
    99  	}
   100  
   101  	return locales.PluralRuleOther
   102  }
   103  
   104  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tzm_MA'
   105  func (tzm *tzm_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   106  	return locales.PluralRuleUnknown
   107  }
   108  
   109  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tzm_MA'
   110  func (tzm *tzm_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   111  	return locales.PluralRuleUnknown
   112  }
   113  
   114  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   115  func (tzm *tzm_MA) MonthAbbreviated(month time.Month) string {
   116  	return tzm.monthsAbbreviated[month]
   117  }
   118  
   119  // MonthsAbbreviated returns the locales abbreviated months
   120  func (tzm *tzm_MA) MonthsAbbreviated() []string {
   121  	return tzm.monthsAbbreviated[1:]
   122  }
   123  
   124  // MonthNarrow returns the locales narrow month given the 'month' provided
   125  func (tzm *tzm_MA) MonthNarrow(month time.Month) string {
   126  	return tzm.monthsNarrow[month]
   127  }
   128  
   129  // MonthsNarrow returns the locales narrow months
   130  func (tzm *tzm_MA) MonthsNarrow() []string {
   131  	return tzm.monthsNarrow[1:]
   132  }
   133  
   134  // MonthWide returns the locales wide month given the 'month' provided
   135  func (tzm *tzm_MA) MonthWide(month time.Month) string {
   136  	return tzm.monthsWide[month]
   137  }
   138  
   139  // MonthsWide returns the locales wide months
   140  func (tzm *tzm_MA) MonthsWide() []string {
   141  	return tzm.monthsWide[1:]
   142  }
   143  
   144  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   145  func (tzm *tzm_MA) WeekdayAbbreviated(weekday time.Weekday) string {
   146  	return tzm.daysAbbreviated[weekday]
   147  }
   148  
   149  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   150  func (tzm *tzm_MA) WeekdaysAbbreviated() []string {
   151  	return tzm.daysAbbreviated
   152  }
   153  
   154  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   155  func (tzm *tzm_MA) WeekdayNarrow(weekday time.Weekday) string {
   156  	return tzm.daysNarrow[weekday]
   157  }
   158  
   159  // WeekdaysNarrow returns the locales narrow weekdays
   160  func (tzm *tzm_MA) WeekdaysNarrow() []string {
   161  	return tzm.daysNarrow
   162  }
   163  
   164  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   165  func (tzm *tzm_MA) WeekdayShort(weekday time.Weekday) string {
   166  	return tzm.daysShort[weekday]
   167  }
   168  
   169  // WeekdaysShort returns the locales short weekdays
   170  func (tzm *tzm_MA) WeekdaysShort() []string {
   171  	return tzm.daysShort
   172  }
   173  
   174  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   175  func (tzm *tzm_MA) WeekdayWide(weekday time.Weekday) string {
   176  	return tzm.daysWide[weekday]
   177  }
   178  
   179  // WeekdaysWide returns the locales wide weekdays
   180  func (tzm *tzm_MA) WeekdaysWide() []string {
   181  	return tzm.daysWide
   182  }
   183  
   184  // Decimal returns the decimal point of number
   185  func (tzm *tzm_MA) Decimal() string {
   186  	return tzm.decimal
   187  }
   188  
   189  // Group returns the group of number
   190  func (tzm *tzm_MA) Group() string {
   191  	return tzm.group
   192  }
   193  
   194  // Group returns the minus sign of number
   195  func (tzm *tzm_MA) Minus() string {
   196  	return tzm.minus
   197  }
   198  
   199  // FmtNumber returns 'num' with digits/precision of 'v' for 'tzm_MA' and handles both Whole and Real numbers based on 'v'
   200  func (tzm *tzm_MA) FmtNumber(num float64, v uint64) string {
   201  
   202  	return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   203  }
   204  
   205  // FmtPercent returns 'num' with digits/precision of 'v' for 'tzm_MA' and handles both Whole and Real numbers based on 'v'
   206  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   207  func (tzm *tzm_MA) FmtPercent(num float64, v uint64) string {
   208  	return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   209  }
   210  
   211  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tzm_MA'
   212  func (tzm *tzm_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   213  
   214  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   215  	symbol := tzm.currencies[currency]
   216  	l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
   217  	count := 0
   218  	inWhole := v == 0
   219  	b := make([]byte, 0, l)
   220  
   221  	for i := len(s) - 1; i >= 0; i-- {
   222  
   223  		if s[i] == '.' {
   224  			b = append(b, tzm.decimal[0])
   225  			inWhole = true
   226  			continue
   227  		}
   228  
   229  		if inWhole {
   230  			if count == 3 {
   231  				for j := len(tzm.group) - 1; j >= 0; j-- {
   232  					b = append(b, tzm.group[j])
   233  				}
   234  				count = 1
   235  			} else {
   236  				count++
   237  			}
   238  		}
   239  
   240  		b = append(b, s[i])
   241  	}
   242  
   243  	if num < 0 {
   244  		b = append(b, tzm.minus[0])
   245  	}
   246  
   247  	// reverse
   248  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   249  		b[i], b[j] = b[j], b[i]
   250  	}
   251  
   252  	if int(v) < 2 {
   253  
   254  		if v == 0 {
   255  			b = append(b, tzm.decimal...)
   256  		}
   257  
   258  		for i := 0; i < 2-int(v); i++ {
   259  			b = append(b, '0')
   260  		}
   261  	}
   262  
   263  	b = append(b, tzm.currencyPositiveSuffix...)
   264  
   265  	b = append(b, symbol...)
   266  
   267  	return string(b)
   268  }
   269  
   270  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tzm_MA'
   271  // in accounting notation.
   272  func (tzm *tzm_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   273  
   274  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   275  	symbol := tzm.currencies[currency]
   276  	l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
   277  	count := 0
   278  	inWhole := v == 0
   279  	b := make([]byte, 0, l)
   280  
   281  	for i := len(s) - 1; i >= 0; i-- {
   282  
   283  		if s[i] == '.' {
   284  			b = append(b, tzm.decimal[0])
   285  			inWhole = true
   286  			continue
   287  		}
   288  
   289  		if inWhole {
   290  			if count == 3 {
   291  				for j := len(tzm.group) - 1; j >= 0; j-- {
   292  					b = append(b, tzm.group[j])
   293  				}
   294  				count = 1
   295  			} else {
   296  				count++
   297  			}
   298  		}
   299  
   300  		b = append(b, s[i])
   301  	}
   302  
   303  	if num < 0 {
   304  
   305  		b = append(b, tzm.minus[0])
   306  
   307  	}
   308  
   309  	// reverse
   310  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   311  		b[i], b[j] = b[j], b[i]
   312  	}
   313  
   314  	if int(v) < 2 {
   315  
   316  		if v == 0 {
   317  			b = append(b, tzm.decimal...)
   318  		}
   319  
   320  		for i := 0; i < 2-int(v); i++ {
   321  			b = append(b, '0')
   322  		}
   323  	}
   324  
   325  	if num < 0 {
   326  		b = append(b, tzm.currencyNegativeSuffix...)
   327  		b = append(b, symbol...)
   328  	} else {
   329  
   330  		b = append(b, tzm.currencyPositiveSuffix...)
   331  		b = append(b, symbol...)
   332  	}
   333  
   334  	return string(b)
   335  }
   336  
   337  // FmtDateShort returns the short date representation of 't' for 'tzm_MA'
   338  func (tzm *tzm_MA) FmtDateShort(t time.Time) string {
   339  
   340  	b := make([]byte, 0, 32)
   341  
   342  	if t.Day() < 10 {
   343  		b = append(b, '0')
   344  	}
   345  
   346  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   347  	b = append(b, []byte{0x2f}...)
   348  
   349  	if t.Month() < 10 {
   350  		b = append(b, '0')
   351  	}
   352  
   353  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   354  
   355  	b = append(b, []byte{0x2f}...)
   356  
   357  	if t.Year() > 0 {
   358  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   359  	} else {
   360  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   361  	}
   362  
   363  	return string(b)
   364  }
   365  
   366  // FmtDateMedium returns the medium date representation of 't' for 'tzm_MA'
   367  func (tzm *tzm_MA) FmtDateMedium(t time.Time) string {
   368  
   369  	b := make([]byte, 0, 32)
   370  
   371  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   372  	b = append(b, []byte{0x20}...)
   373  	b = append(b, tzm.monthsAbbreviated[t.Month()]...)
   374  	b = append(b, []byte{0x20}...)
   375  
   376  	if t.Year() > 0 {
   377  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   378  	} else {
   379  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   380  	}
   381  
   382  	return string(b)
   383  }
   384  
   385  // FmtDateLong returns the long date representation of 't' for 'tzm_MA'
   386  func (tzm *tzm_MA) FmtDateLong(t time.Time) string {
   387  
   388  	b := make([]byte, 0, 32)
   389  
   390  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   391  	b = append(b, []byte{0x20}...)
   392  	b = append(b, tzm.monthsWide[t.Month()]...)
   393  	b = append(b, []byte{0x20}...)
   394  
   395  	if t.Year() > 0 {
   396  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   397  	} else {
   398  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   399  	}
   400  
   401  	return string(b)
   402  }
   403  
   404  // FmtDateFull returns the full date representation of 't' for 'tzm_MA'
   405  func (tzm *tzm_MA) FmtDateFull(t time.Time) string {
   406  
   407  	b := make([]byte, 0, 32)
   408  
   409  	b = append(b, tzm.daysWide[t.Weekday()]...)
   410  	b = append(b, []byte{0x2c, 0x20}...)
   411  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   412  	b = append(b, []byte{0x20}...)
   413  	b = append(b, tzm.monthsWide[t.Month()]...)
   414  	b = append(b, []byte{0x20}...)
   415  
   416  	if t.Year() > 0 {
   417  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   418  	} else {
   419  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   420  	}
   421  
   422  	return string(b)
   423  }
   424  
   425  // FmtTimeShort returns the short time representation of 't' for 'tzm_MA'
   426  func (tzm *tzm_MA) FmtTimeShort(t time.Time) string {
   427  
   428  	b := make([]byte, 0, 32)
   429  
   430  	return string(b)
   431  }
   432  
   433  // FmtTimeMedium returns the medium time representation of 't' for 'tzm_MA'
   434  func (tzm *tzm_MA) FmtTimeMedium(t time.Time) string {
   435  
   436  	b := make([]byte, 0, 32)
   437  
   438  	return string(b)
   439  }
   440  
   441  // FmtTimeLong returns the long time representation of 't' for 'tzm_MA'
   442  func (tzm *tzm_MA) FmtTimeLong(t time.Time) string {
   443  
   444  	b := make([]byte, 0, 32)
   445  
   446  	return string(b)
   447  }
   448  
   449  // FmtTimeFull returns the full time representation of 't' for 'tzm_MA'
   450  func (tzm *tzm_MA) FmtTimeFull(t time.Time) string {
   451  
   452  	b := make([]byte, 0, 32)
   453  
   454  	return string(b)
   455  }
   456  

View as plain text