lb.js 4.2 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. 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:
  76. 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split(
  77. '_'
  78. ),
  79. monthsParseExact: true,
  80. weekdays:
  81. 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split(
  82. '_'
  83. ),
  84. weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
  85. weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
  86. weekdaysParseExact: true,
  87. longDateFormat: {
  88. LT: 'H:mm [Auer]',
  89. LTS: 'H:mm:ss [Auer]',
  90. L: 'DD.MM.YYYY',
  91. LL: 'D. MMMM YYYY',
  92. LLL: 'D. MMMM YYYY H:mm [Auer]',
  93. LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]',
  94. },
  95. calendar: {
  96. sameDay: '[Haut um] LT',
  97. sameElse: 'L',
  98. nextDay: '[Muer um] LT',
  99. nextWeek: 'dddd [um] LT',
  100. lastDay: '[Gëschter um] LT',
  101. lastWeek: function () {
  102. // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
  103. switch (this.day()) {
  104. case 2:
  105. case 4:
  106. return '[Leschten] dddd [um] LT';
  107. default:
  108. return '[Leschte] dddd [um] LT';
  109. }
  110. },
  111. },
  112. relativeTime: {
  113. future: processFutureTime,
  114. past: processPastTime,
  115. s: 'e puer Sekonnen',
  116. ss: '%d Sekonnen',
  117. m: processRelativeTime,
  118. mm: '%d Minutten',
  119. h: processRelativeTime,
  120. hh: '%d Stonnen',
  121. d: processRelativeTime,
  122. dd: '%d Deeg',
  123. M: processRelativeTime,
  124. MM: '%d Méint',
  125. y: processRelativeTime,
  126. yy: '%d Joer',
  127. },
  128. dayOfMonthOrdinalParse: /\d{1,2}\./,
  129. ordinal: '%d.',
  130. week: {
  131. dow: 1, // Monday is the first day of the week.
  132. doy: 4, // The week that contains Jan 4th is the first week of the year.
  133. },
  134. });