mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
An empty required field showed the browser's own validation bubble ("Please
fill out this field"), in the system's language and not the app's. RForm now
sets `novalidate`, RTextField marks the field with `aria-required` instead of
`required`, and an empty required field says so in an RTooltip whose text is
a new `required` chrome label backed by `common.required`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
// Translated backing for the v2 library's chrome labels (see
|
|
// `@/v2/lib/a11y/chromeLabels`). Primitives may not touch i18n, so the app
|
|
// builds the bundle here and provides it once.
|
|
//
|
|
// Each property is a getter, so `t` runs inside the reading component's
|
|
// render effect and a locale switch re-renders the labels. Utility code is
|
|
// allowed to call i18n.global directly, as `validation.ts` does.
|
|
import i18n from "@/locales";
|
|
import type { ChromeLabels } from "@/v2/lib/a11y/chromeLabels";
|
|
|
|
const t = (key: string) => i18n.global.t(key);
|
|
|
|
export function createChromeLabels(): ChromeLabels {
|
|
return {
|
|
get close() {
|
|
return t("common.close");
|
|
},
|
|
get cancel() {
|
|
return t("common.cancel");
|
|
},
|
|
get clear() {
|
|
return t("common.clear");
|
|
},
|
|
get remove() {
|
|
return t("common.remove");
|
|
},
|
|
get all() {
|
|
return t("common.all");
|
|
},
|
|
get previous() {
|
|
return t("common.previous");
|
|
},
|
|
get next() {
|
|
return t("common.next");
|
|
},
|
|
get datePicker() {
|
|
return t("common.date-picker");
|
|
},
|
|
get previousYear() {
|
|
return t("common.previous-year");
|
|
},
|
|
get previousMonth() {
|
|
return t("common.previous-month");
|
|
},
|
|
get nextMonth() {
|
|
return t("common.next-month");
|
|
},
|
|
get nextYear() {
|
|
return t("common.next-year");
|
|
},
|
|
get today() {
|
|
return t("common.today");
|
|
},
|
|
get required() {
|
|
return t("common.required");
|
|
},
|
|
step: (current, total) =>
|
|
i18n.global.t("common.step-of", { current, total }),
|
|
};
|
|
}
|