locale.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. Date CalendarDateFormat
  48. Time CalendarDateFormat
  49. DateTime CalendarDateFormat
  50. }
  51. // CalendarDateFormat contains the DateTime length format information
  52. type CalendarDateFormat struct{ Full, Long, Medium, Short string }
  53. // CalendarFormatNames contains the DateTime name information
  54. type CalendarFormatNames struct {
  55. Months CalendarMonthFormatNames
  56. Days CalendarDayFormatNames
  57. Periods CalendarPeriodFormatNames
  58. Eras Eras
  59. }
  60. // Eras contains the Era information for both AD and BC
  61. type Eras struct {
  62. AD CalendarEraFormatNames
  63. BC CalendarEraFormatNames
  64. }
  65. // CalendarEraFormatNames contains the Era name information
  66. type CalendarEraFormatNames struct{ Full, Abbrev, Narrow string }
  67. // CalendarMonthFormatNames contains the DateTime month formats information
  68. type CalendarMonthFormatNames struct {
  69. Abbreviated CalendarMonthFormatNameValue
  70. Narrow CalendarMonthFormatNameValue
  71. Short CalendarMonthFormatNameValue
  72. Wide CalendarMonthFormatNameValue
  73. }
  74. // CalendarMonthFormatNameValue contains the DateTime month name information
  75. type CalendarMonthFormatNameValue map[time.Month]string
  76. // CalendarDayFormatNames contains the DateTime month name information
  77. type CalendarDayFormatNames struct {
  78. Abbreviated CalendarDayFormatNameValue
  79. Narrow CalendarDayFormatNameValue
  80. Short CalendarDayFormatNameValue
  81. Wide CalendarDayFormatNameValue
  82. }
  83. // CalendarDayFormatNameValue contains the DateTime day name information
  84. type CalendarDayFormatNameValue map[time.Weekday]string
  85. // CalendarPeriodFormatNames contains the DateTime period information
  86. type CalendarPeriodFormatNames struct {
  87. Abbreviated CalendarPeriodFormatNameValue
  88. Narrow CalendarPeriodFormatNameValue
  89. Short CalendarPeriodFormatNameValue
  90. Wide CalendarPeriodFormatNameValue
  91. }
  92. // CalendarPeriodFormatNameValue contains the DateTime period name information
  93. type CalendarPeriodFormatNameValue map[string]string