lv.js 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //! moment.js locale configuration
  2. //! locale : Latvian [lv]
  3. //! author : Kristaps Karlsons : https://github.com/skakri
  4. //! author : Jānis Elmeris : https://github.com/JanisE
  5. import moment from '../moment';
  6. var units = {
  7. ss: 'sekundes_sekundēm_sekunde_sekundes'.split('_'),
  8. m: 'minūtes_minūtēm_minūte_minūtes'.split('_'),
  9. mm: 'minūtes_minūtēm_minūte_minūtes'.split('_'),
  10. h: 'stundas_stundām_stunda_stundas'.split('_'),
  11. hh: 'stundas_stundām_stunda_stundas'.split('_'),
  12. d: 'dienas_dienām_diena_dienas'.split('_'),
  13. dd: 'dienas_dienām_diena_dienas'.split('_'),
  14. M: 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
  15. MM: 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
  16. y: 'gada_gadiem_gads_gadi'.split('_'),
  17. yy: 'gada_gadiem_gads_gadi'.split('_'),
  18. };
  19. /**
  20. * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
  21. */
  22. function format(forms, number, withoutSuffix) {
  23. if (withoutSuffix) {
  24. // E.g. "21 minūte", "3 minūtes".
  25. return number % 10 === 1 && number % 100 !== 11 ? forms[2] : forms[3];
  26. } else {
  27. // E.g. "21 minūtes" as in "pēc 21 minūtes".
  28. // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
  29. return number % 10 === 1 && number % 100 !== 11 ? forms[0] : forms[1];
  30. }
  31. }
  32. function relativeTimeWithPlural(number, withoutSuffix, key) {
  33. return number + ' ' + format(units[key], number, withoutSuffix);
  34. }
  35. function relativeTimeWithSingular(number, withoutSuffix, key) {
  36. return format(units[key], number, withoutSuffix);
  37. }
  38. function relativeSeconds(number, withoutSuffix) {
  39. return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
  40. }
  41. export default moment.defineLocale('lv', {
  42. months: 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split(
  43. '_'
  44. ),
  45. monthsShort: 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
  46. weekdays: 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split(
  47. '_'
  48. ),
  49. weekdaysShort: 'Sv_P_O_T_C_Pk_S'.split('_'),
  50. weekdaysMin: 'Sv_P_O_T_C_Pk_S'.split('_'),
  51. weekdaysParseExact: true,
  52. longDateFormat: {
  53. LT: 'HH:mm',
  54. LTS: 'HH:mm:ss',
  55. L: 'DD.MM.YYYY.',
  56. LL: 'YYYY. [gada] D. MMMM',
  57. LLL: 'YYYY. [gada] D. MMMM, HH:mm',
  58. LLLL: 'YYYY. [gada] D. MMMM, dddd, HH:mm',
  59. },
  60. calendar: {
  61. sameDay: '[Šodien pulksten] LT',
  62. nextDay: '[Rīt pulksten] LT',
  63. nextWeek: 'dddd [pulksten] LT',
  64. lastDay: '[Vakar pulksten] LT',
  65. lastWeek: '[Pagājušā] dddd [pulksten] LT',
  66. sameElse: 'L',
  67. },
  68. relativeTime: {
  69. future: 'pēc %s',
  70. past: 'pirms %s',
  71. s: relativeSeconds,
  72. ss: relativeTimeWithPlural,
  73. m: relativeTimeWithSingular,
  74. mm: relativeTimeWithPlural,
  75. h: relativeTimeWithSingular,
  76. hh: relativeTimeWithPlural,
  77. d: relativeTimeWithSingular,
  78. dd: relativeTimeWithPlural,
  79. M: relativeTimeWithSingular,
  80. MM: relativeTimeWithPlural,
  81. y: relativeTimeWithSingular,
  82. yy: relativeTimeWithPlural,
  83. },
  84. dayOfMonthOrdinalParse: /\d{1,2}\./,
  85. ordinal: '%d.',
  86. week: {
  87. dow: 1, // Monday is the first day of the week.
  88. doy: 4, // The week that contains Jan 4th is the first week of the year.
  89. },
  90. });