uk.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // moment.js locale configuration
  2. // locale : ukrainian (uk)
  3. // author : zemlanin : https://github.com/zemlanin
  4. // Author : Menelion Elensúle : https://github.com/Oire
  5. (function (factory) {
  6. if (typeof define === 'function' && define.amd) {
  7. define(['moment'], factory); // AMD
  8. } else if (typeof exports === 'object') {
  9. module.exports = factory(require('../moment')); // Node
  10. } else {
  11. factory((typeof global !== 'undefined' ? global : this).moment); // node or other global
  12. }
  13. }(function (moment) {
  14. function plural(word, num) {
  15. var forms = word.split('_');
  16. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  17. }
  18. function relativeTimeWithPlural(number, withoutSuffix, key) {
  19. var format = {
  20. 'mm': 'хвилина_хвилини_хвилин',
  21. 'hh': 'година_години_годин',
  22. 'dd': 'день_дні_днів',
  23. 'MM': 'місяць_місяці_місяців',
  24. 'yy': 'рік_роки_років'
  25. };
  26. if (key === 'm') {
  27. return withoutSuffix ? 'хвилина' : 'хвилину';
  28. }
  29. else if (key === 'h') {
  30. return withoutSuffix ? 'година' : 'годину';
  31. }
  32. else {
  33. return number + ' ' + plural(format[key], +number);
  34. }
  35. }
  36. function monthsCaseReplace(m, format) {
  37. var months = {
  38. 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
  39. 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
  40. },
  41. nounCase = (/D[oD]? *MMMM?/).test(format) ?
  42. 'accusative' :
  43. 'nominative';
  44. return months[nounCase][m.month()];
  45. }
  46. function weekdaysCaseReplace(m, format) {
  47. var weekdays = {
  48. 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
  49. 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
  50. 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
  51. },
  52. nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
  53. 'accusative' :
  54. ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
  55. 'genitive' :
  56. 'nominative');
  57. return weekdays[nounCase][m.day()];
  58. }
  59. function processHoursFunction(str) {
  60. return function () {
  61. return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
  62. };
  63. }
  64. return moment.defineLocale('uk', {
  65. months : monthsCaseReplace,
  66. monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
  67. weekdays : weekdaysCaseReplace,
  68. weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  69. weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  70. longDateFormat : {
  71. LT : 'HH:mm',
  72. LTS : 'LT:ss',
  73. L : 'DD.MM.YYYY',
  74. LL : 'D MMMM YYYY р.',
  75. LLL : 'D MMMM YYYY р., LT',
  76. LLLL : 'dddd, D MMMM YYYY р., LT'
  77. },
  78. calendar : {
  79. sameDay: processHoursFunction('[Сьогодні '),
  80. nextDay: processHoursFunction('[Завтра '),
  81. lastDay: processHoursFunction('[Вчора '),
  82. nextWeek: processHoursFunction('[У] dddd ['),
  83. lastWeek: function () {
  84. switch (this.day()) {
  85. case 0:
  86. case 3:
  87. case 5:
  88. case 6:
  89. return processHoursFunction('[Минулої] dddd [').call(this);
  90. case 1:
  91. case 2:
  92. case 4:
  93. return processHoursFunction('[Минулого] dddd [').call(this);
  94. }
  95. },
  96. sameElse: 'L'
  97. },
  98. relativeTime : {
  99. future : 'за %s',
  100. past : '%s тому',
  101. s : 'декілька секунд',
  102. m : relativeTimeWithPlural,
  103. mm : relativeTimeWithPlural,
  104. h : 'годину',
  105. hh : relativeTimeWithPlural,
  106. d : 'день',
  107. dd : relativeTimeWithPlural,
  108. M : 'місяць',
  109. MM : relativeTimeWithPlural,
  110. y : 'рік',
  111. yy : relativeTimeWithPlural
  112. },
  113. // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
  114. meridiemParse: /ночі|ранку|дня|вечора/,
  115. isPM: function (input) {
  116. return /^(дня|вечора)$/.test(input);
  117. },
  118. meridiem : function (hour, minute, isLower) {
  119. if (hour < 4) {
  120. return 'ночі';
  121. } else if (hour < 12) {
  122. return 'ранку';
  123. } else if (hour < 17) {
  124. return 'дня';
  125. } else {
  126. return 'вечора';
  127. }
  128. },
  129. ordinalParse: /\d{1,2}-(й|го)/,
  130. ordinal: function (number, period) {
  131. switch (period) {
  132. case 'M':
  133. case 'd':
  134. case 'DDD':
  135. case 'w':
  136. case 'W':
  137. return number + '-й';
  138. case 'D':
  139. return number + '-го';
  140. default:
  141. return number;
  142. }
  143. },
  144. week : {
  145. dow : 1, // Monday is the first day of the week.
  146. doy : 7 // The week that contains Jan 1st is the first week of the year.
  147. }
  148. });
  149. }));