index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var formatDistanceLocale = {
  7. lessThanXSeconds: {
  8. one: 'llai na eiliad',
  9. other: 'llai na {{count}} eiliad'
  10. },
  11. xSeconds: {
  12. one: '1 eiliad',
  13. other: '{{count}} eiliad'
  14. },
  15. halfAMinute: 'hanner munud',
  16. lessThanXMinutes: {
  17. one: 'llai na munud',
  18. two: 'llai na 2 funud',
  19. other: 'llai na {{count}} munud'
  20. },
  21. xMinutes: {
  22. one: '1 munud',
  23. two: '2 funud',
  24. other: '{{count}} munud'
  25. },
  26. aboutXHours: {
  27. one: 'tua 1 awr',
  28. other: 'tua {{count}} awr'
  29. },
  30. xHours: {
  31. one: '1 awr',
  32. other: '{{count}} awr'
  33. },
  34. xDays: {
  35. one: '1 diwrnod',
  36. two: '2 ddiwrnod',
  37. other: '{{count}} diwrnod'
  38. },
  39. aboutXWeeks: {
  40. one: 'tua 1 wythnos',
  41. two: 'tua pythefnos',
  42. other: 'tua {{count}} wythnos'
  43. },
  44. xWeeks: {
  45. one: '1 wythnos',
  46. two: 'pythefnos',
  47. other: '{{count}} wythnos'
  48. },
  49. aboutXMonths: {
  50. one: 'tua 1 mis',
  51. two: 'tua 2 fis',
  52. other: 'tua {{count}} mis'
  53. },
  54. xMonths: {
  55. one: '1 mis',
  56. two: '2 fis',
  57. other: '{{count}} mis'
  58. },
  59. aboutXYears: {
  60. one: 'tua 1 flwyddyn',
  61. two: 'tua 2 flynedd',
  62. other: 'tua {{count}} mlynedd'
  63. },
  64. xYears: {
  65. one: '1 flwyddyn',
  66. two: '2 flynedd',
  67. other: '{{count}} mlynedd'
  68. },
  69. overXYears: {
  70. one: 'dros 1 flwyddyn',
  71. two: 'dros 2 flynedd',
  72. other: 'dros {{count}} mlynedd'
  73. },
  74. almostXYears: {
  75. one: 'bron 1 flwyddyn',
  76. two: 'bron 2 flynedd',
  77. other: 'bron {{count}} mlynedd'
  78. }
  79. };
  80. var formatDistance = function formatDistance(token, count, options) {
  81. var result;
  82. var tokenValue = formatDistanceLocale[token];
  83. if (typeof tokenValue === 'string') {
  84. result = tokenValue;
  85. } else if (count === 1) {
  86. result = tokenValue.one;
  87. } else if (count === 2 && !!tokenValue.two) {
  88. result = tokenValue.two;
  89. } else {
  90. result = tokenValue.other.replace('{{count}}', String(count));
  91. }
  92. if (options !== null && options !== void 0 && options.addSuffix) {
  93. if (options.comparison && options.comparison > 0) {
  94. return 'mewn ' + result;
  95. } else {
  96. return result + ' yn ôl';
  97. }
  98. }
  99. return result;
  100. };
  101. var _default = formatDistance;
  102. exports.default = _default;
  103. module.exports = exports.default;