locale.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package ut
  2. import "time"
  3. // Locale contains all of the locale info needed for translation,
  4. // number and date formatting
  5. type Locale struct {
  6. Locale string
  7. Number Number
  8. Calendar Calendar
  9. PluralRule string
  10. }
  11. // Number contains all of the number related formatting information
  12. type Number struct {
  13. Symbols Symbols
  14. Formats NumberFormats
  15. Currencies CurrencyFormatValue
  16. }
  17. // CurrencyFormatValue contains the currency information
  18. type CurrencyFormatValue map[string]Currency
  19. // Symbols contains the number symbols related to formatting
  20. type Symbols struct {
  21. Decimal string
  22. Group string
  23. Negative string
  24. Percent string
  25. PerMille string
  26. }
  27. // NumberFormats contains the number format information related to formatting
  28. type NumberFormats struct {
  29. Decimal string
  30. Currency string
  31. CurrencyAccounting string
  32. Percent string
  33. }
  34. // Currency contains the Currency related formatting information
  35. type Currency struct {
  36. Currency string
  37. DisplayName string
  38. Symbol string
  39. }
  40. // Calendar contains the DateTime formatting information
  41. type Calendar struct {
  42. Formats CalendarFormats
  43. FormatNames CalendarFormatNames
  44. }
  45. // CalendarFormats contains the DateTime format information
  46. type CalendarFormats struct {
  47. DateEra DateEra
  48. Time CalendarDateFormat
  49. DateTime CalendarDateFormat
  50. }
  51. // DateEra contains Era Date Formats as they can vary if AD vs BC
  52. type DateEra struct {
  53. BC CalendarDateFormat
  54. AD CalendarDateFormat
  55. }
  56. // CalendarDateFormat contains the DateTime length format information
  57. type CalendarDateFormat struct{ Full, Long, Medium, Short string }
  58. // CalendarFormatNames contains the DateTime name information
  59. type CalendarFormatNames struct {
  60. Months CalendarMonthFormatNames
  61. Days CalendarDayFormatNames
  62. Periods CalendarPeriodFormatNames
  63. Eras Eras
  64. }
  65. // Eras contains the Era information for both AD and BC
  66. type Eras struct {
  67. AD CalendarEraFormatNames
  68. BC CalendarEraFormatNames
  69. }
  70. // CalendarEraFormatNames contains the Era name information
  71. type CalendarEraFormatNames struct{ Full, Abbrev, Narrow string }
  72. // CalendarMonthFormatNames contains the DateTime month formats information
  73. type CalendarMonthFormatNames struct {
  74. Abbreviated CalendarMonthFormatNameValue
  75. Narrow CalendarMonthFormatNameValue
  76. Short CalendarMonthFormatNameValue
  77. Wide CalendarMonthFormatNameValue
  78. }
  79. // CalendarMonthFormatNameValue contains the DateTime month name information
  80. type CalendarMonthFormatNameValue map[time.Month]string
  81. // CalendarDayFormatNames contains the DateTime month name information
  82. type CalendarDayFormatNames struct {
  83. Abbreviated CalendarDayFormatNameValue
  84. Narrow CalendarDayFormatNameValue
  85. Short CalendarDayFormatNameValue
  86. Wide CalendarDayFormatNameValue
  87. }
  88. // CalendarDayFormatNameValue contains the DateTime day name information
  89. type CalendarDayFormatNameValue map[time.Weekday]string
  90. // CalendarPeriodFormatNames contains the DateTime period information
  91. type CalendarPeriodFormatNames struct {
  92. Abbreviated CalendarPeriodFormatNameValue
  93. Narrow CalendarPeriodFormatNameValue
  94. Short CalendarPeriodFormatNameValue
  95. Wide CalendarPeriodFormatNameValue
  96. }
  97. // CalendarPeriodFormatNameValue contains the DateTime period name information
  98. type CalendarPeriodFormatNameValue map[string]string