Skip to content

Commit

Permalink
feat(datepicker): add swedish locale (#2804)
Browse files Browse the repository at this point in the history
* feat(datepicker): add swedish locale

* fix(datepicker): fix country code for swedish

Swedish is SV, not SE. SE is Northern Sami
  • Loading branch information
PerfectlyNormal authored and valorkin committed Oct 20, 2017
1 parent 8b53225 commit eccb382
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
4 changes: 2 additions & 2 deletions demo/src/app/components/+datepicker/demo-datepicker.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { routes } from './demo-datepicker.routes';
import { defineLocale } from 'ngx-bootstrap/bs-moment';
import {

ar, cs, de, enGb, es, esDo, esUs, fr, hi, it, ja, ko, nl, nlBe, pl, ptBr, ru, zhCn, tr
ar, cs, de, enGb, es, esDo, esUs, fr, hi, it, ja, ko, nl, nlBe, pl, ptBr, sv, ru, zhCn, tr
} from 'ngx-bootstrap/locale';

const locales = [ar, cs, de, enGb, es, esDo, esUs, fr, hi, it, ja, ko, nl, nlBe, pl, ptBr, ru, zhCn, tr];
const locales = [ar, cs, de, enGb, es, esDo, esUs, fr, hi, it, ja, ko, nl, nlBe, pl, ptBr, sv, ru, zhCn, tr];

locales.forEach(locale => defineLocale(locale.abbr, locale));

Expand Down
61 changes: 61 additions & 0 deletions src/bs-moment/i18n/sv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// moment.js locale configuration
// locale : Swedish [sv]
// author : Jens Alm : https://github.com/ulmus

import { LocaleData } from '../locale/locale.class';

export const sv: LocaleData = {
abbr: 'sv',
months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
L : 'YYYY-MM-DD',
LL : 'D MMMM YYYY',
LLL : 'D MMMM YYYY [kl.] HH:mm',
LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
lll : 'D MMM YYYY HH:mm',
llll : 'ddd D MMM YYYY HH:mm'
},
calendar : {
sameDay: '[Idag] LT',
nextDay: '[Imorgon] LT',
lastDay: '[Igår] LT',
nextWeek: '[På] dddd LT',
lastWeek: '[I] dddd[s] LT',
sameElse: 'L'
},
relativeTime : {
future : 'om %s',
past : 'för %s sedan',
s : 'några sekunder',
m : 'en minut',
mm : '%d minuter',
h : 'en timme',
hh : '%d timmar',
d : 'en dag',
dd : '%d dagar',
M : 'en månad',
MM : '%d månader',
y : 'ett år',
yy : '%d år'
},
dayOfMonthOrdinalParse: /\d{1,2}(e|a)/,
ordinal : function (number) {
const b = number % 10,
// tslint:disable-next-line:no-bitwise
output = (~~(number % 100 / 10) === 1) ? 'e' :
(b === 1) ? 'a' :
(b === 2) ? 'a' :
(b === 3) ? 'e' : 'e';
return number + output;
},
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4th is the first week of the year.
}
};
1 change: 1 addition & 0 deletions src/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { nl } from './bs-moment/i18n/nl';
export { nlBe } from './bs-moment/i18n/nl-be';
export { pl } from './bs-moment/i18n/pl';
export { ptBr } from './bs-moment/i18n/pt-br';
export { sv } from './bs-moment/i18n/sv';
export { ru } from './bs-moment/i18n/ru';
export { zhCn } from './bs-moment/i18n/zh-cn';
export { tr } from './bs-moment/i18n/tr';

0 comments on commit eccb382

Please sign in to comment.