Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(i18n): route DateInput/DateTimeInput validation messages through translator (#4546)

Cindy Zhang925d906a90ac
diff --git a/.changeset/i18n-date-input-live-regions.md b/.changeset/i18n-date-input-live-regions.md
new file mode 100644
index 0000000000..8e3f6a2247
--- /dev/null
+++ b/.changeset/i18n-date-input-live-regions.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] DateTimeInput: the focused-and-empty time placeholder hints ("e.g., 2:30 PM" / "e.g., 14:30") now route through the i18n translator so they localize with the rest of the component. Adds `@astryx.dateTimeInput.timeHint12h` and `@astryx.dateTimeInput.timeHint24h` to the `en` catalog. The live-region "Invalid date" / "Invalid time" announcements this PR also covered landed first in #4363 and now reuse that PR's `@astryx.dateInput.invalidDate` and `@astryx.timeInput.invalidTime` keys. (#4546)
+
+@cixzhang
diff --git a/packages/core/locales/en.json b/packages/core/locales/en.json
index 5f68d0f967..1d39ff2238 100644
--- a/packages/core/locales/en.json
+++ b/packages/core/locales/en.json
@@ -643,6 +643,14 @@
"defaultMessage": "Invalid date",
"description": "Screen-reader-only live-region alert in DateInput / DateTimeInput when the typed date cannot be parsed. The field silently reverts on blur, so this is the only rejection feedback a screen-reader user gets."
},
+ "@astryx.dateTimeInput.timeHint12h": {
+ "defaultMessage": "e.g., 2:30 PM",
+ "description": "Placeholder hint shown in the DateTimeInput time field when focused and empty with 12-hour format. Gives an example of expected input format."
+ },
+ "@astryx.dateTimeInput.timeHint24h": {
+ "defaultMessage": "e.g., 14:30",
+ "description": "Placeholder hint shown in the DateTimeInput time field when focused and empty with 24-hour format. Gives an example of expected input format."
+ },
"@astryx.dateTimeInput.timeSuffix": {
"defaultMessage": "{label} time",
"description": "Screen-reader-only accessible name for the time-of-day slot in a DateTimeInput. Example: `Start date time`; reorder freely (e.g. \"time of {label}\")."
diff --git a/packages/core/src/DateTimeInput/DateTimeInput.tsx b/packages/core/src/DateTimeInput/DateTimeInput.tsx
index b20cfc17b5..ce5a0366eb 100644
--- a/packages/core/src/DateTimeInput/DateTimeInput.tsx
+++ b/packages/core/src/DateTimeInput/DateTimeInput.tsx
@@ -594,10 +594,12 @@ export function DateTimeInput({
const resolvedTimePlaceholder = useMemo(() => {
if (isTimeFocused && !timeDisplayValue) {
- return hourFormat === '12h' ? 'e.g., 2:30 PM' : 'e.g., 14:30';
+ return hourFormat === '12h'
+ ? t('@astryx.dateTimeInput.timeHint12h')
+ : t('@astryx.dateTimeInput.timeHint24h');
}
return timePlaceholder;
- }, [isTimeFocused, timeDisplayValue, hourFormat, timePlaceholder]);
+ }, [isTimeFocused, timeDisplayValue, hourFormat, timePlaceholder, t]);
// --- Unified change handler ---
const fireChange = useCallback(