index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var formatDistanceLocale = {
  7. lessThanXSeconds: {
  8. one: {
  9. standalone: 'manje od 1 sekunde',
  10. withPrepositionAgo: 'manje od 1 sekunde',
  11. withPrepositionIn: 'manje od 1 sekundu'
  12. },
  13. dual: 'manje od {{count}} sekunde',
  14. other: 'manje od {{count}} sekundi'
  15. },
  16. xSeconds: {
  17. one: {
  18. standalone: '1 sekunda',
  19. withPrepositionAgo: '1 sekunde',
  20. withPrepositionIn: '1 sekundu'
  21. },
  22. dual: '{{count}} sekunde',
  23. other: '{{count}} sekundi'
  24. },
  25. halfAMinute: 'pola minute',
  26. lessThanXMinutes: {
  27. one: {
  28. standalone: 'manje od 1 minute',
  29. withPrepositionAgo: 'manje od 1 minute',
  30. withPrepositionIn: 'manje od 1 minutu'
  31. },
  32. dual: 'manje od {{count}} minute',
  33. other: 'manje od {{count}} minuta'
  34. },
  35. xMinutes: {
  36. one: {
  37. standalone: '1 minuta',
  38. withPrepositionAgo: '1 minute',
  39. withPrepositionIn: '1 minutu'
  40. },
  41. dual: '{{count}} minute',
  42. other: '{{count}} minuta'
  43. },
  44. aboutXHours: {
  45. one: {
  46. standalone: 'oko 1 sat',
  47. withPrepositionAgo: 'oko 1 sat',
  48. withPrepositionIn: 'oko 1 sat'
  49. },
  50. dual: 'oko {{count}} sata',
  51. other: 'oko {{count}} sati'
  52. },
  53. xHours: {
  54. one: {
  55. standalone: '1 sat',
  56. withPrepositionAgo: '1 sat',
  57. withPrepositionIn: '1 sat'
  58. },
  59. dual: '{{count}} sata',
  60. other: '{{count}} sati'
  61. },
  62. xDays: {
  63. one: {
  64. standalone: '1 dan',
  65. withPrepositionAgo: '1 dan',
  66. withPrepositionIn: '1 dan'
  67. },
  68. dual: '{{count}} dana',
  69. other: '{{count}} dana'
  70. },
  71. aboutXWeeks: {
  72. one: {
  73. standalone: 'oko 1 nedelju',
  74. withPrepositionAgo: 'oko 1 nedelju',
  75. withPrepositionIn: 'oko 1 nedelju'
  76. },
  77. dual: 'oko {{count}} nedelje',
  78. other: 'oko {{count}} nedelje'
  79. },
  80. xWeeks: {
  81. one: {
  82. standalone: '1 nedelju',
  83. withPrepositionAgo: '1 nedelju',
  84. withPrepositionIn: '1 nedelju'
  85. },
  86. dual: '{{count}} nedelje',
  87. other: '{{count}} nedelje'
  88. },
  89. aboutXMonths: {
  90. one: {
  91. standalone: 'oko 1 mesec',
  92. withPrepositionAgo: 'oko 1 mesec',
  93. withPrepositionIn: 'oko 1 mesec'
  94. },
  95. dual: 'oko {{count}} meseca',
  96. other: 'oko {{count}} meseci'
  97. },
  98. xMonths: {
  99. one: {
  100. standalone: '1 mesec',
  101. withPrepositionAgo: '1 mesec',
  102. withPrepositionIn: '1 mesec'
  103. },
  104. dual: '{{count}} meseca',
  105. other: '{{count}} meseci'
  106. },
  107. aboutXYears: {
  108. one: {
  109. standalone: 'oko 1 godinu',
  110. withPrepositionAgo: 'oko 1 godinu',
  111. withPrepositionIn: 'oko 1 godinu'
  112. },
  113. dual: 'oko {{count}} godine',
  114. other: 'oko {{count}} godina'
  115. },
  116. xYears: {
  117. one: {
  118. standalone: '1 godina',
  119. withPrepositionAgo: '1 godine',
  120. withPrepositionIn: '1 godinu'
  121. },
  122. dual: '{{count}} godine',
  123. other: '{{count}} godina'
  124. },
  125. overXYears: {
  126. one: {
  127. standalone: 'preko 1 godinu',
  128. withPrepositionAgo: 'preko 1 godinu',
  129. withPrepositionIn: 'preko 1 godinu'
  130. },
  131. dual: 'preko {{count}} godine',
  132. other: 'preko {{count}} godina'
  133. },
  134. almostXYears: {
  135. one: {
  136. standalone: 'gotovo 1 godinu',
  137. withPrepositionAgo: 'gotovo 1 godinu',
  138. withPrepositionIn: 'gotovo 1 godinu'
  139. },
  140. dual: 'gotovo {{count}} godine',
  141. other: 'gotovo {{count}} godina'
  142. }
  143. };
  144. var formatDistance = function formatDistance(token, count, options) {
  145. var result;
  146. var tokenValue = formatDistanceLocale[token];
  147. if (typeof tokenValue === 'string') {
  148. result = tokenValue;
  149. } else if (count === 1) {
  150. if (options !== null && options !== void 0 && options.addSuffix) {
  151. if (options.comparison && options.comparison > 0) {
  152. result = tokenValue.one.withPrepositionIn;
  153. } else {
  154. result = tokenValue.one.withPrepositionAgo;
  155. }
  156. } else {
  157. result = tokenValue.one.standalone;
  158. }
  159. } else if (count % 10 > 1 && count % 10 < 5 &&
  160. // if last digit is between 2 and 4
  161. String(count).substr(-2, 1) !== '1' // unless the 2nd to last digit is "1"
  162. ) {
  163. result = tokenValue.dual.replace('{{count}}', String(count));
  164. } else {
  165. result = tokenValue.other.replace('{{count}}', String(count));
  166. }
  167. if (options !== null && options !== void 0 && options.addSuffix) {
  168. if (options.comparison && options.comparison > 0) {
  169. return 'za ' + result;
  170. } else {
  171. return 'pre ' + result;
  172. }
  173. }
  174. return result;
  175. };
  176. var _default = formatDistance;
  177. exports.default = _default;
  178. module.exports = exports.default;