Translate the alt-date and alt-datetime part names (year, month, day, …)
Prerequisites
- I have read the documentation
What theme are you using?
core (and every theme built on DateElement, plus @rjsf/mantine and @rjsf/daisyui)
Is your feature request related to a problem? Please describe.
AltDateWidget and AltDateTimeWidget show the name of each date part (year, month, day, hour, minute, second) as the raw DateElementProp.type string. It can't be translated through translateString, so a localized form still shows and announces English part names.
@rjsf/utils: the sharedDateElementinuseAltDateWidgetProps.tsxrendersplaceholder={type}. Core and every theme that uses it inherit this.@rjsf/mantine: since #5354, each part'sSelectusespart.typeas itsaria-label. That names the part, e.g. "Geburtstag year", and its listbox, so the English word is now in the announced name, not just the placeholder.
TranslatableString has no entries for these words; the widgets' only strings are NowLabel and ClearLabel.
Describe the solution you'd like
- Add
TranslatableStringentries for the six part names, e.g.YearLabel: 'year',MonthLabel: 'month',DayLabel: 'day',HourLabel: 'hour',MinuteLabel: 'minute',SecondLabel: 'second'. The default strings stay the same, so English output doesn't change. - Map a
DateElementProp.typeto itsTranslatableStringin one helper in@rjsf/utils(or havegetDateElementPropsreturn the translated label next totype), so no theme maps them itself. - Use the translated label wherever a part name is shown or announced:
- the
placeholderinDateElement(@rjsf/utils); placeholderandaria-labelin@rjsf/mantine'sAltDatePart;- the part widgets any other theme renders for itself (check each theme's
AltDateWidget, e.g.@rjsf/daisyui's visible per-part labels).
- the
- Add the new keys to the translation docs, and to any locale files the repo ships.
Acceptance criteria
- With a
translateStringthat maps the new keys, every alt-date and alt-datetime part shows the translated placeholder, in core and in every theme. - In
@rjsf/mantine, each part's accessible name is<field label> <translated part>, and its listbox'saria-labelis the translated part. - With no custom
translateString, output is unchanged, and no snapshot changes. - The new tests fail without the translation (mutation-checked).
Describe alternatives you've considered
Doing this as part of #5355, which names each part by the field title in every theme and already suggests running the per-part label through translateString. It is kept separate because the translation keys are useful on their own (the visible placeholders are untranslated today), and #5354 already names the Mantine parts without them.
Source: rjsf-team/react-jsonschema-form