localize.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import { buildLocalizeFn } from "../../_lib/buildLocalizeFn.js";
  2. const eraValues = {
  3. narrow: ["aC", "dC"],
  4. abbreviated: ["a.C.", "d.C."],
  5. wide: ["avanti Cristo", "dopo Cristo"],
  6. };
  7. const quarterValues = {
  8. narrow: ["1", "2", "3", "4"],
  9. abbreviated: ["T1", "T2", "T3", "T4"],
  10. wide: ["1º trimestre", "2º trimestre", "3º trimestre", "4º trimestre"],
  11. };
  12. const monthValues = {
  13. narrow: ["G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"],
  14. abbreviated: [
  15. "gen",
  16. "feb",
  17. "mar",
  18. "apr",
  19. "mag",
  20. "giu",
  21. "lug",
  22. "ago",
  23. "set",
  24. "ott",
  25. "nov",
  26. "dic",
  27. ],
  28. wide: [
  29. "gennaio",
  30. "febbraio",
  31. "marzo",
  32. "aprile",
  33. "maggio",
  34. "giugno",
  35. "luglio",
  36. "agosto",
  37. "settembre",
  38. "ottobre",
  39. "novembre",
  40. "dicembre",
  41. ],
  42. };
  43. const dayValues = {
  44. narrow: ["D", "L", "M", "M", "G", "V", "S"],
  45. short: ["dom", "lun", "mar", "mer", "gio", "ven", "sab"],
  46. abbreviated: ["dom", "lun", "mar", "mer", "gio", "ven", "sab"],
  47. wide: [
  48. "domenica",
  49. "lunedì",
  50. "martedì",
  51. "mercoledì",
  52. "giovedì",
  53. "venerdì",
  54. "sabato",
  55. ],
  56. };
  57. const dayPeriodValues = {
  58. narrow: {
  59. am: "m.",
  60. pm: "p.",
  61. midnight: "mezzanotte",
  62. noon: "mezzogiorno",
  63. morning: "mattina",
  64. afternoon: "pomeriggio",
  65. evening: "sera",
  66. night: "notte",
  67. },
  68. abbreviated: {
  69. am: "AM",
  70. pm: "PM",
  71. midnight: "mezzanotte",
  72. noon: "mezzogiorno",
  73. morning: "mattina",
  74. afternoon: "pomeriggio",
  75. evening: "sera",
  76. night: "notte",
  77. },
  78. wide: {
  79. am: "AM",
  80. pm: "PM",
  81. midnight: "mezzanotte",
  82. noon: "mezzogiorno",
  83. morning: "mattina",
  84. afternoon: "pomeriggio",
  85. evening: "sera",
  86. night: "notte",
  87. },
  88. };
  89. const formattingDayPeriodValues = {
  90. narrow: {
  91. am: "m.",
  92. pm: "p.",
  93. midnight: "mezzanotte",
  94. noon: "mezzogiorno",
  95. morning: "di mattina",
  96. afternoon: "del pomeriggio",
  97. evening: "di sera",
  98. night: "di notte",
  99. },
  100. abbreviated: {
  101. am: "AM",
  102. pm: "PM",
  103. midnight: "mezzanotte",
  104. noon: "mezzogiorno",
  105. morning: "di mattina",
  106. afternoon: "del pomeriggio",
  107. evening: "di sera",
  108. night: "di notte",
  109. },
  110. wide: {
  111. am: "AM",
  112. pm: "PM",
  113. midnight: "mezzanotte",
  114. noon: "mezzogiorno",
  115. morning: "di mattina",
  116. afternoon: "del pomeriggio",
  117. evening: "di sera",
  118. night: "di notte",
  119. },
  120. };
  121. const ordinalNumber = (dirtyNumber, _options) => {
  122. const number = Number(dirtyNumber);
  123. return String(number);
  124. };
  125. export const localize = {
  126. ordinalNumber,
  127. era: buildLocalizeFn({
  128. values: eraValues,
  129. defaultWidth: "wide",
  130. }),
  131. quarter: buildLocalizeFn({
  132. values: quarterValues,
  133. defaultWidth: "wide",
  134. argumentCallback: (quarter) => quarter - 1,
  135. }),
  136. month: buildLocalizeFn({
  137. values: monthValues,
  138. defaultWidth: "wide",
  139. }),
  140. day: buildLocalizeFn({
  141. values: dayValues,
  142. defaultWidth: "wide",
  143. }),
  144. dayPeriod: buildLocalizeFn({
  145. values: dayPeriodValues,
  146. defaultWidth: "wide",
  147. formattingValues: formattingDayPeriodValues,
  148. defaultFormattingWidth: "wide",
  149. }),
  150. };