@@ -3,6 +3,7 @@ import type { Equals } from "tsafe";
3
3
import { assert } from "tsafe/assert" ;
4
4
import { symToStr } from "tsafe/symToStr" ;
5
5
import { useAnalyticsId } from "./tools/useAnalyticsId" ;
6
+ import { createComponentI18nApi } from "./i18n" ;
6
7
7
8
export type TooltipProps = TooltipProps . WithClickAction | TooltipProps . WithHoverAction ;
8
9
@@ -30,6 +31,8 @@ export const Tooltip = memo(
30
31
const { id : id_prop , className, description, kind, children, ...rest } = props ;
31
32
assert < Equals < keyof typeof rest , never > > ( ) ;
32
33
34
+ const { t } = useTranslation ( ) ;
35
+
33
36
const id = useAnalyticsId ( {
34
37
"defaultIdPrefix" : "fr-tooltip" ,
35
38
"explicitlyProvidedId" : id_prop
@@ -63,7 +66,7 @@ export const Tooltip = memo(
63
66
aria-describedby = { id }
64
67
id = { `tooltip-owner-${ id } ` }
65
68
>
66
- Information contextuelle
69
+ { t ( "tooltip-button-text" ) }
67
70
</ button >
68
71
) : (
69
72
displayChildren ( children , id )
@@ -97,4 +100,20 @@ export const Tooltip = memo(
97
100
98
101
Tooltip . displayName = symToStr ( { Tooltip } ) ;
99
102
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
+
100
119
export default Tooltip ;
0 commit comments