locale.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. Percent string
  32. }
  33. // Currency contains the Currency related formatting information
  34. type Currency struct {
  35. Currency string
  36. DisplayName string
  37. Symbol string
  38. }
  39. // Calendar contains the DateTime formatting information
  40. type Calendar struct {
  41. Formats CalendarFormats
  42. FormatNames CalendarFormatNames
  43. }
  44. // CalendarFormats contains the DateTime format information
  45. type CalendarFormats struct {
  46. Date CalendarDateFormat
  47. Time CalendarDateFormat
  48. DateTime CalendarDateFormat
  49. }
  50. // CalendarDateFormat contains the DateTime length format information
  51. type CalendarDateFormat struct{ Full, Long, Medium, Short string }
  52. // CalendarFormatNames contains the DateTime name information
  53. type CalendarFormatNames struct {
  54. Months CalendarMonthFormatNames
  55. Days CalendarDayFormatNames
  56. Periods CalendarPeriodFormatNames
  57. }
  58. // CalendarMonthFormatNames contains the DateTime month formats information
  59. type CalendarMonthFormatNames struct {
  60. Abbreviated CalendarMonthFormatNameValue
  61. Narrow CalendarMonthFormatNameValue
  62. Short CalendarMonthFormatNameValue
  63. Wide CalendarMonthFormatNameValue
  64. }
  65. // CalendarMonthFormatNameValue contains the DateTime month name information
  66. type CalendarMonthFormatNameValue map[time.Month]string
  67. // CalendarDayFormatNames contains the DateTime month name information
  68. type CalendarDayFormatNames struct {
  69. Abbreviated CalendarDayFormatNameValue
  70. Narrow CalendarDayFormatNameValue
  71. Short CalendarDayFormatNameValue
  72. Wide CalendarDayFormatNameValue
  73. }
  74. // CalendarDayFormatNameValue contains the DateTime day name information
  75. type CalendarDayFormatNameValue map[time.Weekday]string
  76. // CalendarPeriodFormatNames contains the DateTime period information
  77. type CalendarPeriodFormatNames struct {
  78. Abbreviated CalendarPeriodFormatNameValue
  79. Narrow CalendarPeriodFormatNameValue
  80. Short CalendarPeriodFormatNameValue
  81. Wide CalendarPeriodFormatNameValue
  82. }
  83. // CalendarPeriodFormatNameValue contains the DateTime period name information
  84. type CalendarPeriodFormatNameValue map[string]string