index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function isPluralType(val) {
  7. return val.one !== undefined;
  8. }
  9. var formatDistanceLocale = {
  10. lessThanXSeconds: {
  11. present: {
  12. one: 'manj kot {{count}} sekunda',
  13. two: 'manj kot {{count}} sekundi',
  14. few: 'manj kot {{count}} sekunde',
  15. other: 'manj kot {{count}} sekund'
  16. },
  17. past: {
  18. one: 'manj kot {{count}} sekundo',
  19. two: 'manj kot {{count}} sekundama',
  20. few: 'manj kot {{count}} sekundami',
  21. other: 'manj kot {{count}} sekundami'
  22. },
  23. future: {
  24. one: 'manj kot {{count}} sekundo',
  25. two: 'manj kot {{count}} sekundi',
  26. few: 'manj kot {{count}} sekunde',
  27. other: 'manj kot {{count}} sekund'
  28. }
  29. },
  30. xSeconds: {
  31. present: {
  32. one: '{{count}} sekunda',
  33. two: '{{count}} sekundi',
  34. few: '{{count}} sekunde',
  35. other: '{{count}} sekund'
  36. },
  37. past: {
  38. one: '{{count}} sekundo',
  39. two: '{{count}} sekundama',
  40. few: '{{count}} sekundami',
  41. other: '{{count}} sekundami'
  42. },
  43. future: {
  44. one: '{{count}} sekundo',
  45. two: '{{count}} sekundi',
  46. few: '{{count}} sekunde',
  47. other: '{{count}} sekund'
  48. }
  49. },
  50. halfAMinute: 'pol minute',
  51. lessThanXMinutes: {
  52. present: {
  53. one: 'manj kot {{count}} minuta',
  54. two: 'manj kot {{count}} minuti',
  55. few: 'manj kot {{count}} minute',
  56. other: 'manj kot {{count}} minut'
  57. },
  58. past: {
  59. one: 'manj kot {{count}} minuto',
  60. two: 'manj kot {{count}} minutama',
  61. few: 'manj kot {{count}} minutami',
  62. other: 'manj kot {{count}} minutami'
  63. },
  64. future: {
  65. one: 'manj kot {{count}} minuto',
  66. two: 'manj kot {{count}} minuti',
  67. few: 'manj kot {{count}} minute',
  68. other: 'manj kot {{count}} minut'
  69. }
  70. },
  71. xMinutes: {
  72. present: {
  73. one: '{{count}} minuta',
  74. two: '{{count}} minuti',
  75. few: '{{count}} minute',
  76. other: '{{count}} minut'
  77. },
  78. past: {
  79. one: '{{count}} minuto',
  80. two: '{{count}} minutama',
  81. few: '{{count}} minutami',
  82. other: '{{count}} minutami'
  83. },
  84. future: {
  85. one: '{{count}} minuto',
  86. two: '{{count}} minuti',
  87. few: '{{count}} minute',
  88. other: '{{count}} minut'
  89. }
  90. },
  91. aboutXHours: {
  92. present: {
  93. one: 'približno {{count}} ura',
  94. two: 'približno {{count}} uri',
  95. few: 'približno {{count}} ure',
  96. other: 'približno {{count}} ur'
  97. },
  98. past: {
  99. one: 'približno {{count}} uro',
  100. two: 'približno {{count}} urama',
  101. few: 'približno {{count}} urami',
  102. other: 'približno {{count}} urami'
  103. },
  104. future: {
  105. one: 'približno {{count}} uro',
  106. two: 'približno {{count}} uri',
  107. few: 'približno {{count}} ure',
  108. other: 'približno {{count}} ur'
  109. }
  110. },
  111. xHours: {
  112. present: {
  113. one: '{{count}} ura',
  114. two: '{{count}} uri',
  115. few: '{{count}} ure',
  116. other: '{{count}} ur'
  117. },
  118. past: {
  119. one: '{{count}} uro',
  120. two: '{{count}} urama',
  121. few: '{{count}} urami',
  122. other: '{{count}} urami'
  123. },
  124. future: {
  125. one: '{{count}} uro',
  126. two: '{{count}} uri',
  127. few: '{{count}} ure',
  128. other: '{{count}} ur'
  129. }
  130. },
  131. xDays: {
  132. present: {
  133. one: '{{count}} dan',
  134. two: '{{count}} dni',
  135. few: '{{count}} dni',
  136. other: '{{count}} dni'
  137. },
  138. past: {
  139. one: '{{count}} dnem',
  140. two: '{{count}} dnevoma',
  141. few: '{{count}} dnevi',
  142. other: '{{count}} dnevi'
  143. },
  144. future: {
  145. one: '{{count}} dan',
  146. two: '{{count}} dni',
  147. few: '{{count}} dni',
  148. other: '{{count}} dni'
  149. }
  150. },
  151. // no tenses for weeks?
  152. aboutXWeeks: {
  153. one: 'približno {{count}} teden',
  154. two: 'približno {{count}} tedna',
  155. few: 'približno {{count}} tedne',
  156. other: 'približno {{count}} tednov'
  157. },
  158. // no tenses for weeks?
  159. xWeeks: {
  160. one: '{{count}} teden',
  161. two: '{{count}} tedna',
  162. few: '{{count}} tedne',
  163. other: '{{count}} tednov'
  164. },
  165. aboutXMonths: {
  166. present: {
  167. one: 'približno {{count}} mesec',
  168. two: 'približno {{count}} meseca',
  169. few: 'približno {{count}} mesece',
  170. other: 'približno {{count}} mesecev'
  171. },
  172. past: {
  173. one: 'približno {{count}} mesecem',
  174. two: 'približno {{count}} mesecema',
  175. few: 'približno {{count}} meseci',
  176. other: 'približno {{count}} meseci'
  177. },
  178. future: {
  179. one: 'približno {{count}} mesec',
  180. two: 'približno {{count}} meseca',
  181. few: 'približno {{count}} mesece',
  182. other: 'približno {{count}} mesecev'
  183. }
  184. },
  185. xMonths: {
  186. present: {
  187. one: '{{count}} mesec',
  188. two: '{{count}} meseca',
  189. few: '{{count}} meseci',
  190. other: '{{count}} mesecev'
  191. },
  192. past: {
  193. one: '{{count}} mesecem',
  194. two: '{{count}} mesecema',
  195. few: '{{count}} meseci',
  196. other: '{{count}} meseci'
  197. },
  198. future: {
  199. one: '{{count}} mesec',
  200. two: '{{count}} meseca',
  201. few: '{{count}} mesece',
  202. other: '{{count}} mesecev'
  203. }
  204. },
  205. aboutXYears: {
  206. present: {
  207. one: 'približno {{count}} leto',
  208. two: 'približno {{count}} leti',
  209. few: 'približno {{count}} leta',
  210. other: 'približno {{count}} let'
  211. },
  212. past: {
  213. one: 'približno {{count}} letom',
  214. two: 'približno {{count}} letoma',
  215. few: 'približno {{count}} leti',
  216. other: 'približno {{count}} leti'
  217. },
  218. future: {
  219. one: 'približno {{count}} leto',
  220. two: 'približno {{count}} leti',
  221. few: 'približno {{count}} leta',
  222. other: 'približno {{count}} let'
  223. }
  224. },
  225. xYears: {
  226. present: {
  227. one: '{{count}} leto',
  228. two: '{{count}} leti',
  229. few: '{{count}} leta',
  230. other: '{{count}} let'
  231. },
  232. past: {
  233. one: '{{count}} letom',
  234. two: '{{count}} letoma',
  235. few: '{{count}} leti',
  236. other: '{{count}} leti'
  237. },
  238. future: {
  239. one: '{{count}} leto',
  240. two: '{{count}} leti',
  241. few: '{{count}} leta',
  242. other: '{{count}} let'
  243. }
  244. },
  245. overXYears: {
  246. present: {
  247. one: 'več kot {{count}} leto',
  248. two: 'več kot {{count}} leti',
  249. few: 'več kot {{count}} leta',
  250. other: 'več kot {{count}} let'
  251. },
  252. past: {
  253. one: 'več kot {{count}} letom',
  254. two: 'več kot {{count}} letoma',
  255. few: 'več kot {{count}} leti',
  256. other: 'več kot {{count}} leti'
  257. },
  258. future: {
  259. one: 'več kot {{count}} leto',
  260. two: 'več kot {{count}} leti',
  261. few: 'več kot {{count}} leta',
  262. other: 'več kot {{count}} let'
  263. }
  264. },
  265. almostXYears: {
  266. present: {
  267. one: 'skoraj {{count}} leto',
  268. two: 'skoraj {{count}} leti',
  269. few: 'skoraj {{count}} leta',
  270. other: 'skoraj {{count}} let'
  271. },
  272. past: {
  273. one: 'skoraj {{count}} letom',
  274. two: 'skoraj {{count}} letoma',
  275. few: 'skoraj {{count}} leti',
  276. other: 'skoraj {{count}} leti'
  277. },
  278. future: {
  279. one: 'skoraj {{count}} leto',
  280. two: 'skoraj {{count}} leti',
  281. few: 'skoraj {{count}} leta',
  282. other: 'skoraj {{count}} let'
  283. }
  284. }
  285. };
  286. function getFormFromCount(count) {
  287. switch (count % 100) {
  288. case 1:
  289. return 'one';
  290. case 2:
  291. return 'two';
  292. case 3:
  293. case 4:
  294. return 'few';
  295. default:
  296. return 'other';
  297. }
  298. }
  299. var formatDistance = function formatDistance(token, count, options) {
  300. var result = '';
  301. var tense = 'present';
  302. if (options !== null && options !== void 0 && options.addSuffix) {
  303. if (options.comparison && options.comparison > 0) {
  304. tense = 'future';
  305. result = 'čez ';
  306. } else {
  307. tense = 'past';
  308. result = 'pred ';
  309. }
  310. }
  311. var tokenValue = formatDistanceLocale[token];
  312. if (typeof tokenValue === 'string') {
  313. result += tokenValue;
  314. } else {
  315. var form = getFormFromCount(count);
  316. if (isPluralType(tokenValue)) {
  317. result += tokenValue[form].replace('{{count}}', String(count));
  318. } else {
  319. result += tokenValue[tense][form].replace('{{count}}', String(count));
  320. }
  321. }
  322. return result;
  323. };
  324. var _default = formatDistance;
  325. exports.default = _default;
  326. module.exports = exports.default;