mfe_MU.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. package mfe_MU
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type mfe_MU struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal string
  15. group string
  16. minus string
  17. percent string
  18. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyPositivePrefix string
  23. currencyPositiveSuffix string
  24. currencyNegativePrefix string
  25. currencyNegativeSuffix string
  26. monthsAbbreviated []string
  27. monthsNarrow []string
  28. monthsWide []string
  29. daysAbbreviated []string
  30. daysNarrow []string
  31. daysShort []string
  32. daysWide []string
  33. periodsAbbreviated []string
  34. periodsNarrow []string
  35. periodsShort []string
  36. periodsWide []string
  37. erasAbbreviated []string
  38. erasNarrow []string
  39. erasWide []string
  40. timezones map[string]string
  41. }
  42. // New returns a new instance of translator for the 'mfe_MU' locale
  43. func New() locales.Translator {
  44. return &mfe_MU{
  45. locale: "mfe_MU",
  46. pluralsCardinal: nil,
  47. pluralsOrdinal: nil,
  48. pluralsRange: nil,
  49. group: " ",
  50. timeSeparator: ":",
  51. 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 ", "BYR ", "BZD ", "CAD ", "CDF ", "CHE ", "CHF ", "CHW ", "CLE ", "CLF ", "CLP ", "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 ", "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 ", "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 ", "UZS ", "VEB ", "VEF ", "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 "},
  52. currencyPositivePrefix: " ",
  53. currencyPositiveSuffix: "K",
  54. currencyNegativePrefix: " ",
  55. currencyNegativeSuffix: "K",
  56. monthsAbbreviated: []string{"", "zan", "fev", "mar", "avr", "me", "zin", "zil", "out", "sep", "okt", "nov", "des"},
  57. monthsNarrow: []string{"", "z", "f", "m", "a", "m", "z", "z", "o", "s", "o", "n", "d"},
  58. monthsWide: []string{"", "zanvie", "fevriye", "mars", "avril", "me", "zin", "zilye", "out", "septam", "oktob", "novam", "desam"},
  59. daysAbbreviated: []string{"dim", "lin", "mar", "mer", "ze", "van", "sam"},
  60. daysNarrow: []string{"d", "l", "m", "m", "z", "v", "s"},
  61. daysWide: []string{"dimans", "lindi", "mardi", "merkredi", "zedi", "vandredi", "samdi"},
  62. erasAbbreviated: []string{"av. Z-K", "ap. Z-K"},
  63. erasNarrow: []string{"", ""},
  64. erasWide: []string{"avan Zezi-Krist", "apre Zezi-Krist"},
  65. timezones: map[string]string{"CAT": "CAT", "ECT": "ECT", "OEZ": "OEZ", "WESZ": "WESZ", "WAT": "WAT", "GMT": "GMT", "ARST": "ARST", "LHDT": "LHDT", "UYST": "UYST", "HADT": "HADT", "MST": "MST", "AKST": "AKST", "AKDT": "AKDT", "∅∅∅": "∅∅∅", "ADT": "ADT", "MDT": "MDT", "TMST": "TMST", "CDT": "CDT", "UYT": "UYT", "BT": "BT", "HKST": "HKST", "ACWDT": "ACWDT", "OESZ": "OESZ", "NZST": "NZST", "CLST": "CLST", "AEST": "AEST", "EDT": "EDT", "COT": "COT", "WIB": "WIB", "HNT": "HNT", "WARST": "WARST", "WITA": "WITA", "ART": "ART", "JDT": "JDT", "BOT": "BOT", "AEDT": "AEDT", "SGT": "SGT", "HKT": "HKT", "IST": "IST", "PDT": "PDT", "AWST": "AWST", "MESZ": "MESZ", "JST": "JST", "AWDT": "AWDT", "EST": "EST", "AST": "AST", "HAST": "HAST", "SAST": "SAST", "WAST": "WAST", "ACST": "ACST", "LHST": "LHST", "ChST": "ChST", "WIT": "WIT", "EAT": "EAT", "PST": "PST", "GYT": "GYT", "CST": "CST", "MEZ": "MEZ", "HAT": "HAT", "MYT": "MYT", "NZDT": "NZDT", "COST": "COST", "ACWST": "ACWST", "GFT": "GFT", "ACDT": "ACDT", "TMT": "TMT", "VET": "VET", "WEZ": "WEZ", "WART": "WART", "SRT": "SRT", "CLT": "CLT", "CHAST": "CHAST", "CHADT": "CHADT"},
  66. }
  67. }
  68. // Locale returns the current translators string locale
  69. func (mfe *mfe_MU) Locale() string {
  70. return mfe.locale
  71. }
  72. // PluralsCardinal returns the list of cardinal plural rules associated with 'mfe_MU'
  73. func (mfe *mfe_MU) PluralsCardinal() []locales.PluralRule {
  74. return mfe.pluralsCardinal
  75. }
  76. // PluralsOrdinal returns the list of ordinal plural rules associated with 'mfe_MU'
  77. func (mfe *mfe_MU) PluralsOrdinal() []locales.PluralRule {
  78. return mfe.pluralsOrdinal
  79. }
  80. // PluralsRange returns the list of range plural rules associated with 'mfe_MU'
  81. func (mfe *mfe_MU) PluralsRange() []locales.PluralRule {
  82. return mfe.pluralsRange
  83. }
  84. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mfe_MU'
  85. func (mfe *mfe_MU) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  86. return locales.PluralRuleUnknown
  87. }
  88. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mfe_MU'
  89. func (mfe *mfe_MU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  90. return locales.PluralRuleUnknown
  91. }
  92. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mfe_MU'
  93. func (mfe *mfe_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  94. return locales.PluralRuleUnknown
  95. }
  96. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  97. func (mfe *mfe_MU) MonthAbbreviated(month time.Month) string {
  98. return mfe.monthsAbbreviated[month]
  99. }
  100. // MonthsAbbreviated returns the locales abbreviated months
  101. func (mfe *mfe_MU) MonthsAbbreviated() []string {
  102. return mfe.monthsAbbreviated[1:]
  103. }
  104. // MonthNarrow returns the locales narrow month given the 'month' provided
  105. func (mfe *mfe_MU) MonthNarrow(month time.Month) string {
  106. return mfe.monthsNarrow[month]
  107. }
  108. // MonthsNarrow returns the locales narrow months
  109. func (mfe *mfe_MU) MonthsNarrow() []string {
  110. return mfe.monthsNarrow[1:]
  111. }
  112. // MonthWide returns the locales wide month given the 'month' provided
  113. func (mfe *mfe_MU) MonthWide(month time.Month) string {
  114. return mfe.monthsWide[month]
  115. }
  116. // MonthsWide returns the locales wide months
  117. func (mfe *mfe_MU) MonthsWide() []string {
  118. return mfe.monthsWide[1:]
  119. }
  120. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  121. func (mfe *mfe_MU) WeekdayAbbreviated(weekday time.Weekday) string {
  122. return mfe.daysAbbreviated[weekday]
  123. }
  124. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  125. func (mfe *mfe_MU) WeekdaysAbbreviated() []string {
  126. return mfe.daysAbbreviated
  127. }
  128. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  129. func (mfe *mfe_MU) WeekdayNarrow(weekday time.Weekday) string {
  130. return mfe.daysNarrow[weekday]
  131. }
  132. // WeekdaysNarrow returns the locales narrow weekdays
  133. func (mfe *mfe_MU) WeekdaysNarrow() []string {
  134. return mfe.daysNarrow
  135. }
  136. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  137. func (mfe *mfe_MU) WeekdayShort(weekday time.Weekday) string {
  138. return mfe.daysShort[weekday]
  139. }
  140. // WeekdaysShort returns the locales short weekdays
  141. func (mfe *mfe_MU) WeekdaysShort() []string {
  142. return mfe.daysShort
  143. }
  144. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  145. func (mfe *mfe_MU) WeekdayWide(weekday time.Weekday) string {
  146. return mfe.daysWide[weekday]
  147. }
  148. // WeekdaysWide returns the locales wide weekdays
  149. func (mfe *mfe_MU) WeekdaysWide() []string {
  150. return mfe.daysWide
  151. }
  152. // FmtNumber returns 'num' with digits/precision of 'v' for 'mfe_MU' and handles both Whole and Real numbers based on 'v'
  153. func (mfe *mfe_MU) FmtNumber(num float64, v uint64) string {
  154. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  155. }
  156. // FmtPercent returns 'num' with digits/precision of 'v' for 'mfe_MU' and handles both Whole and Real numbers based on 'v'
  157. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  158. func (mfe *mfe_MU) FmtPercent(num float64, v uint64) string {
  159. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  160. }
  161. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mfe_MU'
  162. func (mfe *mfe_MU) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  163. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  164. symbol := mfe.currencies[currency]
  165. l := len(s) + len(symbol) + 3
  166. b := make([]byte, 0, l)
  167. for i := len(s) - 1; i >= 0; i-- {
  168. if s[i] == '.' {
  169. b = append(b, mfe.decimal[0])
  170. continue
  171. }
  172. b = append(b, s[i])
  173. }
  174. for j := len(symbol) - 1; j >= 0; j-- {
  175. b = append(b, symbol[j])
  176. }
  177. for j := len(mfe.currencyPositivePrefix) - 1; j >= 0; j-- {
  178. b = append(b, mfe.currencyPositivePrefix[j])
  179. }
  180. if num < 0 {
  181. b = append(b, mfe.minus[0])
  182. }
  183. // reverse
  184. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  185. b[i], b[j] = b[j], b[i]
  186. }
  187. b = append(b, mfe.currencyPositiveSuffix...)
  188. return string(b)
  189. }
  190. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mfe_MU'
  191. // in accounting notation.
  192. func (mfe *mfe_MU) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  193. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  194. symbol := mfe.currencies[currency]
  195. l := len(s) + len(symbol) + 3
  196. b := make([]byte, 0, l)
  197. for i := len(s) - 1; i >= 0; i-- {
  198. if s[i] == '.' {
  199. b = append(b, mfe.decimal[0])
  200. continue
  201. }
  202. b = append(b, s[i])
  203. }
  204. if num < 0 {
  205. for j := len(symbol) - 1; j >= 0; j-- {
  206. b = append(b, symbol[j])
  207. }
  208. for j := len(mfe.currencyNegativePrefix) - 1; j >= 0; j-- {
  209. b = append(b, mfe.currencyNegativePrefix[j])
  210. }
  211. b = append(b, mfe.minus[0])
  212. } else {
  213. for j := len(symbol) - 1; j >= 0; j-- {
  214. b = append(b, symbol[j])
  215. }
  216. for j := len(mfe.currencyPositivePrefix) - 1; j >= 0; j-- {
  217. b = append(b, mfe.currencyPositivePrefix[j])
  218. }
  219. }
  220. // reverse
  221. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  222. b[i], b[j] = b[j], b[i]
  223. }
  224. if num < 0 {
  225. b = append(b, mfe.currencyNegativeSuffix...)
  226. } else {
  227. b = append(b, mfe.currencyPositiveSuffix...)
  228. }
  229. return string(b)
  230. }
  231. // FmtDateShort returns the short date representation of 't' for 'mfe_MU'
  232. func (mfe *mfe_MU) FmtDateShort(t time.Time) string {
  233. b := make([]byte, 0, 32)
  234. b = strconv.AppendInt(b, int64(t.Day()), 10)
  235. b = append(b, []byte{0x2f}...)
  236. b = strconv.AppendInt(b, int64(t.Month()), 10)
  237. b = append(b, []byte{0x2f}...)
  238. b = strconv.AppendInt(b, int64(t.Year()), 10)
  239. return string(b)
  240. }
  241. // FmtDateMedium returns the medium date representation of 't' for 'mfe_MU'
  242. func (mfe *mfe_MU) FmtDateMedium(t time.Time) string {
  243. b := make([]byte, 0, 32)
  244. b = strconv.AppendInt(b, int64(t.Day()), 10)
  245. b = append(b, []byte{0x20}...)
  246. b = append(b, mfe.monthsAbbreviated[t.Month()]...)
  247. b = append(b, []byte{0x2c, 0x20}...)
  248. b = strconv.AppendInt(b, int64(t.Year()), 10)
  249. return string(b)
  250. }
  251. // FmtDateLong returns the long date representation of 't' for 'mfe_MU'
  252. func (mfe *mfe_MU) FmtDateLong(t time.Time) string {
  253. b := make([]byte, 0, 32)
  254. b = strconv.AppendInt(b, int64(t.Day()), 10)
  255. b = append(b, []byte{0x20}...)
  256. b = append(b, mfe.monthsWide[t.Month()]...)
  257. b = append(b, []byte{0x20}...)
  258. b = strconv.AppendInt(b, int64(t.Year()), 10)
  259. return string(b)
  260. }
  261. // FmtDateFull returns the full date representation of 't' for 'mfe_MU'
  262. func (mfe *mfe_MU) FmtDateFull(t time.Time) string {
  263. b := make([]byte, 0, 32)
  264. b = append(b, mfe.daysWide[t.Weekday()]...)
  265. b = append(b, []byte{0x20}...)
  266. b = strconv.AppendInt(b, int64(t.Day()), 10)
  267. b = append(b, []byte{0x20}...)
  268. b = append(b, mfe.monthsWide[t.Month()]...)
  269. b = append(b, []byte{0x20}...)
  270. b = strconv.AppendInt(b, int64(t.Year()), 10)
  271. return string(b)
  272. }
  273. // FmtTimeShort returns the short time representation of 't' for 'mfe_MU'
  274. func (mfe *mfe_MU) FmtTimeShort(t time.Time) string {
  275. b := make([]byte, 0, 32)
  276. if t.Hour() < 10 {
  277. b = append(b, '0')
  278. }
  279. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  280. b = append(b, mfe.timeSeparator...)
  281. if t.Minute() < 10 {
  282. b = append(b, '0')
  283. }
  284. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  285. return string(b)
  286. }
  287. // FmtTimeMedium returns the medium time representation of 't' for 'mfe_MU'
  288. func (mfe *mfe_MU) FmtTimeMedium(t time.Time) string {
  289. b := make([]byte, 0, 32)
  290. if t.Hour() < 10 {
  291. b = append(b, '0')
  292. }
  293. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  294. b = append(b, mfe.timeSeparator...)
  295. if t.Minute() < 10 {
  296. b = append(b, '0')
  297. }
  298. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  299. b = append(b, mfe.timeSeparator...)
  300. if t.Second() < 10 {
  301. b = append(b, '0')
  302. }
  303. b = strconv.AppendInt(b, int64(t.Second()), 10)
  304. return string(b)
  305. }
  306. // FmtTimeLong returns the long time representation of 't' for 'mfe_MU'
  307. func (mfe *mfe_MU) FmtTimeLong(t time.Time) string {
  308. b := make([]byte, 0, 32)
  309. if t.Hour() < 10 {
  310. b = append(b, '0')
  311. }
  312. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  313. b = append(b, mfe.timeSeparator...)
  314. if t.Minute() < 10 {
  315. b = append(b, '0')
  316. }
  317. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  318. b = append(b, mfe.timeSeparator...)
  319. if t.Second() < 10 {
  320. b = append(b, '0')
  321. }
  322. b = strconv.AppendInt(b, int64(t.Second()), 10)
  323. b = append(b, []byte{0x20}...)
  324. tz, _ := t.Zone()
  325. b = append(b, tz...)
  326. return string(b)
  327. }
  328. // FmtTimeFull returns the full time representation of 't' for 'mfe_MU'
  329. func (mfe *mfe_MU) FmtTimeFull(t time.Time) string {
  330. b := make([]byte, 0, 32)
  331. if t.Hour() < 10 {
  332. b = append(b, '0')
  333. }
  334. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  335. b = append(b, mfe.timeSeparator...)
  336. if t.Minute() < 10 {
  337. b = append(b, '0')
  338. }
  339. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  340. b = append(b, mfe.timeSeparator...)
  341. if t.Second() < 10 {
  342. b = append(b, '0')
  343. }
  344. b = strconv.AppendInt(b, int64(t.Second()), 10)
  345. b = append(b, []byte{0x20}...)
  346. tz, _ := t.Zone()
  347. if btz, ok := mfe.timezones[tz]; ok {
  348. b = append(b, btz...)
  349. } else {
  350. b = append(b, tz...)
  351. }
  352. return string(b)
  353. }