Skip to main content

Locale

  • Access and update the locale by using the hook useT()
  • If the provided locale doesn't match any JSON translation files, Talkr will use the defaultLanguage sent to the provider.
import React, { useState } from "react";
import { useT } from "talkr";

export default function MyComponent() {
const { T, setLocale, locale } = useT();
return (
<>
<h1>{T("hello")}</h1>
<p>{locale}</p>
<button onClick={() => setLocale("fr")}>speak french</button>
</>
);
}