lb.js 5.5 KB

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