tlh.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. var numbersNouns = 'pagh_wa’_cha’_wej_loS_vagh_jav_Soch_chorgh_Hut'.split('_');
  11. function translateFuture(output) {
  12. var time = output;
  13. time = (output.indexOf('jaj') !== -1) ?
  14. time.slice(0, -3) + 'leS' :
  15. (output.indexOf('jar') !== -1) ?
  16. time.slice(0, -3) + 'waQ' :
  17. (output.indexOf('DIS') !== -1) ?
  18. time.slice(0, -3) + 'nem' :
  19. time + ' pIq';
  20. return time;
  21. }
  22. function translatePast(output) {
  23. var time = output;
  24. time = (output.indexOf('jaj') !== -1) ?
  25. time.slice(0, -3) + 'Hu’' :
  26. (output.indexOf('jar') !== -1) ?
  27. time.slice(0, -3) + 'wen' :
  28. (output.indexOf('DIS') !== -1) ?
  29. time.slice(0, -3) + 'ben' :
  30. time + ' ret';
  31. return time;
  32. }
  33. function translate(number, withoutSuffix, string, isFuture) {
  34. var numberNoun = numberAsNoun(number);
  35. switch (string) {
  36. case 'ss':
  37. return numberNoun + ' lup';
  38. case 'mm':
  39. return numberNoun + ' tup';
  40. case 'hh':
  41. return numberNoun + ' rep';
  42. case 'dd':
  43. return numberNoun + ' jaj';
  44. case 'MM':
  45. return numberNoun + ' jar';
  46. case 'yy':
  47. return numberNoun + ' DIS';
  48. }
  49. }
  50. function numberAsNoun(number) {
  51. var hundred = Math.floor((number % 1000) / 100),
  52. ten = Math.floor((number % 100) / 10),
  53. one = number % 10,
  54. word = '';
  55. if (hundred > 0) {
  56. word += numbersNouns[hundred] + 'vatlh';
  57. }
  58. if (ten > 0) {
  59. word += ((word !== '') ? ' ' : '') + numbersNouns[ten] + 'maH';
  60. }
  61. if (one > 0) {
  62. word += ((word !== '') ? ' ' : '') + numbersNouns[one];
  63. }
  64. return (word === '') ? 'pagh' : word;
  65. }
  66. var tlh = moment.defineLocale('tlh', {
  67. 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('_'),
  68. 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('_'),
  69. monthsParseExact : true,
  70. weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  71. weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  72. weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  73. longDateFormat : {
  74. LT : 'HH:mm',
  75. LTS : 'HH:mm:ss',
  76. L : 'DD.MM.YYYY',
  77. LL : 'D MMMM YYYY',
  78. LLL : 'D MMMM YYYY HH:mm',
  79. LLLL : 'dddd, D MMMM YYYY HH:mm'
  80. },
  81. calendar : {
  82. sameDay: '[DaHjaj] LT',
  83. nextDay: '[wa’leS] LT',
  84. nextWeek: 'LLL',
  85. lastDay: '[wa’Hu’] LT',
  86. lastWeek: 'LLL',
  87. sameElse: 'L'
  88. },
  89. relativeTime : {
  90. future : translateFuture,
  91. past : translatePast,
  92. s : 'puS lup',
  93. ss : translate,
  94. m : 'wa’ tup',
  95. mm : translate,
  96. h : 'wa’ rep',
  97. hh : translate,
  98. d : 'wa’ jaj',
  99. dd : translate,
  100. M : 'wa’ jar',
  101. MM : translate,
  102. y : 'wa’ DIS',
  103. yy : translate
  104. },
  105. dayOfMonthOrdinalParse: /\d{1,2}\./,
  106. ordinal : '%d.',
  107. week : {
  108. dow : 1, // Monday is the first day of the week.
  109. doy : 4 // The week that contains Jan 4th is the first week of the year.
  110. }
  111. });
  112. return tlh;
  113. })));