lb.js 5.0 KB

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