@@ -3,6 +3,7 @@ import type { Equals } from "tsafe";
33import { assert } from "tsafe/assert" ;
44import { symToStr } from "tsafe/symToStr" ;
55import { useAnalyticsId } from "./tools/useAnalyticsId" ;
6+ import { createComponentI18nApi } from "./i18n" ;
67
78export 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
98101Tooltip . 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+
100119export default Tooltip ;
0 commit comments