sr.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Serbian [sr]
  2. import dayjs from '../index';
  3. var translator = {
  4. words: {
  5. m: ['jedan minut', 'jednog minuta'],
  6. mm: ['%d minut', '%d minuta', '%d minuta'],
  7. h: ['jedan sat', 'jednog sata'],
  8. hh: ['%d sat', '%d sata', '%d sati'],
  9. d: ['jedan dan', 'jednog dana'],
  10. dd: ['%d dan', '%d dana', '%d dana'],
  11. M: ['jedan mesec', 'jednog meseca'],
  12. MM: ['%d mesec', '%d meseca', '%d meseci'],
  13. y: ['jednu godinu', 'jedne godine'],
  14. yy: ['%d godinu', '%d godine', '%d godina']
  15. },
  16. correctGrammarCase: function correctGrammarCase(number, wordKey) {
  17. if (number % 10 >= 1 && number % 10 <= 4 && (number % 100 < 10 || number % 100 >= 20)) {
  18. return number % 10 === 1 ? wordKey[0] : wordKey[1];
  19. }
  20. return wordKey[2];
  21. },
  22. relativeTimeFormatter: function relativeTimeFormatter(number, withoutSuffix, key, isFuture) {
  23. var wordKey = translator.words[key];
  24. if (key.length === 1) {
  25. // Nominativ
  26. if (key === 'y' && withoutSuffix) return 'jedna godina';
  27. return isFuture || withoutSuffix ? wordKey[0] : wordKey[1];
  28. }
  29. var word = translator.correctGrammarCase(number, wordKey); // Nominativ
  30. if (key === 'yy' && withoutSuffix && word === '%d godinu') return number + " godina";
  31. return word.replace('%d', number);
  32. }
  33. };
  34. var locale = {
  35. name: 'sr',
  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. months: 'Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar'.split('_'),
  40. monthsShort: 'Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.'.split('_'),
  41. weekStart: 1,
  42. relativeTime: {
  43. future: 'za %s',
  44. past: 'pre %s',
  45. s: 'nekoliko sekundi',
  46. m: translator.relativeTimeFormatter,
  47. mm: translator.relativeTimeFormatter,
  48. h: translator.relativeTimeFormatter,
  49. hh: translator.relativeTimeFormatter,
  50. d: translator.relativeTimeFormatter,
  51. dd: translator.relativeTimeFormatter,
  52. M: translator.relativeTimeFormatter,
  53. MM: translator.relativeTimeFormatter,
  54. y: translator.relativeTimeFormatter,
  55. yy: translator.relativeTimeFormatter
  56. },
  57. ordinal: function ordinal(n) {
  58. return n + ".";
  59. },
  60. formats: {
  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. };
  69. dayjs.locale(locale, null, true);
  70. export default locale;