pl.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // moment.js locale configuration
  2. // locale : polish (pl)
  3. // author : Rafal Hirsz : https://github.com/evoL
  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((typeof global !== 'undefined' ? global : this).moment); // node or other global
  11. }
  12. }(function (moment) {
  13. var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_'),
  14. monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
  15. function plural(n) {
  16. return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
  17. }
  18. function translate(number, withoutSuffix, key) {
  19. var result = number + ' ';
  20. switch (key) {
  21. case 'm':
  22. return withoutSuffix ? 'minuta' : 'minutę';
  23. case 'mm':
  24. return result + (plural(number) ? 'minuty' : 'minut');
  25. case 'h':
  26. return withoutSuffix ? 'godzina' : 'godzinę';
  27. case 'hh':
  28. return result + (plural(number) ? 'godziny' : 'godzin');
  29. case 'MM':
  30. return result + (plural(number) ? 'miesiące' : 'miesięcy');
  31. case 'yy':
  32. return result + (plural(number) ? 'lata' : 'lat');
  33. }
  34. }
  35. return moment.defineLocale('pl', {
  36. months : function (momentToFormat, format) {
  37. if (/D MMMM/.test(format)) {
  38. return monthsSubjective[momentToFormat.month()];
  39. } else {
  40. return monthsNominative[momentToFormat.month()];
  41. }
  42. },
  43. monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
  44. weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
  45. weekdaysShort : 'nie_pon_wt_śr_czw_pt_sb'.split('_'),
  46. weekdaysMin : 'N_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
  47. longDateFormat : {
  48. LT : 'HH:mm',
  49. LTS : 'LT:ss',
  50. L : 'DD.MM.YYYY',
  51. LL : 'D MMMM YYYY',
  52. LLL : 'D MMMM YYYY LT',
  53. LLLL : 'dddd, D MMMM YYYY LT'
  54. },
  55. calendar : {
  56. sameDay: '[Dziś o] LT',
  57. nextDay: '[Jutro o] LT',
  58. nextWeek: '[W] dddd [o] LT',
  59. lastDay: '[Wczoraj o] LT',
  60. lastWeek: function () {
  61. switch (this.day()) {
  62. case 0:
  63. return '[W zeszłą niedzielę o] LT';
  64. case 3:
  65. return '[W zeszłą środę o] LT';
  66. case 6:
  67. return '[W zeszłą sobotę o] LT';
  68. default:
  69. return '[W zeszły] dddd [o] LT';
  70. }
  71. },
  72. sameElse: 'L'
  73. },
  74. relativeTime : {
  75. future : 'za %s',
  76. past : '%s temu',
  77. s : 'kilka sekund',
  78. m : translate,
  79. mm : translate,
  80. h : translate,
  81. hh : translate,
  82. d : '1 dzień',
  83. dd : '%d dni',
  84. M : 'miesiąc',
  85. MM : translate,
  86. y : 'rok',
  87. yy : translate
  88. },
  89. ordinalParse: /\d{1,2}\./,
  90. ordinal : '%d.',
  91. week : {
  92. dow : 1, // Monday is the first day of the week.
  93. doy : 4 // The week that contains Jan 4th is the first week of the year.
  94. }
  95. });
  96. }));