lv.js 3.4 KB

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:
  47. 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split(
  48. '_'
  49. ),
  50. weekdaysShort: 'Sv_P_O_T_C_Pk_S'.split('_'),
  51. weekdaysMin: 'Sv_P_O_T_C_Pk_S'.split('_'),
  52. weekdaysParseExact: true,
  53. longDateFormat: {
  54. LT: 'HH:mm',
  55. LTS: 'HH:mm:ss',
  56. L: 'DD.MM.YYYY.',
  57. LL: 'YYYY. [gada] D. MMMM',
  58. LLL: 'YYYY. [gada] D. MMMM, HH:mm',
  59. LLLL: 'YYYY. [gada] D. MMMM, dddd, HH:mm',
  60. },
  61. calendar: {
  62. sameDay: '[Šodien pulksten] LT',
  63. nextDay: '[Rīt pulksten] LT',
  64. nextWeek: 'dddd [pulksten] LT',
  65. lastDay: '[Vakar pulksten] LT',
  66. lastWeek: '[Pagājušā] dddd [pulksten] LT',
  67. sameElse: 'L',
  68. },
  69. relativeTime: {
  70. future: 'pēc %s',
  71. past: 'pirms %s',
  72. s: relativeSeconds,
  73. ss: relativeTimeWithPlural,
  74. m: relativeTimeWithSingular,
  75. mm: relativeTimeWithPlural,
  76. h: relativeTimeWithSingular,
  77. hh: relativeTimeWithPlural,
  78. d: relativeTimeWithSingular,
  79. dd: relativeTimeWithPlural,
  80. M: relativeTimeWithSingular,
  81. MM: relativeTimeWithPlural,
  82. y: relativeTimeWithSingular,
  83. yy: relativeTimeWithPlural,
  84. },
  85. dayOfMonthOrdinalParse: /\d{1,2}\./,
  86. ordinal: '%d.',
  87. week: {
  88. dow: 1, // Monday is the first day of the week.
  89. doy: 4, // The week that contains Jan 4th is the first week of the year.
  90. },
  91. });