tlh.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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: '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(
  74. '_'
  75. ),
  76. monthsParseExact: true,
  77. weekdays: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split(
  78. '_'
  79. ),
  80. weekdaysShort: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split(
  81. '_'
  82. ),
  83. weekdaysMin: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split(
  84. '_'
  85. ),
  86. longDateFormat: {
  87. LT: 'HH:mm',
  88. LTS: 'HH:mm:ss',
  89. L: 'DD.MM.YYYY',
  90. LL: 'D MMMM YYYY',
  91. LLL: 'D MMMM YYYY HH:mm',
  92. LLLL: 'dddd, D MMMM YYYY HH:mm',
  93. },
  94. calendar: {
  95. sameDay: '[DaHjaj] LT',
  96. nextDay: '[wa’leS] LT',
  97. nextWeek: 'LLL',
  98. lastDay: '[wa’Hu’] LT',
  99. lastWeek: 'LLL',
  100. sameElse: 'L',
  101. },
  102. relativeTime: {
  103. future: translateFuture,
  104. past: translatePast,
  105. s: 'puS lup',
  106. ss: translate,
  107. m: 'wa’ tup',
  108. mm: translate,
  109. h: 'wa’ rep',
  110. hh: translate,
  111. d: 'wa’ jaj',
  112. dd: translate,
  113. M: 'wa’ jar',
  114. MM: translate,
  115. y: 'wa’ DIS',
  116. yy: translate,
  117. },
  118. dayOfMonthOrdinalParse: /\d{1,2}\./,
  119. ordinal: '%d.',
  120. week: {
  121. dow: 1, // Monday is the first day of the week.
  122. doy: 4, // The week that contains Jan 4th is the first week of the year.
  123. },
  124. });
  125. return tlh;
  126. })));