Commit bf65358
i18n(Calendar): localize month names via useDateFormatter
YearCalendar and MultiSelectYearCalendar hardcoded English month names in
monthsObj — both the visible abbreviation ("Jan") and the full name used in
the cell aria-label ("January"). These are CLDR data that Intl already knows
for every locale, so route them through react-aria's useDateFormatter
(month: 'short' for the visible text, month: 'long' for the aria-label)
keyed off the active locale from the nearest <I18nProvider>, matching the
MultiMonthPicker i18n approach. monthsObj now carries only month numbers for
the 3x4 grid layout; names are formatted at render time.
The day is fixed to the 1st in local time (new Date(year, month - 1, 1)) to
avoid the UTC-midnight off-by-one that bit MultiMonthPicker. Adds a Storybook
story rendering the months in French via <I18nProvider>.
This leaves the consumer-supplied `labels` prop for only the genuinely
app-authored strings (e.g. "selected"), which Intl does not provide.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 79b7b46 commit bf65358
3 files changed
Lines changed: 58 additions & 49 deletions
File tree
- packages/opub-ui/src/components/Calendar
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
Lines changed: 18 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
45 | 30 | | |
46 | 31 | | |
47 | 32 | | |
| |||
258 | 243 | | |
259 | 244 | | |
260 | 245 | | |
261 | | - | |
| 246 | + | |
262 | 247 | | |
263 | 248 | | |
264 | 249 | | |
265 | 250 | | |
266 | 251 | | |
267 | 252 | | |
268 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
269 | 263 | | |
270 | 264 | | |
271 | 265 | | |
| |||
293 | 287 | | |
294 | 288 | | |
295 | 289 | | |
296 | | - | |
| 290 | + | |
297 | 291 | | |
298 | 292 | | |
299 | 293 | | |
| |||
307 | 301 | | |
308 | 302 | | |
309 | 303 | | |
310 | | - | |
| 304 | + | |
311 | 305 | | |
312 | 306 | | |
313 | 307 | | |
| |||
Lines changed: 18 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
45 | 30 | | |
46 | 31 | | |
47 | 32 | | |
| |||
185 | 170 | | |
186 | 171 | | |
187 | 172 | | |
188 | | - | |
| 173 | + | |
189 | 174 | | |
190 | 175 | | |
191 | 176 | | |
192 | 177 | | |
193 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
194 | 188 | | |
195 | 189 | | |
196 | 190 | | |
| |||
217 | 211 | | |
218 | 212 | | |
219 | 213 | | |
220 | | - | |
| 214 | + | |
221 | 215 | | |
222 | 216 | | |
223 | 217 | | |
| |||
231 | 225 | | |
232 | 226 | | |
233 | 227 | | |
234 | | - | |
| 228 | + | |
235 | 229 | | |
236 | 230 | | |
237 | 231 | | |
| |||
0 commit comments