index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _index = _interopRequireDefault(require("../../../_lib/buildLocalizeFn/index.js"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. var eraValues = {
  9. narrow: ['BC', 'AC'],
  10. abbreviated: ['紀元前', '西暦'],
  11. wide: ['紀元前', '西暦']
  12. };
  13. var quarterValues = {
  14. narrow: ['1', '2', '3', '4'],
  15. abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
  16. wide: ['第1四半期', '第2四半期', '第3四半期', '第4四半期']
  17. };
  18. var monthValues = {
  19. narrow: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
  20. abbreviated: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  21. wide: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  22. };
  23. var dayValues = {
  24. narrow: ['日', '月', '火', '水', '木', '金', '土'],
  25. short: ['日', '月', '火', '水', '木', '金', '土'],
  26. abbreviated: ['日', '月', '火', '水', '木', '金', '土'],
  27. wide: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日']
  28. };
  29. var dayPeriodValues = {
  30. narrow: {
  31. am: '午前',
  32. pm: '午後',
  33. midnight: '深夜',
  34. noon: '正午',
  35. morning: '朝',
  36. afternoon: '午後',
  37. evening: '夜',
  38. night: '深夜'
  39. },
  40. abbreviated: {
  41. am: '午前',
  42. pm: '午後',
  43. midnight: '深夜',
  44. noon: '正午',
  45. morning: '朝',
  46. afternoon: '午後',
  47. evening: '夜',
  48. night: '深夜'
  49. },
  50. wide: {
  51. am: '午前',
  52. pm: '午後',
  53. midnight: '深夜',
  54. noon: '正午',
  55. morning: '朝',
  56. afternoon: '午後',
  57. evening: '夜',
  58. night: '深夜'
  59. }
  60. };
  61. var formattingDayPeriodValues = {
  62. narrow: {
  63. am: '午前',
  64. pm: '午後',
  65. midnight: '深夜',
  66. noon: '正午',
  67. morning: '朝',
  68. afternoon: '午後',
  69. evening: '夜',
  70. night: '深夜'
  71. },
  72. abbreviated: {
  73. am: '午前',
  74. pm: '午後',
  75. midnight: '深夜',
  76. noon: '正午',
  77. morning: '朝',
  78. afternoon: '午後',
  79. evening: '夜',
  80. night: '深夜'
  81. },
  82. wide: {
  83. am: '午前',
  84. pm: '午後',
  85. midnight: '深夜',
  86. noon: '正午',
  87. morning: '朝',
  88. afternoon: '午後',
  89. evening: '夜',
  90. night: '深夜'
  91. }
  92. };
  93. function ordinalNumber(dirtyNumber, dirtyOptions) {
  94. var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
  95. // if they are different for different grammatical genders,
  96. // use `options.unit`:
  97. //
  98. // var options = dirtyOptions || {}
  99. // var unit = String(options.unit)
  100. //
  101. // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
  102. // 'day', 'hour', 'minute', 'second'
  103. var options = dirtyOptions || {};
  104. var unit = String(options.unit);
  105. if (unit === 'date') {
  106. return number + '日';
  107. }
  108. if (unit === 'year') {
  109. return number + '年';
  110. }
  111. return number;
  112. }
  113. var localize = {
  114. ordinalNumber: ordinalNumber,
  115. era: (0, _index.default)({
  116. values: eraValues,
  117. defaultWidth: 'wide'
  118. }),
  119. quarter: (0, _index.default)({
  120. values: quarterValues,
  121. defaultWidth: 'wide',
  122. argumentCallback: function (quarter) {
  123. return Number(quarter) - 1;
  124. }
  125. }),
  126. month: (0, _index.default)({
  127. values: monthValues,
  128. defaultWidth: 'wide'
  129. }),
  130. day: (0, _index.default)({
  131. values: dayValues,
  132. defaultWidth: 'wide'
  133. }),
  134. dayPeriod: (0, _index.default)({
  135. values: dayPeriodValues,
  136. defaultWidth: 'wide',
  137. formattingValues: formattingDayPeriodValues,
  138. defaultFormattingWidth: 'wide'
  139. })
  140. };
  141. var _default = localize;
  142. exports.default = _default;
  143. module.exports = exports.default;