index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var formatDistanceLocale = {
  7. lessThanXSeconds: {
  8. one: 'dưới 1 giây',
  9. other: 'dưới {{count}} giây'
  10. },
  11. xSeconds: {
  12. one: '1 giây',
  13. other: '{{count}} giây'
  14. },
  15. halfAMinute: 'nửa phút',
  16. lessThanXMinutes: {
  17. one: 'dưới 1 phút',
  18. other: 'dưới {{count}} phút'
  19. },
  20. xMinutes: {
  21. one: '1 phút',
  22. other: '{{count}} phút'
  23. },
  24. aboutXHours: {
  25. one: 'khoảng 1 giờ',
  26. other: 'khoảng {{count}} giờ'
  27. },
  28. xHours: {
  29. one: '1 giờ',
  30. other: '{{count}} giờ'
  31. },
  32. xDays: {
  33. one: '1 ngày',
  34. other: '{{count}} ngày'
  35. },
  36. aboutXWeeks: {
  37. one: 'khoảng 1 tuần',
  38. other: 'khoảng {{count}} tuần'
  39. },
  40. xWeeks: {
  41. one: '1 tuần',
  42. other: '{{count}} tuần'
  43. },
  44. aboutXMonths: {
  45. one: 'khoảng 1 tháng',
  46. other: 'khoảng {{count}} tháng'
  47. },
  48. xMonths: {
  49. one: '1 tháng',
  50. other: '{{count}} tháng'
  51. },
  52. aboutXYears: {
  53. one: 'khoảng 1 năm',
  54. other: 'khoảng {{count}} năm'
  55. },
  56. xYears: {
  57. one: '1 năm',
  58. other: '{{count}} năm'
  59. },
  60. overXYears: {
  61. one: 'hơn 1 năm',
  62. other: 'hơn {{count}} năm'
  63. },
  64. almostXYears: {
  65. one: 'gần 1 năm',
  66. other: 'gần {{count}} năm'
  67. }
  68. };
  69. var formatDistance = function formatDistance(token, count, options) {
  70. var result;
  71. var tokenValue = formatDistanceLocale[token];
  72. if (typeof tokenValue === 'string') {
  73. result = tokenValue;
  74. } else if (count === 1) {
  75. result = tokenValue.one;
  76. } else {
  77. result = tokenValue.other.replace('{{count}}', String(count));
  78. }
  79. if (options !== null && options !== void 0 && options.addSuffix) {
  80. if (options.comparison && options.comparison > 0) {
  81. return result + ' nữa';
  82. } else {
  83. return result + ' trước';
  84. }
  85. }
  86. return result;
  87. };
  88. var _default = formatDistance;
  89. exports.default = _default;
  90. module.exports = exports.default;