lb.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //! moment.js locale configuration
  2. //! locale : Luxembourgish [lb]
  3. //! author : mweimerskirch : https://github.com/mweimerskirch
  4. //! author : David Raison : https://github.com/kwisatz
  5. ;(function (global, factory) {
  6. typeof exports === 'object' && typeof module !== 'undefined'
  7. && typeof require === 'function' ? factory(require('../moment')) :
  8. typeof define === 'function' && define.amd ? define(['../moment'], factory) :
  9. factory(global.moment)
  10. }(this, (function (moment) { 'use strict';
  11. function processRelativeTime(number, withoutSuffix, key, isFuture) {
  12. var format = {
  13. 'm': ['eng Minutt', 'enger Minutt'],
  14. 'h': ['eng Stonn', 'enger Stonn'],
  15. 'd': ['een Dag', 'engem Dag'],
  16. 'M': ['ee Mount', 'engem Mount'],
  17. 'y': ['ee Joer', 'engem Joer']
  18. };
  19. return withoutSuffix ? format[key][0] : format[key][1];
  20. }
  21. function processFutureTime(string) {
  22. var number = string.substr(0, string.indexOf(' '));
  23. if (eifelerRegelAppliesToNumber(number)) {
  24. return 'a ' + string;
  25. }
  26. return 'an ' + string;
  27. }
  28. function processPastTime(string) {
  29. var number = string.substr(0, string.indexOf(' '));
  30. if (eifelerRegelAppliesToNumber(number)) {
  31. return 'viru ' + string;
  32. }
  33. return 'virun ' + string;
  34. }
  35. /**
  36. * Returns true if the word before the given number loses the '-n' ending.
  37. * e.g. 'an 10 Deeg' but 'a 5 Deeg'
  38. *
  39. * @param number {integer}
  40. * @returns {boolean}
  41. */
  42. function eifelerRegelAppliesToNumber(number) {
  43. number = parseInt(number, 10);
  44. if (isNaN(number)) {
  45. return false;
  46. }
  47. if (number < 0) {
  48. // Negative Number --> always true
  49. return true;
  50. } else if (number < 10) {
  51. // Only 1 digit
  52. if (4 <= number && number <= 7) {
  53. return true;
  54. }
  55. return false;
  56. } else if (number < 100) {
  57. // 2 digits
  58. var lastDigit = number % 10, firstDigit = number / 10;
  59. if (lastDigit === 0) {
  60. return eifelerRegelAppliesToNumber(firstDigit);
  61. }
  62. return eifelerRegelAppliesToNumber(lastDigit);
  63. } else if (number < 10000) {
  64. // 3 or 4 digits --> recursively check first digit
  65. while (number >= 10) {
  66. number = number / 10;
  67. }
  68. return eifelerRegelAppliesToNumber(number);
  69. } else {
  70. // Anything larger than 4 digits: recursively check first n-3 digits
  71. number = number / 1000;
  72. return eifelerRegelAppliesToNumber(number);
  73. }
  74. }
  75. var lb = moment.defineLocale('lb', {
  76. months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  77. monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
  78. monthsParseExact : true,
  79. weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
  80. weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
  81. weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
  82. weekdaysParseExact : true,
  83. longDateFormat: {
  84. LT: 'H:mm [Auer]',
  85. LTS: 'H:mm:ss [Auer]',
  86. L: 'DD.MM.YYYY',
  87. LL: 'D. MMMM YYYY',
  88. LLL: 'D. MMMM YYYY H:mm [Auer]',
  89. LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
  90. },
  91. calendar: {
  92. sameDay: '[Haut um] LT',
  93. sameElse: 'L',
  94. nextDay: '[Muer um] LT',
  95. nextWeek: 'dddd [um] LT',
  96. lastDay: '[Gëschter um] LT',
  97. lastWeek: function () {
  98. // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
  99. switch (this.day()) {
  100. case 2:
  101. case 4:
  102. return '[Leschten] dddd [um] LT';
  103. default:
  104. return '[Leschte] dddd [um] LT';
  105. }
  106. }
  107. },
  108. relativeTime : {
  109. future : processFutureTime,
  110. past : processPastTime,
  111. s : 'e puer Sekonnen',
  112. m : processRelativeTime,
  113. mm : '%d Minutten',
  114. h : processRelativeTime,
  115. hh : '%d Stonnen',
  116. d : processRelativeTime,
  117. dd : '%d Deeg',
  118. M : processRelativeTime,
  119. MM : '%d Méint',
  120. y : processRelativeTime,
  121. yy : '%d Joer'
  122. },
  123. dayOfMonthOrdinalParse: /\d{1,2}\./,
  124. ordinal: '%d.',
  125. week: {
  126. dow: 1, // Monday is the first day of the week.
  127. doy: 4 // The week that contains Jan 4th is the first week of the year.
  128. }
  129. });
  130. return lb;
  131. })));