lb.js 4.1KB

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