sr.js 3.6 KB

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