Skip to content

Commit

Permalink
Added Serbian (sr) locale (#19) (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf authored and hustcc committed Dec 12, 2017
1 parent d7343b0 commit 5c51252
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion locales/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* 1. please sort by dictionary.
* 2. please ensure the accuracy.
*/
module.exports = [ 'ar', 'be', 'bg', 'ca', 'da', 'de', 'el', 'en', 'en_short', 'es', 'eu', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'in_BG', 'in_HI', 'in_ID', 'it', 'ja', 'ko', 'ml', 'my', 'nb_NO', 'nl', 'nn_NO', 'pl', 'pt_BR', 'ro', 'ru', 'sq', 'sv', 'ta', 'th', 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW' ];
module.exports = [ 'ar', 'be', 'bg', 'ca', 'da', 'de', 'el', 'en', 'en_short', 'es', 'eu', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'in_BG', 'in_HI', 'in_ID', 'it', 'ja', 'ko', 'ml', 'my', 'nb_NO', 'nl', 'nn_NO', 'pl', 'pt_BR', 'ro', 'ru', 'sq', 'sr', 'sv', 'ta', 'th', 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW' ];
42 changes: 42 additions & 0 deletions locales/sr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var seconds = formatNum.bind(null, '1 секунд', '%s секунд', '%s секунде', '%s секунди'),
minutes = formatNum.bind(null, '1 минут', '%s минут', '%s минуте', '%s минута'),
hours = formatNum.bind(null, 'сат времена', '%s сат', '%s сата', '%s сати'),
days = formatNum.bind(null, '1 дан', '%s дан', '%s дана', '%s дана'),
weeks = formatNum.bind(null, 'недељу дана', '%s недељу', '%s недеље', '%s недеља'),
months = formatNum.bind(null, 'месец дана', '%s месец', '%s месеца', '%s месеци'),
years = formatNum.bind(null, 'годину дана', '%s годину', '%s године', '%s година');

module.exports = function(number, index) {
switch(index) {
case 0: return ['малопре', 'управо сад'];
case 1: return ['пре ' + seconds(number), 'за ' + seconds(number)];
case 2:
case 3: return ['пре ' + minutes(number), 'за ' + minutes(number)];
case 4:
case 5: return ['пре ' + hours(number), 'за ' + hours(number)];
case 6:
case 7: return ['пре ' + days(number), 'за ' + days(number)];
case 8:
case 9: return ['пре ' + weeks(number), 'за ' + weeks(number)];
case 10:
case 11: return ['пре ' + months(number), 'за ' + months(number)];
case 12:
case 13: return ['пре ' + years(number), 'за ' + years(number)];
default: return ['', '']
}
};

function formatNum(single, one, few, other, n) {
var rem10 = n % 10;
var rem100 = n % 100;

if (n == 1) {
return single;
} else if (rem10 == 1 && rem100 != 11) {
return one;
} else if (rem10 >= 2 && rem10 <= 4 && !(rem100 >= 12 && rem100 <= 14)) {
return few;
} else {
return other;
}
}

0 comments on commit 5c51252

Please sign in to comment.