(
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore import.meta.glob is supported by Vite
+ import.meta.glob('./*.json', {
+ eager: true,
+ }),
+);
diff --git a/packages/circuit-ui/components/DateInput/translations/it-CH.json b/packages/circuit-ui/components/DateInput/translations/it-CH.json
new file mode 100644
index 0000000000..310ba513ec
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/it-CH.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Anno",
+ "monthInputLabel": "Mese",
+ "dayInputLabel": "Giorno",
+ "openCalendarButtonLabel": "Modifica data",
+ "closeCalendarButtonLabel": "Chiudi calendario",
+ "applyDateButtonLabel": "Applica data",
+ "clearDateButtonLabel": "Rimuovi data"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/it-IT.json b/packages/circuit-ui/components/DateInput/translations/it-IT.json
new file mode 100644
index 0000000000..310ba513ec
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/it-IT.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Anno",
+ "monthInputLabel": "Mese",
+ "dayInputLabel": "Giorno",
+ "openCalendarButtonLabel": "Modifica data",
+ "closeCalendarButtonLabel": "Chiudi calendario",
+ "applyDateButtonLabel": "Applica data",
+ "clearDateButtonLabel": "Rimuovi data"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/lt-LT.json b/packages/circuit-ui/components/DateInput/translations/lt-LT.json
new file mode 100644
index 0000000000..3040347e7f
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/lt-LT.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Metai",
+ "monthInputLabel": "Mėnuo",
+ "dayInputLabel": "Diena",
+ "openCalendarButtonLabel": "Keisti datą",
+ "closeCalendarButtonLabel": "Uždaryti kalendorių",
+ "applyDateButtonLabel": "Taikyti datą",
+ "clearDateButtonLabel": "Išvalyti datą"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/lv-LV.json b/packages/circuit-ui/components/DateInput/translations/lv-LV.json
new file mode 100644
index 0000000000..4983f17a04
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/lv-LV.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Gads",
+ "monthInputLabel": "Mēnesis",
+ "dayInputLabel": "Diena",
+ "openCalendarButtonLabel": "Mainīt datumu",
+ "closeCalendarButtonLabel": "Aizvērt kalendāru",
+ "applyDateButtonLabel": "Piemērot datumu",
+ "clearDateButtonLabel": "Notīrīt datumu"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/nb-NO.json b/packages/circuit-ui/components/DateInput/translations/nb-NO.json
new file mode 100644
index 0000000000..520258708a
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/nb-NO.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "År",
+ "monthInputLabel": "Måned",
+ "dayInputLabel": "Dag",
+ "openCalendarButtonLabel": "Endre dato",
+ "closeCalendarButtonLabel": "Lukk kalender",
+ "applyDateButtonLabel": "Bruk dato",
+ "clearDateButtonLabel": "Slett dato"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/nl-BE.json b/packages/circuit-ui/components/DateInput/translations/nl-BE.json
new file mode 100644
index 0000000000..fcda3b845b
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/nl-BE.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Jaar",
+ "monthInputLabel": "Maand",
+ "dayInputLabel": "Dag",
+ "openCalendarButtonLabel": "Datum wijzigen",
+ "closeCalendarButtonLabel": "Agenda sluiten",
+ "applyDateButtonLabel": "Datum toepassen",
+ "clearDateButtonLabel": "Datum wissen"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/nl-NL.json b/packages/circuit-ui/components/DateInput/translations/nl-NL.json
new file mode 100644
index 0000000000..fcda3b845b
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/nl-NL.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Jaar",
+ "monthInputLabel": "Maand",
+ "dayInputLabel": "Dag",
+ "openCalendarButtonLabel": "Datum wijzigen",
+ "closeCalendarButtonLabel": "Agenda sluiten",
+ "applyDateButtonLabel": "Datum toepassen",
+ "clearDateButtonLabel": "Datum wissen"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/pl-PL.json b/packages/circuit-ui/components/DateInput/translations/pl-PL.json
new file mode 100644
index 0000000000..fbfa42c141
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/pl-PL.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Rok",
+ "monthInputLabel": "Miesiąc",
+ "dayInputLabel": "Dzień",
+ "openCalendarButtonLabel": "Zmień datę",
+ "closeCalendarButtonLabel": "Zamknij kalendarz",
+ "applyDateButtonLabel": "Zastosuj datę",
+ "clearDateButtonLabel": "Usuń datę"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/pt-BR.json b/packages/circuit-ui/components/DateInput/translations/pt-BR.json
new file mode 100644
index 0000000000..22096f95a2
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/pt-BR.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Ano",
+ "monthInputLabel": "Mês",
+ "dayInputLabel": "Dia",
+ "openCalendarButtonLabel": "Alterar data",
+ "closeCalendarButtonLabel": "Fechar agenda",
+ "applyDateButtonLabel": "Aplicar data",
+ "clearDateButtonLabel": "Limpar data"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/pt-PT.json b/packages/circuit-ui/components/DateInput/translations/pt-PT.json
new file mode 100644
index 0000000000..f401597430
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/pt-PT.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Ano",
+ "monthInputLabel": "Mês",
+ "dayInputLabel": "Dia",
+ "openCalendarButtonLabel": "Alterar data",
+ "closeCalendarButtonLabel": "Fechar calendário",
+ "applyDateButtonLabel": "Aplicar data",
+ "clearDateButtonLabel": "Limpar data"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/ro-RO.json b/packages/circuit-ui/components/DateInput/translations/ro-RO.json
new file mode 100644
index 0000000000..4ba85f22de
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/ro-RO.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "An",
+ "monthInputLabel": "Lună",
+ "dayInputLabel": "Zi",
+ "openCalendarButtonLabel": "Modifică data",
+ "closeCalendarButtonLabel": "Închide calendarul",
+ "applyDateButtonLabel": "Aplică data",
+ "clearDateButtonLabel": "Șterge data"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/sk-SK.json b/packages/circuit-ui/components/DateInput/translations/sk-SK.json
new file mode 100644
index 0000000000..b1f5665ada
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/sk-SK.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Rok",
+ "monthInputLabel": "Mesiac",
+ "dayInputLabel": "Deň",
+ "openCalendarButtonLabel": "Zmeniť dátum?",
+ "closeCalendarButtonLabel": "Zatvoriť kalendár",
+ "applyDateButtonLabel": "Vybrať dátum",
+ "clearDateButtonLabel": "Vymazať dátum"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/sl-SI.json b/packages/circuit-ui/components/DateInput/translations/sl-SI.json
new file mode 100644
index 0000000000..da53cc8061
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/sl-SI.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "Leto",
+ "monthInputLabel": "Mesec",
+ "dayInputLabel": "Dan",
+ "openCalendarButtonLabel": "Spremeni datum",
+ "closeCalendarButtonLabel": "Zapri koledar",
+ "applyDateButtonLabel": "Uporabi datum",
+ "clearDateButtonLabel": "Počisti datum"
+}
diff --git a/packages/circuit-ui/components/DateInput/translations/sv-SE.json b/packages/circuit-ui/components/DateInput/translations/sv-SE.json
new file mode 100644
index 0000000000..42dc825800
--- /dev/null
+++ b/packages/circuit-ui/components/DateInput/translations/sv-SE.json
@@ -0,0 +1,9 @@
+{
+ "yearInputLabel": "År",
+ "monthInputLabel": "Månad",
+ "dayInputLabel": "Dag",
+ "openCalendarButtonLabel": "Ändra datum",
+ "closeCalendarButtonLabel": "Stäng kalendern",
+ "applyDateButtonLabel": "Välj datum",
+ "clearDateButtonLabel": "Rensa datum"
+}
diff --git a/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.spec.tsx b/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.spec.tsx
index 86f62b4f18..95c95bf5c7 100644
--- a/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.spec.tsx
+++ b/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.spec.tsx
@@ -98,7 +98,7 @@ describe('PhoneNumberInput', () => {
subscriberNumber: { ...defaultProps.subscriberNumber, ref },
};
render(
);
- const input = screen.getByLabelText('Subscriber number');
+ const input = screen.getByLabelText(/Subscriber number/);
expect(ref.current).toBe(input);
});
@@ -155,7 +155,7 @@ describe('PhoneNumberInput', () => {
const { container } = render(
);
const input = getHiddenInput(container);
const countryCode = screen.getByLabelText('Country code');
- const subscriberNumber = screen.getByLabelText('Subscriber number');
+ const subscriberNumber = screen.getByLabelText(/Subscriber number/);
expect(input).toHaveValue('+4912345678');
expect(countryCode).toHaveValue('DE');
expect(subscriberNumber).toHaveValue('12345678');
@@ -169,7 +169,7 @@ describe('PhoneNumberInput', () => {
const { container } = render(
);
const input = getHiddenInput(container);
const countryCode = screen.getByLabelText('Country code');
- const subscriberNumber = screen.getByLabelText('Subscriber number');
+ const subscriberNumber = screen.getByLabelText(/Subscriber number/);
expect(input).toHaveValue('+4912345678');
expect(countryCode).toHaveValue('DE');
expect(subscriberNumber).toHaveValue('12345678');
@@ -182,7 +182,7 @@ describe('PhoneNumberInput', () => {
rerender(
);
const input = getHiddenInput(container);
const countryCode = screen.getByLabelText('Country code');
- const subscriberNumber = screen.getByLabelText('Subscriber number');
+ const subscriberNumber = screen.getByLabelText(/Subscriber number/);
expect(input).toHaveValue('+112345678');
expect(countryCode).toHaveValue('CA');
expect(subscriberNumber).toHaveValue('12345678');
@@ -225,7 +225,7 @@ describe('PhoneNumberInput', () => {
},
};
render(
);
- const input = screen.getByLabelText('Subscriber number');
+ const input = screen.getByLabelText(/Subscriber number/);
await userEvent.type(input, '1');
expect(onChange).toHaveBeenCalledOnce();
});
@@ -246,7 +246,7 @@ describe('PhoneNumberInput', () => {
},
};
render(
);
- const input = screen.getByLabelText('Subscriber number');
+ const input = screen.getByLabelText(/Subscriber number/);
await userEvent.click(input);
await userEvent.paste(phoneNumber);
expect(props.ref.current).toHaveValue('+4912345678');
@@ -270,7 +270,7 @@ describe('PhoneNumberInput', () => {
},
};
render(
);
- const input = screen.getByLabelText('Subscriber number');
+ const input = screen.getByLabelText(/Subscriber number/);
await userEvent.click(input);
await userEvent.paste('012345678');
expect(props.ref.current).toHaveValue('+112345678');
@@ -288,7 +288,7 @@ describe('PhoneNumberInput', () => {
},
};
render(
);
- const input = screen.getByLabelText('Subscriber number');
+ const input = screen.getByLabelText(/Subscriber number/);
expect(input).toBeValid();
});
@@ -301,7 +301,7 @@ describe('PhoneNumberInput', () => {
},
};
render(
);
- const input = screen.getByLabelText('Subscriber number');
+ const input = screen.getByLabelText(/Subscriber number/);
expect(input).toBeInvalid();
});
diff --git a/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.stories.tsx b/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.stories.tsx
index 27d452b94c..a857f17c9d 100644
--- a/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.stories.tsx
+++ b/packages/circuit-ui/components/PhoneNumberInput/PhoneNumberInput.stories.tsx
@@ -76,6 +76,7 @@ export const Validations = (args: PhoneNumberInputProps) => (
(
),
diff --git a/packages/circuit-ui/components/Toggletip/Toggletip.tsx b/packages/circuit-ui/components/Toggletip/Toggletip.tsx
index bb2ba05b0c..f5f547d54e 100644
--- a/packages/circuit-ui/components/Toggletip/Toggletip.tsx
+++ b/packages/circuit-ui/components/Toggletip/Toggletip.tsx
@@ -49,8 +49,11 @@ import { CloseButton } from '../CloseButton/index.js';
import { Headline } from '../Headline/index.js';
import { Body } from '../Body/index.js';
import { Button, type ButtonProps } from '../Button/index.js';
+import { useI18n } from '../../hooks/useI18n/useI18n.js';
+import type { Locale } from '../../util/i18n.js';
import classes from './Toggletip.module.css';
+import { translations } from './translations/index.js';
export interface ToggletipReferenceProps {
'id': string;
@@ -84,7 +87,7 @@ export interface ToggletipProps extends HTMLAttributes {
/**
* Label for the toggletip's close button.
*/
- closeButtonLabel: string;
+ closeButtonLabel?: string;
/**
* Whether the toggletip is initially open. Default: 'false'.
*/
@@ -105,11 +108,18 @@ export interface ToggletipProps extends HTMLAttributes {
* Default: 12.
*/
offset?: number | { mainAxis?: number; crossAxis?: number };
+ /**
+ * One or more [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag)
+ * locale identifiers such as `'de-DE'` or `['GB', 'en-US']`.
+ * When passing an array, the first supported locale is used.
+ * Defaults to `navigator.language` in supported environments.
+ */
+ locale?: Locale;
}
export const Toggletip = forwardRef(
- (
- {
+ (props, ref) => {
+ const {
defaultOpen = false,
placement: defaultPlacement = 'top',
offset = 12,
@@ -120,10 +130,9 @@ export const Toggletip = forwardRef(
closeButtonLabel,
className,
style,
- ...props
- },
- ref,
- ) => {
+ locale,
+ ...rest
+ } = useI18n(props, translations);
const zIndex = useStackContext();
const isMobile = useMedia('(max-width: 479px)');
const arrowRef = useRef(null);
@@ -244,7 +253,7 @@ export const Toggletip = forwardRef(
{/* eslint-disable jsx-a11y/no-autofocus */}
{/* @ts-expect-error "Expression produces a union type that is too complex to represent" */}