Skip to content

Commit 14504e5

Browse files
authored
Merge pull request #2490 from vdh/patch-2
Added missing 'Saturday' string to locale-en
2 parents 7d91d29 + c05c4af commit 14504e5

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

src/locale-en.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
'Click to enter Colorscale title': 'Click to enter Colourscale title'
1616
},
1717
format: {
18-
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
18+
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
1919
shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
2020
months: [
2121
'January', 'February', 'March', 'April', 'May', 'June',

test/jasmine/tests/localize_test.js

+86
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,92 @@ describe('localization', function() {
6262
.then(done);
6363
});
6464

65+
function getLabels(axLetter) {
66+
var out = [];
67+
var s = d3.select(gd).selectAll('.' + axLetter + 'tick');
68+
s.each(function() { out.push(d3.select(this).text()); });
69+
return out;
70+
}
71+
72+
it('contains all short and long day and month names in the default locale', function(done) {
73+
Plotly.newPlot(gd, [{
74+
x: ['2000-01-01', '2000-12-01'],
75+
y: ['2000-01-02', '2000-01-08'],
76+
mode: 'markers'
77+
}], {
78+
xaxis: {dtick: 'M1', tickformat: '%b'},
79+
yaxis: {dtick: 1000 * 3600 * 24, tickformat: '%a'}
80+
})
81+
.then(function() {
82+
expect(getLabels('x')).toEqual([
83+
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
84+
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
85+
]);
86+
expect(getLabels('y')).toEqual([
87+
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
88+
]);
89+
90+
return Plotly.relayout(gd, {
91+
'xaxis.tickformat': '%B',
92+
'yaxis.tickformat': '%A'
93+
});
94+
})
95+
.then(function() {
96+
expect(getLabels('x')).toEqual([
97+
'January', 'February', 'March', 'April', 'May', 'June',
98+
'July', 'August', 'September', 'October', 'November', 'December'
99+
]);
100+
expect(getLabels('y')).toEqual([
101+
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
102+
]);
103+
})
104+
.catch(failTest)
105+
.then(done);
106+
});
107+
108+
it('contains correct periods, dateTime, date, and time fields in the default locale', function(done) {
109+
Plotly.newPlot(gd, [{
110+
x: ['2000-01-01 11:00', '2000-01-01 13:00'],
111+
y: ['2000-01-01 23:00', '2000-01-02 01:00'],
112+
mode: 'markers'
113+
}], {
114+
xaxis: {dtick: 1000 * 3600, tickformat: '%-I %p'},
115+
yaxis: {dtick: 1000 * 3600, tickformat: '%-I %p'}
116+
})
117+
.then(function() {
118+
expect(getLabels('x')).toEqual(['11 AM', '12 PM', '1 PM']);
119+
expect(getLabels('y')).toEqual(['11 PM', '12 AM', '1 AM']);
120+
121+
return Plotly.relayout(gd, {
122+
'xaxis.tickformat': '%c',
123+
'yaxis.tickformat': '%x~%X'
124+
});
125+
})
126+
.then(function() {
127+
expect(getLabels('x')).toEqual([
128+
'Sat Jan 1 11:00:00 2000', 'Sat Jan 1 12:00:00 2000', 'Sat Jan 1 13:00:00 2000'
129+
]);
130+
expect(getLabels('y')).toEqual([
131+
// here we're using British English, so day/month/year
132+
'01/01/2000~23:00:00', '02/01/2000~00:00:00', '02/01/2000~01:00:00'
133+
]);
134+
135+
Plotly.register(require('@src/locale-en-us'));
136+
return Plotly.redraw(gd);
137+
})
138+
.then(function() {
139+
expect(getLabels('x')).toEqual([
140+
'Sat Jan 1 11:00:00 2000', 'Sat Jan 1 12:00:00 2000', 'Sat Jan 1 13:00:00 2000'
141+
]);
142+
expect(getLabels('y')).toEqual([
143+
// now with the US version
144+
'01/01/2000~23:00:00', '01/02/2000~00:00:00', '01/02/2000~01:00:00'
145+
]);
146+
})
147+
.catch(failTest)
148+
.then(done);
149+
});
150+
65151
it('uses the region first, then language (registered case)', function(done) {
66152
plot('eg-AU')
67153
.then(function() {

0 commit comments

Comments
 (0)