Dynamic values

  • To handle dynamic translations, just add an object with all necessary dynamic values

  • To make it work, you need to surround the dynamic values by double underscores in your JSON files (__dynamicValue__)

"user": {
    "describe": {
      "simple": "You are __name__",
      "complex": "You are __name__ and you like __hobby__"
    }
  }
import React from "react";
import { useT } from "talkr";

export default function MyComponent() {
  const { T } = useT();
  return (
    <>
      <h1>{T("user.describe.complex", { name: "joe", hobby: "coding" })}</h1>
    </>
  );
}

Last updated