Home > Back-end >  How can I translate dynamic sentence with react i18next?
How can I translate dynamic sentence with react i18next?

Time:12-09

So I want something like this to show on my page:

there are ${number} monkeys living in our zoo

so the number is a number got from server

My question is how to use t function from react-18nex to do it and what should I do in my locales files for translate?

many thanks

CodePudding user response:

You can use {{ }} in your language json file like,

hello: "hello, {{username}}"

and use it like that:

 i18n.t("hello",{username:"hasankzl"})
  • Related