sr.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //! moment.js locale configuration
  2. //! locale : Serbian [sr]
  3. //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
  4. ;(function (global, factory) {
  5. typeof exports === 'object' && typeof module !== 'undefined'
  6. && typeof require === 'function' ? factory(require('../moment')) :
  7. typeof define === 'function' && define.amd ? define(['../moment'], factory) :
  8. factory(global.moment)
  9. }(this, (function (moment) { 'use strict';
  10. var translator = {
  11. words: { //Different grammatical cases
  12. m: ['jedan minut', 'jedne minute'],
  13. mm: ['minut', 'minute', 'minuta'],
  14. h: ['jedan sat', 'jednog sata'],
  15. hh: ['sat', 'sata', 'sati'],
  16. dd: ['dan', 'dana', 'dana'],
  17. MM: ['mesec', 'meseca', 'meseci'],
  18. yy: ['godina', 'godine', 'godina']
  19. },
  20. correctGrammaticalCase: function (number, wordKey) {
  21. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  22. },
  23. translate: function (number, withoutSuffix, key) {
  24. var wordKey = translator.words[key];
  25. if (key.length === 1) {
  26. return withoutSuffix ? wordKey[0] : wordKey[1];
  27. } else {
  28. return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
  29. }
  30. }
  31. };
  32. var sr = moment.defineLocale('sr', {
  33. months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
  34. monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
  35. monthsParseExact: true,
  36. weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
  37. weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
  38. weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
  39. weekdaysParseExact : true,
  40. longDateFormat: {
  41. LT: 'H:mm',
  42. LTS : 'H:mm:ss',
  43. L: 'DD.MM.YYYY',
  44. LL: 'D. MMMM YYYY',
  45. LLL: 'D. MMMM YYYY H:mm',
  46. LLLL: 'dddd, D. MMMM YYYY H:mm'
  47. },
  48. calendar: {
  49. sameDay: '[danas u] LT',
  50. nextDay: '[sutra u] LT',
  51. nextWeek: function () {
  52. switch (this.day()) {
  53. case 0:
  54. return '[u] [nedelju] [u] LT';
  55. case 3:
  56. return '[u] [sredu] [u] LT';
  57. case 6:
  58. return '[u] [subotu] [u] LT';
  59. case 1:
  60. case 2:
  61. case 4:
  62. case 5:
  63. return '[u] dddd [u] LT';
  64. }
  65. },
  66. lastDay : '[juče u] LT',
  67. lastWeek : function () {
  68. var lastWeekDays = [
  69. '[prošle] [nedelje] [u] LT',
  70. '[prošlog] [ponedeljka] [u] LT',
  71. '[prošlog] [utorka] [u] LT',
  72. '[prošle] [srede] [u] LT',
  73. '[prošlog] [četvrtka] [u] LT',
  74. '[prošlog] [petka] [u] LT',
  75. '[prošle] [subote] [u] LT'
  76. ];
  77. return lastWeekDays[this.day()];
  78. },
  79. sameElse : 'L'
  80. },
  81. relativeTime : {
  82. future : 'za %s',
  83. past : 'pre %s',
  84. s : 'nekoliko sekundi',
  85. m : translator.translate,
  86. mm : translator.translate,
  87. h : translator.translate,
  88. hh : translator.translate,
  89. d : 'dan',
  90. dd : translator.translate,
  91. M : 'mesec',
  92. MM : translator.translate,
  93. y : 'godinu',
  94. yy : translator.translate
  95. },
  96. dayOfMonthOrdinalParse: /\d{1,2}\./,
  97. ordinal : '%d.',
  98. week : {
  99. dow : 1, // Monday is the first day of the week.
  100. doy : 7 // The week that contains Jan 1st is the first week of the year.
  101. }
  102. });
  103. return sr;
  104. })));