tlh.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //! moment.js locale configuration
  2. //! locale : Klingon [tlh]
  3. //! author : Dominika Kruk : https://github.com/amaranthrose
  4. ;(function (global, factory) {
  5. typeof exports === 'object' && typeof module !== 'undefined'
  6. && typeof require === 'function' ? factory(require('../moment')) :
  7. typeof define === 'function' && define.amd ? define(['../moment'], factory) :
  8. factory(global.moment)
  9. }(this, (function (moment) { 'use strict';
  10. //! moment.js locale configuration
  11. var numbersNouns = 'pagh_wa’_cha’_wej_loS_vagh_jav_Soch_chorgh_Hut'.split('_');
  12. function translateFuture(output) {
  13. var time = output;
  14. time =
  15. output.indexOf('jaj') !== -1
  16. ? time.slice(0, -3) + 'leS'
  17. : output.indexOf('jar') !== -1
  18. ? time.slice(0, -3) + 'waQ'
  19. : output.indexOf('DIS') !== -1
  20. ? time.slice(0, -3) + 'nem'
  21. : time + ' pIq';
  22. return time;
  23. }
  24. function translatePast(output) {
  25. var time = output;
  26. time =
  27. output.indexOf('jaj') !== -1
  28. ? time.slice(0, -3) + 'Hu’'
  29. : output.indexOf('jar') !== -1
  30. ? time.slice(0, -3) + 'wen'
  31. : output.indexOf('DIS') !== -1
  32. ? time.slice(0, -3) + 'ben'
  33. : time + ' ret';
  34. return time;
  35. }
  36. function translate(number, withoutSuffix, string, isFuture) {
  37. var numberNoun = numberAsNoun(number);
  38. switch (string) {
  39. case 'ss':
  40. return numberNoun + ' lup';
  41. case 'mm':
  42. return numberNoun + ' tup';
  43. case 'hh':
  44. return numberNoun + ' rep';
  45. case 'dd':
  46. return numberNoun + ' jaj';
  47. case 'MM':
  48. return numberNoun + ' jar';
  49. case 'yy':
  50. return numberNoun + ' DIS';
  51. }
  52. }
  53. function numberAsNoun(number) {
  54. var hundred = Math.floor((number % 1000) / 100),
  55. ten = Math.floor((number % 100) / 10),
  56. one = number % 10,
  57. word = '';
  58. if (hundred > 0) {
  59. word += numbersNouns[hundred] + 'vatlh';
  60. }
  61. if (ten > 0) {
  62. word += (word !== '' ? ' ' : '') + numbersNouns[ten] + 'maH';
  63. }
  64. if (one > 0) {
  65. word += (word !== '' ? ' ' : '') + numbersNouns[one];
  66. }
  67. return word === '' ? 'pagh' : word;
  68. }
  69. var tlh = moment.defineLocale('tlh', {
  70. months: 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split(
  71. '_'
  72. ),
  73. monthsShort:
  74. 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split(
  75. '_'
  76. ),
  77. monthsParseExact: true,
  78. weekdays: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split(
  79. '_'
  80. ),
  81. weekdaysShort:
  82. 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  83. weekdaysMin:
  84. 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  85. longDateFormat: {
  86. LT: 'HH:mm',
  87. LTS: 'HH:mm:ss',
  88. L: 'DD.MM.YYYY',
  89. LL: 'D MMMM YYYY',
  90. LLL: 'D MMMM YYYY HH:mm',
  91. LLLL: 'dddd, D MMMM YYYY HH:mm',
  92. },
  93. calendar: {
  94. sameDay: '[DaHjaj] LT',
  95. nextDay: '[wa’leS] LT',
  96. nextWeek: 'LLL',
  97. lastDay: '[wa’Hu’] LT',
  98. lastWeek: 'LLL',
  99. sameElse: 'L',
  100. },
  101. relativeTime: {
  102. future: translateFuture,
  103. past: translatePast,
  104. s: 'puS lup',
  105. ss: translate,
  106. m: 'wa’ tup',
  107. mm: translate,
  108. h: 'wa’ rep',
  109. hh: translate,
  110. d: 'wa’ jaj',
  111. dd: translate,
  112. M: 'wa’ jar',
  113. MM: translate,
  114. y: 'wa’ DIS',
  115. yy: translate,
  116. },
  117. dayOfMonthOrdinalParse: /\d{1,2}\./,
  118. ordinal: '%d.',
  119. week: {
  120. dow: 1, // Monday is the first day of the week.
  121. doy: 4, // The week that contains Jan 4th is the first week of the year.
  122. },
  123. });
  124. return tlh;
  125. })));