sr.js 4.1 KB

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