sr.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // moment.js language configuration
  2. // language : Serbian-latin (sr)
  3. // author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
  4. (function (factory) {
  5. if (typeof define === 'function' && define.amd) {
  6. define(['moment'], factory); // AMD
  7. } else if (typeof exports === 'object') {
  8. module.exports = factory(require('../moment')); // Node
  9. } else {
  10. factory(window.moment); // Browser global
  11. }
  12. }(function (moment) {
  13. var translator = {
  14. words: { //Different grammatical cases
  15. m: ['jedan minut', 'jedne minute'],
  16. mm: ['minut', 'minute', 'minuta'],
  17. h: ['jedan sat', 'jednog sata'],
  18. hh: ['sat', 'sata', 'sati'],
  19. dd: ['dan', 'dana', 'dana'],
  20. MM: ['mesec', 'meseca', 'meseci'],
  21. yy: ['godina', 'godine', 'godina']
  22. },
  23. correctGrammaticalCase: function (number, wordKey) {
  24. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  25. },
  26. translate: function (number, withoutSuffix, key) {
  27. var wordKey = translator.words[key];
  28. if (key.length === 1) {
  29. return withoutSuffix ? wordKey[0] : wordKey[1];
  30. } else {
  31. return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
  32. }
  33. }
  34. };
  35. return moment.lang('sr', {
  36. months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
  37. monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
  38. weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
  39. weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
  40. weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
  41. longDateFormat: {
  42. LT: "H:mm",
  43. L: "DD. MM. YYYY",
  44. LL: "D. MMMM YYYY",
  45. LLL: "D. MMMM YYYY LT",
  46. LLLL: "dddd, D. MMMM YYYY LT"
  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. ordinal : '%d.',
  97. week : {
  98. dow : 1, // Monday is the first day of the week.
  99. doy : 7 // The week that contains Jan 1st is the first week of the year.
  100. }
  101. });
  102. }));