mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Upgrade moment.js to latest version, add missing locales now that we
support more languages.
This commit is contained in:
150
lib/javascripts/moment_locale/be.js
Normal file
150
lib/javascripts/moment_locale/be.js
Normal file
@ -0,0 +1,150 @@
|
||||
// moment.js locale configuration
|
||||
// locale : belarusian (be)
|
||||
// author : Dmitry Demidov : https://github.com/demidov91
|
||||
// author: Praleska: http://praleska.pro/
|
||||
// Author : Menelion Elensúle : https://github.com/Oire
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['moment'], factory); // AMD
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory(require('../moment')); // Node
|
||||
} else {
|
||||
factory(window.moment); // Browser global
|
||||
}
|
||||
}(function (moment) {
|
||||
function plural(word, num) {
|
||||
var forms = word.split('_');
|
||||
return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
|
||||
}
|
||||
|
||||
function relativeTimeWithPlural(number, withoutSuffix, key) {
|
||||
var format = {
|
||||
'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
|
||||
'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
|
||||
'dd': 'дзень_дні_дзён',
|
||||
'MM': 'месяц_месяцы_месяцаў',
|
||||
'yy': 'год_гады_гадоў'
|
||||
};
|
||||
if (key === 'm') {
|
||||
return withoutSuffix ? 'хвіліна' : 'хвіліну';
|
||||
}
|
||||
else if (key === 'h') {
|
||||
return withoutSuffix ? 'гадзіна' : 'гадзіну';
|
||||
}
|
||||
else {
|
||||
return number + ' ' + plural(format[key], +number);
|
||||
}
|
||||
}
|
||||
|
||||
function monthsCaseReplace(m, format) {
|
||||
var months = {
|
||||
'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
|
||||
'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
|
||||
},
|
||||
|
||||
nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
|
||||
'accusative' :
|
||||
'nominative';
|
||||
|
||||
return months[nounCase][m.month()];
|
||||
}
|
||||
|
||||
function weekdaysCaseReplace(m, format) {
|
||||
var weekdays = {
|
||||
'nominative': 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
|
||||
'accusative': 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_')
|
||||
},
|
||||
|
||||
nounCase = (/\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/).test(format) ?
|
||||
'accusative' :
|
||||
'nominative';
|
||||
|
||||
return weekdays[nounCase][m.day()];
|
||||
}
|
||||
|
||||
return moment.defineLocale('be', {
|
||||
months : monthsCaseReplace,
|
||||
monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
|
||||
weekdays : weekdaysCaseReplace,
|
||||
weekdaysShort : "нд_пн_ат_ср_чц_пт_сб".split("_"),
|
||||
weekdaysMin : "нд_пн_ат_ср_чц_пт_сб".split("_"),
|
||||
longDateFormat : {
|
||||
LT : "HH:mm",
|
||||
L : "DD.MM.YYYY",
|
||||
LL : "D MMMM YYYY г.",
|
||||
LLL : "D MMMM YYYY г., LT",
|
||||
LLLL : "dddd, D MMMM YYYY г., LT"
|
||||
},
|
||||
calendar : {
|
||||
sameDay: '[Сёння ў] LT',
|
||||
nextDay: '[Заўтра ў] LT',
|
||||
lastDay: '[Учора ў] LT',
|
||||
nextWeek: function () {
|
||||
return '[У] dddd [ў] LT';
|
||||
},
|
||||
lastWeek: function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
case 3:
|
||||
case 5:
|
||||
case 6:
|
||||
return '[У мінулую] dddd [ў] LT';
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
return '[У мінулы] dddd [ў] LT';
|
||||
}
|
||||
},
|
||||
sameElse: 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : "праз %s",
|
||||
past : "%s таму",
|
||||
s : "некалькі секунд",
|
||||
m : relativeTimeWithPlural,
|
||||
mm : relativeTimeWithPlural,
|
||||
h : relativeTimeWithPlural,
|
||||
hh : relativeTimeWithPlural,
|
||||
d : "дзень",
|
||||
dd : relativeTimeWithPlural,
|
||||
M : "месяц",
|
||||
MM : relativeTimeWithPlural,
|
||||
y : "год",
|
||||
yy : relativeTimeWithPlural
|
||||
},
|
||||
|
||||
|
||||
meridiem : function (hour, minute, isLower) {
|
||||
if (hour < 4) {
|
||||
return "ночы";
|
||||
} else if (hour < 12) {
|
||||
return "раніцы";
|
||||
} else if (hour < 17) {
|
||||
return "дня";
|
||||
} else {
|
||||
return "вечара";
|
||||
}
|
||||
},
|
||||
|
||||
ordinal: function (number, period) {
|
||||
switch (period) {
|
||||
case 'M':
|
||||
case 'd':
|
||||
case 'DDD':
|
||||
case 'w':
|
||||
case 'W':
|
||||
return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
|
||||
case 'D':
|
||||
return number + '-га';
|
||||
default:
|
||||
return number;
|
||||
}
|
||||
},
|
||||
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
}
|
||||
});
|
||||
}));
|
Reference in New Issue
Block a user