nyn_UG.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. package nyn_UG
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type nyn_UG 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. monthsAbbreviated []string
  23. monthsNarrow []string
  24. monthsWide []string
  25. daysAbbreviated []string
  26. daysNarrow []string
  27. daysShort []string
  28. daysWide []string
  29. periodsAbbreviated []string
  30. periodsNarrow []string
  31. periodsShort []string
  32. periodsWide []string
  33. erasAbbreviated []string
  34. erasNarrow []string
  35. erasWide []string
  36. timezones map[string]string
  37. }
  38. // New returns a new instance of translator for the 'nyn_UG' locale
  39. func New() locales.Translator {
  40. return &nyn_UG{
  41. locale: "nyn_UG",
  42. pluralsCardinal: []locales.PluralRule{2, 6},
  43. pluralsOrdinal: nil,
  44. pluralsRange: nil,
  45. timeSeparator: ":",
  46. 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 "},
  47. monthsAbbreviated: []string{"", "KBZ", "KBR", "KST", "KKN", "KTN", "KMK", "KMS", "KMN", "KMW", "KKM", "KNK", "KNB"},
  48. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  49. monthsWide: []string{"", "Okwokubanza", "Okwakabiri", "Okwakashatu", "Okwakana", "Okwakataana", "Okwamukaaga", "Okwamushanju", "Okwamunaana", "Okwamwenda", "Okwaikumi", "Okwaikumi na kumwe", "Okwaikumi na ibiri"},
  50. daysAbbreviated: []string{"SAN", "ORK", "OKB", "OKS", "OKN", "OKT", "OMK"},
  51. daysNarrow: []string{"S", "K", "R", "S", "N", "T", "M"},
  52. daysWide: []string{"Sande", "Orwokubanza", "Orwakabiri", "Orwakashatu", "Orwakana", "Orwakataano", "Orwamukaaga"},
  53. erasAbbreviated: []string{"BC", "AD"},
  54. erasNarrow: []string{"", ""},
  55. erasWide: []string{"Kurisito Atakaijire", "Kurisito Yaijire"},
  56. timezones: map[string]string{"CST": "CST", "CHADT": "CHADT", "VET": "VET", "CAT": "CAT", "HAT": "HAT", "TMT": "TMT", "ACDT": "ACDT", "WAST": "WAST", "HKT": "HKT", "HKST": "HKST", "IST": "IST", "EAT": "EAT", "JDT": "JDT", "WAT": "WAT", "BT": "BT", "ARST": "ARST", "WESZ": "WESZ", "EDT": "EDT", "ChST": "ChST", "AST": "AST", "AEDT": "AEDT", "ADT": "ADT", "ACST": "ACST", "PST": "PST", "PDT": "PDT", "MESZ": "MESZ", "ACWST": "ACWST", "ACWDT": "ACWDT", "ART": "ART", "AKST": "AKST", "AWST": "AWST", "GFT": "GFT", "WEZ": "WEZ", "WITA": "WITA", "OEZ": "OEZ", "OESZ": "OESZ", "HAST": "HAST", "BOT": "BOT", "UYST": "UYST", "ECT": "ECT", "AWDT": "AWDT", "LHDT": "LHDT", "NZDT": "NZDT", "COST": "COST", "TMST": "TMST", "JST": "JST", "AKDT": "AKDT", "HADT": "HADT", "SRT": "SRT", "MEZ": "MEZ", "CLST": "CLST", "WIB": "WIB", "MDT": "MDT", "EST": "EST", "WART": "WART", "WIT": "WIT", "GMT": "GMT", "HNT": "HNT", "CLT": "CLT", "SAST": "SAST", "MST": "MST", "∅∅∅": "∅∅∅", "LHST": "LHST", "NZST": "NZST", "COT": "COT", "WARST": "WARST", "GYT": "GYT", "SGT": "SGT", "CHAST": "CHAST", "AEST": "AEST", "MYT": "MYT", "CDT": "CDT", "UYT": "UYT"},
  57. }
  58. }
  59. // Locale returns the current translators string locale
  60. func (nyn *nyn_UG) Locale() string {
  61. return nyn.locale
  62. }
  63. // PluralsCardinal returns the list of cardinal plural rules associated with 'nyn_UG'
  64. func (nyn *nyn_UG) PluralsCardinal() []locales.PluralRule {
  65. return nyn.pluralsCardinal
  66. }
  67. // PluralsOrdinal returns the list of ordinal plural rules associated with 'nyn_UG'
  68. func (nyn *nyn_UG) PluralsOrdinal() []locales.PluralRule {
  69. return nyn.pluralsOrdinal
  70. }
  71. // PluralsRange returns the list of range plural rules associated with 'nyn_UG'
  72. func (nyn *nyn_UG) PluralsRange() []locales.PluralRule {
  73. return nyn.pluralsRange
  74. }
  75. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nyn_UG'
  76. func (nyn *nyn_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  77. n := math.Abs(num)
  78. if n == 1 {
  79. return locales.PluralRuleOne
  80. }
  81. return locales.PluralRuleOther
  82. }
  83. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nyn_UG'
  84. func (nyn *nyn_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. return locales.PluralRuleUnknown
  86. }
  87. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nyn_UG'
  88. func (nyn *nyn_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  89. return locales.PluralRuleUnknown
  90. }
  91. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  92. func (nyn *nyn_UG) MonthAbbreviated(month time.Month) string {
  93. return nyn.monthsAbbreviated[month]
  94. }
  95. // MonthsAbbreviated returns the locales abbreviated months
  96. func (nyn *nyn_UG) MonthsAbbreviated() []string {
  97. return nyn.monthsAbbreviated[1:]
  98. }
  99. // MonthNarrow returns the locales narrow month given the 'month' provided
  100. func (nyn *nyn_UG) MonthNarrow(month time.Month) string {
  101. return nyn.monthsNarrow[month]
  102. }
  103. // MonthsNarrow returns the locales narrow months
  104. func (nyn *nyn_UG) MonthsNarrow() []string {
  105. return nyn.monthsNarrow[1:]
  106. }
  107. // MonthWide returns the locales wide month given the 'month' provided
  108. func (nyn *nyn_UG) MonthWide(month time.Month) string {
  109. return nyn.monthsWide[month]
  110. }
  111. // MonthsWide returns the locales wide months
  112. func (nyn *nyn_UG) MonthsWide() []string {
  113. return nyn.monthsWide[1:]
  114. }
  115. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  116. func (nyn *nyn_UG) WeekdayAbbreviated(weekday time.Weekday) string {
  117. return nyn.daysAbbreviated[weekday]
  118. }
  119. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  120. func (nyn *nyn_UG) WeekdaysAbbreviated() []string {
  121. return nyn.daysAbbreviated
  122. }
  123. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  124. func (nyn *nyn_UG) WeekdayNarrow(weekday time.Weekday) string {
  125. return nyn.daysNarrow[weekday]
  126. }
  127. // WeekdaysNarrow returns the locales narrow weekdays
  128. func (nyn *nyn_UG) WeekdaysNarrow() []string {
  129. return nyn.daysNarrow
  130. }
  131. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  132. func (nyn *nyn_UG) WeekdayShort(weekday time.Weekday) string {
  133. return nyn.daysShort[weekday]
  134. }
  135. // WeekdaysShort returns the locales short weekdays
  136. func (nyn *nyn_UG) WeekdaysShort() []string {
  137. return nyn.daysShort
  138. }
  139. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  140. func (nyn *nyn_UG) WeekdayWide(weekday time.Weekday) string {
  141. return nyn.daysWide[weekday]
  142. }
  143. // WeekdaysWide returns the locales wide weekdays
  144. func (nyn *nyn_UG) WeekdaysWide() []string {
  145. return nyn.daysWide
  146. }
  147. // FmtNumber returns 'num' with digits/precision of 'v' for 'nyn_UG' and handles both Whole and Real numbers based on 'v'
  148. func (nyn *nyn_UG) FmtNumber(num float64, v uint64) string {
  149. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  150. }
  151. // FmtPercent returns 'num' with digits/precision of 'v' for 'nyn_UG' and handles both Whole and Real numbers based on 'v'
  152. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  153. func (nyn *nyn_UG) FmtPercent(num float64, v uint64) string {
  154. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  155. }
  156. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nyn_UG'
  157. func (nyn *nyn_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  158. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  159. symbol := nyn.currencies[currency]
  160. l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3
  161. count := 0
  162. inWhole := v == 0
  163. b := make([]byte, 0, l)
  164. for i := len(s) - 1; i >= 0; i-- {
  165. if s[i] == '.' {
  166. b = append(b, nyn.decimal[0])
  167. inWhole = true
  168. continue
  169. }
  170. if inWhole {
  171. if count == 3 {
  172. b = append(b, nyn.group[0])
  173. count = 1
  174. } else {
  175. count++
  176. }
  177. }
  178. b = append(b, s[i])
  179. }
  180. for j := len(symbol) - 1; j >= 0; j-- {
  181. b = append(b, symbol[j])
  182. }
  183. if num < 0 {
  184. b = append(b, nyn.minus[0])
  185. }
  186. // reverse
  187. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  188. b[i], b[j] = b[j], b[i]
  189. }
  190. if int(v) < 2 {
  191. if v == 0 {
  192. b = append(b, nyn.decimal...)
  193. }
  194. for i := 0; i < 2-int(v); i++ {
  195. b = append(b, '0')
  196. }
  197. }
  198. return string(b)
  199. }
  200. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nyn_UG'
  201. // in accounting notation.
  202. func (nyn *nyn_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  203. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  204. symbol := nyn.currencies[currency]
  205. l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3
  206. count := 0
  207. inWhole := v == 0
  208. b := make([]byte, 0, l)
  209. for i := len(s) - 1; i >= 0; i-- {
  210. if s[i] == '.' {
  211. b = append(b, nyn.decimal[0])
  212. inWhole = true
  213. continue
  214. }
  215. if inWhole {
  216. if count == 3 {
  217. b = append(b, nyn.group[0])
  218. count = 1
  219. } else {
  220. count++
  221. }
  222. }
  223. b = append(b, s[i])
  224. }
  225. if num < 0 {
  226. for j := len(symbol) - 1; j >= 0; j-- {
  227. b = append(b, symbol[j])
  228. }
  229. b = append(b, nyn.minus[0])
  230. } else {
  231. for j := len(symbol) - 1; j >= 0; j-- {
  232. b = append(b, symbol[j])
  233. }
  234. }
  235. // reverse
  236. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  237. b[i], b[j] = b[j], b[i]
  238. }
  239. if int(v) < 2 {
  240. if v == 0 {
  241. b = append(b, nyn.decimal...)
  242. }
  243. for i := 0; i < 2-int(v); i++ {
  244. b = append(b, '0')
  245. }
  246. }
  247. return string(b)
  248. }
  249. // FmtDateShort returns the short date representation of 't' for 'nyn_UG'
  250. func (nyn *nyn_UG) FmtDateShort(t time.Time) string {
  251. b := make([]byte, 0, 32)
  252. if t.Day() < 10 {
  253. b = append(b, '0')
  254. }
  255. b = strconv.AppendInt(b, int64(t.Day()), 10)
  256. b = append(b, []byte{0x2f}...)
  257. if t.Month() < 10 {
  258. b = append(b, '0')
  259. }
  260. b = strconv.AppendInt(b, int64(t.Month()), 10)
  261. b = append(b, []byte{0x2f}...)
  262. b = strconv.AppendInt(b, int64(t.Year()), 10)
  263. return string(b)
  264. }
  265. // FmtDateMedium returns the medium date representation of 't' for 'nyn_UG'
  266. func (nyn *nyn_UG) FmtDateMedium(t time.Time) string {
  267. b := make([]byte, 0, 32)
  268. b = strconv.AppendInt(b, int64(t.Day()), 10)
  269. b = append(b, []byte{0x20}...)
  270. b = append(b, nyn.monthsAbbreviated[t.Month()]...)
  271. b = append(b, []byte{0x20}...)
  272. b = strconv.AppendInt(b, int64(t.Year()), 10)
  273. return string(b)
  274. }
  275. // FmtDateLong returns the long date representation of 't' for 'nyn_UG'
  276. func (nyn *nyn_UG) FmtDateLong(t time.Time) string {
  277. b := make([]byte, 0, 32)
  278. b = strconv.AppendInt(b, int64(t.Day()), 10)
  279. b = append(b, []byte{0x20}...)
  280. b = append(b, nyn.monthsWide[t.Month()]...)
  281. b = append(b, []byte{0x20}...)
  282. b = strconv.AppendInt(b, int64(t.Year()), 10)
  283. return string(b)
  284. }
  285. // FmtDateFull returns the full date representation of 't' for 'nyn_UG'
  286. func (nyn *nyn_UG) FmtDateFull(t time.Time) string {
  287. b := make([]byte, 0, 32)
  288. b = append(b, nyn.daysWide[t.Weekday()]...)
  289. b = append(b, []byte{0x2c, 0x20}...)
  290. b = strconv.AppendInt(b, int64(t.Day()), 10)
  291. b = append(b, []byte{0x20}...)
  292. b = append(b, nyn.monthsWide[t.Month()]...)
  293. b = append(b, []byte{0x20}...)
  294. b = strconv.AppendInt(b, int64(t.Year()), 10)
  295. return string(b)
  296. }
  297. // FmtTimeShort returns the short time representation of 't' for 'nyn_UG'
  298. func (nyn *nyn_UG) FmtTimeShort(t time.Time) string {
  299. b := make([]byte, 0, 32)
  300. if t.Hour() < 10 {
  301. b = append(b, '0')
  302. }
  303. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  304. b = append(b, nyn.timeSeparator...)
  305. if t.Minute() < 10 {
  306. b = append(b, '0')
  307. }
  308. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  309. return string(b)
  310. }
  311. // FmtTimeMedium returns the medium time representation of 't' for 'nyn_UG'
  312. func (nyn *nyn_UG) FmtTimeMedium(t time.Time) string {
  313. b := make([]byte, 0, 32)
  314. if t.Hour() < 10 {
  315. b = append(b, '0')
  316. }
  317. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  318. b = append(b, nyn.timeSeparator...)
  319. if t.Minute() < 10 {
  320. b = append(b, '0')
  321. }
  322. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  323. b = append(b, nyn.timeSeparator...)
  324. if t.Second() < 10 {
  325. b = append(b, '0')
  326. }
  327. b = strconv.AppendInt(b, int64(t.Second()), 10)
  328. return string(b)
  329. }
  330. // FmtTimeLong returns the long time representation of 't' for 'nyn_UG'
  331. func (nyn *nyn_UG) FmtTimeLong(t time.Time) string {
  332. b := make([]byte, 0, 32)
  333. if t.Hour() < 10 {
  334. b = append(b, '0')
  335. }
  336. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  337. b = append(b, nyn.timeSeparator...)
  338. if t.Minute() < 10 {
  339. b = append(b, '0')
  340. }
  341. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  342. b = append(b, nyn.timeSeparator...)
  343. if t.Second() < 10 {
  344. b = append(b, '0')
  345. }
  346. b = strconv.AppendInt(b, int64(t.Second()), 10)
  347. b = append(b, []byte{0x20}...)
  348. tz, _ := t.Zone()
  349. b = append(b, tz...)
  350. return string(b)
  351. }
  352. // FmtTimeFull returns the full time representation of 't' for 'nyn_UG'
  353. func (nyn *nyn_UG) FmtTimeFull(t time.Time) string {
  354. b := make([]byte, 0, 32)
  355. if t.Hour() < 10 {
  356. b = append(b, '0')
  357. }
  358. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  359. b = append(b, nyn.timeSeparator...)
  360. if t.Minute() < 10 {
  361. b = append(b, '0')
  362. }
  363. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  364. b = append(b, nyn.timeSeparator...)
  365. if t.Second() < 10 {
  366. b = append(b, '0')
  367. }
  368. b = strconv.AppendInt(b, int64(t.Second()), 10)
  369. b = append(b, []byte{0x20}...)
  370. tz, _ := t.Zone()
  371. if btz, ok := nyn.timezones[tz]; ok {
  372. b = append(b, btz...)
  373. } else {
  374. b = append(b, tz...)
  375. }
  376. return string(b)
  377. }