Skip to content

Commit f6d9a64

Browse files
committed
fix: fix it locale error (#458)
* fix: fix it locale error * fix: fix es locale monthsShort error * test: fix test * fix: add missing es-do and es-us locale file
1 parent 7e04004 commit f6d9a64

File tree

5 files changed

+57
-20
lines changed

5 files changed

+57
-20
lines changed

src/locale/es-es.js src/locale/es-do.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import dayjs from 'dayjs'
22

33
const locale = {
4-
name: 'es-es',
5-
weekdays: 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
4+
name: 'es-do',
5+
weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
6+
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
7+
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
68
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
9+
monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'),
710
relativeTime: {
811
future: 'en %s',
912
past: 'hace %s',

src/locale/es-us.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import dayjs from 'dayjs'
2+
3+
const locale = {
4+
name: 'es-us',
5+
weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
6+
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
7+
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
8+
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
9+
monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'),
10+
relativeTime: {
11+
future: 'en %s',
12+
past: 'hace %s',
13+
s: 'unos segundos',
14+
m: 'un minuto',
15+
mm: '%d minutos',
16+
h: 'una hora',
17+
hh: '%d horas',
18+
d: 'un día',
19+
dd: '%d días',
20+
M: 'un mes',
21+
MM: '%d meses',
22+
y: 'un año',
23+
yy: '%d años'
24+
},
25+
ordinal: n => `${n}º`
26+
}
27+
28+
dayjs.locale(locale, null, true)
29+
30+
export default locale

src/locale/es.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import dayjs from 'dayjs'
22

33
const locale = {
44
name: 'es',
5-
weekdays: 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
5+
monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'),
6+
weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
7+
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
8+
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
69
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
7-
monthsShort: 'enero_feb_marzo_abr_mayo_jun_jul_agosto_sept_oct_nov_dic'.split('_'),
810
formats: {
911
LT: 'H:mm',
1012
LTS: 'H:mm:ss',

src/locale/it.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import dayjs from 'dayjs'
22

33
const locale = {
44
name: 'it',
5-
weekdays: 'Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato'.split('_'),
6-
months: 'Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settembre_Ottobre_Novembre_Dicembre'.split('_'),
7-
monthsShort: 'genn_febbr_mar_apr_magg_giugno_luglio_ag_sett_ott_nov_dic'.split('_'),
5+
weekdays: 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'),
6+
weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'),
7+
weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'),
8+
months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
9+
monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
810
formats: {
911
LT: 'HH:mm',
1012
LTS: 'HH:mm:ss',

test/locale.test.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const format = 'dddd D, MMMM'
1515
it('Uses spanish locale through constructor', () => { // not recommend
1616
expect(dayjs('2018-4-28', { locale: es })
1717
.format(format))
18-
.toBe('Sábado 28, Abril')
18+
.toBe('sábado 28, Abril')
1919
})
2020

2121
it('set locale for one instance only', () => {
@@ -25,7 +25,7 @@ it('set locale for one instance only', () => {
2525

2626
expect(dayjs('2018-4-28')
2727
.locale(es).format(format))
28-
.toBe('Sábado 28, Abril')
28+
.toBe('sábado 28, Abril')
2929

3030
expect(dayjs('2018-4-28')
3131
.format(format))
@@ -38,7 +38,7 @@ it('set global locale', () => {
3838
.toBe('Saturday 28, April')
3939
dayjs.locale(es)
4040
expect(dayjs('2018-4-28').format(format))
41-
.toBe('Sábado 28, Abril')
41+
.toBe('sábado 28, Abril')
4242
dayjs.locale('en')
4343
expect(dayjs('2018-4-28').format(format))
4444
.toBe('Saturday 28, April')
@@ -50,10 +50,10 @@ it('immutable instance locale', () => {
5050
expect(origin.format(format))
5151
.toBe('Saturday 28, April')
5252
expect(origin.locale('es').format(format))
53-
.toBe('Sábado 28, Abril')
53+
.toBe('sábado 28, Abril')
5454
const changed = origin.locale('es')
5555
expect(changed.format(format))
56-
.toBe('Sábado 28, Abril')
56+
.toBe('sábado 28, Abril')
5757
expect(origin.format(format))
5858
.toBe('Saturday 28, April')
5959
})
@@ -73,29 +73,29 @@ describe('Instance locale inheritance', () => {
7373

7474
it('Clone', () => {
7575
expect(esDayjs.clone().format(format))
76-
.toBe('Sábado 28, Abril')
76+
.toBe('sábado 28, Abril')
7777
expect(dayjs(esDayjs).format(format))
78-
.toBe('Sábado 28, Abril')
78+
.toBe('sábado 28, Abril')
7979
})
8080

8181
it('StartOf EndOf', () => {
8282
expect(esDayjs.startOf('year').format(format))
83-
.toBe('Lunes 1, Enero')
83+
.toBe('lunes 1, Enero')
8484
expect(esDayjs.endOf('day').format(format))
85-
.toBe('Sábado 28, Abril')
85+
.toBe('sábado 28, Abril')
8686
})
8787

8888
it('Set', () => {
8989
expect(esDayjs.set('year', 2017).format(format))
90-
.toBe('Viernes 28, Abril')
90+
.toBe('viernes 28, Abril')
9191
})
9292

9393
it('Add', () => {
9494
expect(esDayjs.add(1, 'year').format(format))
95-
.toBe('Domingo 28, Abril')
95+
.toBe('domingo 28, Abril')
9696
expect(esDayjs.add(1, 'month').format(format))
97-
.toBe('Lunes 28, Mayo')
97+
.toBe('lunes 28, Mayo')
9898
expect(esDayjs.add(1, 'minute').format(format))
99-
.toBe('Sábado 28, Abril')
99+
.toBe('sábado 28, Abril')
100100
})
101101
})

0 commit comments

Comments
 (0)