Skip to content

Commit a921417

Browse files
committed
fix(tooltip): add i18n
1 parent df1c2b1 commit a921417

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Tooltip.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Equals } from "tsafe";
33
import { assert } from "tsafe/assert";
44
import { symToStr } from "tsafe/symToStr";
55
import { useAnalyticsId } from "./tools/useAnalyticsId";
6+
import { createComponentI18nApi } from "./i18n";
67

78
export type TooltipProps = TooltipProps.WithClickAction | TooltipProps.WithHoverAction;
89

@@ -30,6 +31,8 @@ export const Tooltip = memo(
3031
const { id: id_prop, className, description, kind, children, ...rest } = props;
3132
assert<Equals<keyof typeof rest, never>>();
3233

34+
const { t } = useTranslation();
35+
3336
const id = useAnalyticsId({
3437
"defaultIdPrefix": "fr-tooltip",
3538
"explicitlyProvidedId": id_prop
@@ -63,7 +66,7 @@ export const Tooltip = memo(
6366
aria-describedby={id}
6467
id={`tooltip-owner-${id}`}
6568
>
66-
Information contextuelle
69+
{t("tooltip-button-text")}
6770
</button>
6871
) : (
6972
displayChildren(children, id)
@@ -97,4 +100,20 @@ export const Tooltip = memo(
97100

98101
Tooltip.displayName = symToStr({ Tooltip });
99102

103+
const { useTranslation, addTooltipTranslations } = createComponentI18nApi({
104+
"componentName": symToStr({ Tooltip }),
105+
"frMessages": {
106+
"tooltip-button-text": "Information contextuelle"
107+
}
108+
});
109+
110+
addTooltipTranslations({
111+
"lang": "en",
112+
"messages": {
113+
"tooltip-button-text": "Contextual information"
114+
}
115+
});
116+
117+
export { addTooltipTranslations };
118+
100119
export default Tooltip;

0 commit comments

Comments
 (0)