Basic
In any component, import Talkr's hook
useT.Destructure the translation function
TfromuseTFetch the desired sentence as if you were directly accessing an object, by adding
.between each key. Based on the JSON example above, we could print the sentenceThe connection succedeedby simply writingT("feedback.success")
import React from "react";
import { useT } from "talkr";
export default function MyComponent() {
const { T } = useT();
return (
<>
<h1>{T("hello")}</h1>
<div>{T("feedback.success")}</div>
</>
);
}Last updated
