localize.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import { buildLocalizeFn } from "../../_lib/buildLocalizeFn.js";
  2. const eraValues = {
  3. narrow: ["M.A", "M."],
  4. abbreviated: ["M.A", "M."],
  5. wide: ["Miloddan Avvalgi", "Milodiy"],
  6. };
  7. const quarterValues = {
  8. narrow: ["1", "2", "3", "4"],
  9. abbreviated: ["CH.1", "CH.2", "CH.3", "CH.4"],
  10. wide: ["1-chi chorak", "2-chi chorak", "3-chi chorak", "4-chi chorak"],
  11. };
  12. // Note: in English, the names of days of the week and months are capitalized.
  13. // If you are making a new locale based on this one, check if the same is true for the language you're working on.
  14. // Generally, formatted dates should look like they are in the middle of a sentence,
  15. // e.g. in Spanish language the weekdays and months should be in the lowercase.
  16. const monthValues = {
  17. narrow: ["Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"],
  18. abbreviated: [
  19. "Yan",
  20. "Fev",
  21. "Mar",
  22. "Apr",
  23. "May",
  24. "Iyun",
  25. "Iyul",
  26. "Avg",
  27. "Sen",
  28. "Okt",
  29. "Noy",
  30. "Dek",
  31. ],
  32. wide: [
  33. "Yanvar",
  34. "Fevral",
  35. "Mart",
  36. "Aprel",
  37. "May",
  38. "Iyun",
  39. "Iyul",
  40. "Avgust",
  41. "Sentabr",
  42. "Oktabr",
  43. "Noyabr",
  44. "Dekabr",
  45. ],
  46. };
  47. const dayValues = {
  48. narrow: ["Y", "D", "S", "CH", "P", "J", "SH"],
  49. short: ["Ya", "Du", "Se", "Cho", "Pa", "Ju", "Sha"],
  50. abbreviated: ["Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"],
  51. wide: [
  52. "Yakshanba",
  53. "Dushanba",
  54. "Seshanba",
  55. "Chorshanba",
  56. "Payshanba",
  57. "Juma",
  58. "Shanba",
  59. ],
  60. };
  61. const dayPeriodValues = {
  62. narrow: {
  63. am: "a",
  64. pm: "p",
  65. midnight: "y.t",
  66. noon: "p.",
  67. morning: "ertalab",
  68. afternoon: "tushdan keyin",
  69. evening: "kechqurun",
  70. night: "tun",
  71. },
  72. abbreviated: {
  73. am: "AM",
  74. pm: "PM",
  75. midnight: "yarim tun",
  76. noon: "peshin",
  77. morning: "ertalab",
  78. afternoon: "tushdan keyin",
  79. evening: "kechqurun",
  80. night: "tun",
  81. },
  82. wide: {
  83. am: "a.m.",
  84. pm: "p.m.",
  85. midnight: "yarim tun",
  86. noon: "peshin",
  87. morning: "ertalab",
  88. afternoon: "tushdan keyin",
  89. evening: "kechqurun",
  90. night: "tun",
  91. },
  92. };
  93. const formattingDayPeriodValues = {
  94. narrow: {
  95. am: "a",
  96. pm: "p",
  97. midnight: "y.t",
  98. noon: "p.",
  99. morning: "ertalab",
  100. afternoon: "tushdan keyin",
  101. evening: "kechqurun",
  102. night: "tun",
  103. },
  104. abbreviated: {
  105. am: "AM",
  106. pm: "PM",
  107. midnight: "yarim tun",
  108. noon: "peshin",
  109. morning: "ertalab",
  110. afternoon: "tushdan keyin",
  111. evening: "kechqurun",
  112. night: "tun",
  113. },
  114. wide: {
  115. am: "a.m.",
  116. pm: "p.m.",
  117. midnight: "yarim tun",
  118. noon: "peshin",
  119. morning: "ertalab",
  120. afternoon: "tushdan keyin",
  121. evening: "kechqurun",
  122. night: "tun",
  123. },
  124. };
  125. const ordinalNumber = (dirtyNumber, _options) => {
  126. return String(dirtyNumber);
  127. };
  128. export const localize = {
  129. ordinalNumber,
  130. era: buildLocalizeFn({
  131. values: eraValues,
  132. defaultWidth: "wide",
  133. }),
  134. quarter: buildLocalizeFn({
  135. values: quarterValues,
  136. defaultWidth: "wide",
  137. argumentCallback: (quarter) => quarter - 1,
  138. }),
  139. month: buildLocalizeFn({
  140. values: monthValues,
  141. defaultWidth: "wide",
  142. }),
  143. day: buildLocalizeFn({
  144. values: dayValues,
  145. defaultWidth: "wide",
  146. }),
  147. dayPeriod: buildLocalizeFn({
  148. values: dayPeriodValues,
  149. defaultWidth: "wide",
  150. formattingValues: formattingDayPeriodValues,
  151. defaultFormattingWidth: "wide",
  152. }),
  153. };