localize.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import { buildLocalizeFn } from "../../_lib/buildLocalizeFn.js";
  2. // https://www.unicode.org/cldr/charts/32/summary/sk.html#1772
  3. const eraValues = {
  4. narrow: ["pred Kr.", "po Kr."],
  5. abbreviated: ["pred Kr.", "po Kr."],
  6. wide: ["pred Kristom", "po Kristovi"],
  7. };
  8. // https://www.unicode.org/cldr/charts/32/summary/sk.html#1780
  9. const quarterValues = {
  10. narrow: ["1", "2", "3", "4"],
  11. abbreviated: ["Q1", "Q2", "Q3", "Q4"],
  12. wide: ["1. štvrťrok", "2. štvrťrok", "3. štvrťrok", "4. štvrťrok"],
  13. };
  14. // https://www.unicode.org/cldr/charts/32/summary/sk.html#1804
  15. const monthValues = {
  16. narrow: ["j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"],
  17. abbreviated: [
  18. "jan",
  19. "feb",
  20. "mar",
  21. "apr",
  22. "máj",
  23. "jún",
  24. "júl",
  25. "aug",
  26. "sep",
  27. "okt",
  28. "nov",
  29. "dec",
  30. ],
  31. wide: [
  32. "január",
  33. "február",
  34. "marec",
  35. "apríl",
  36. "máj",
  37. "jún",
  38. "júl",
  39. "august",
  40. "september",
  41. "október",
  42. "november",
  43. "december",
  44. ],
  45. };
  46. const formattingMonthValues = {
  47. narrow: ["j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"],
  48. abbreviated: [
  49. "jan",
  50. "feb",
  51. "mar",
  52. "apr",
  53. "máj",
  54. "jún",
  55. "júl",
  56. "aug",
  57. "sep",
  58. "okt",
  59. "nov",
  60. "dec",
  61. ],
  62. wide: [
  63. "januára",
  64. "februára",
  65. "marca",
  66. "apríla",
  67. "mája",
  68. "júna",
  69. "júla",
  70. "augusta",
  71. "septembra",
  72. "októbra",
  73. "novembra",
  74. "decembra",
  75. ],
  76. };
  77. // https://www.unicode.org/cldr/charts/32/summary/sk.html#1876
  78. const dayValues = {
  79. narrow: ["n", "p", "u", "s", "š", "p", "s"],
  80. short: ["ne", "po", "ut", "st", "št", "pi", "so"],
  81. abbreviated: ["ne", "po", "ut", "st", "št", "pi", "so"],
  82. wide: [
  83. "nedeľa",
  84. "pondelok",
  85. "utorok",
  86. "streda",
  87. "štvrtok",
  88. "piatok",
  89. "sobota",
  90. ],
  91. };
  92. // https://www.unicode.org/cldr/charts/32/summary/sk.html#1932
  93. const dayPeriodValues = {
  94. narrow: {
  95. am: "AM",
  96. pm: "PM",
  97. midnight: "poln.",
  98. noon: "pol.",
  99. morning: "ráno",
  100. afternoon: "pop.",
  101. evening: "več.",
  102. night: "noc",
  103. },
  104. abbreviated: {
  105. am: "AM",
  106. pm: "PM",
  107. midnight: "poln.",
  108. noon: "pol.",
  109. morning: "ráno",
  110. afternoon: "popol.",
  111. evening: "večer",
  112. night: "noc",
  113. },
  114. wide: {
  115. am: "AM",
  116. pm: "PM",
  117. midnight: "polnoc",
  118. noon: "poludnie",
  119. morning: "ráno",
  120. afternoon: "popoludnie",
  121. evening: "večer",
  122. night: "noc",
  123. },
  124. };
  125. const formattingDayPeriodValues = {
  126. narrow: {
  127. am: "AM",
  128. pm: "PM",
  129. midnight: "o poln.",
  130. noon: "nap.",
  131. morning: "ráno",
  132. afternoon: "pop.",
  133. evening: "več.",
  134. night: "v n.",
  135. },
  136. abbreviated: {
  137. am: "AM",
  138. pm: "PM",
  139. midnight: "o poln.",
  140. noon: "napol.",
  141. morning: "ráno",
  142. afternoon: "popol.",
  143. evening: "večer",
  144. night: "v noci",
  145. },
  146. wide: {
  147. am: "AM",
  148. pm: "PM",
  149. midnight: "o polnoci",
  150. noon: "napoludnie",
  151. morning: "ráno",
  152. afternoon: "popoludní",
  153. evening: "večer",
  154. night: "v noci",
  155. },
  156. };
  157. const ordinalNumber = (dirtyNumber, _options) => {
  158. const number = Number(dirtyNumber);
  159. return number + ".";
  160. };
  161. export const localize = {
  162. ordinalNumber,
  163. era: buildLocalizeFn({
  164. values: eraValues,
  165. defaultWidth: "wide",
  166. }),
  167. quarter: buildLocalizeFn({
  168. values: quarterValues,
  169. defaultWidth: "wide",
  170. argumentCallback: (quarter) => quarter - 1,
  171. }),
  172. month: buildLocalizeFn({
  173. values: monthValues,
  174. defaultWidth: "wide",
  175. formattingValues: formattingMonthValues,
  176. defaultFormattingWidth: "wide",
  177. }),
  178. day: buildLocalizeFn({
  179. values: dayValues,
  180. defaultWidth: "wide",
  181. }),
  182. dayPeriod: buildLocalizeFn({
  183. values: dayPeriodValues,
  184. defaultWidth: "wide",
  185. formattingValues: formattingDayPeriodValues,
  186. defaultFormattingWidth: "wide",
  187. }),
  188. };