tlh.js 3.7 KB

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