How can get an array`s value from JSON file by use of useTranslations() in nextjs13.4?

112 Views Asked by At

this is may json file sample:

{
    "nav":{
    "head":{"title":"ProjectName","logo":"/logo.svg","link": "/"},
    "menu":\[
    {"title":"Home","link":""},
    {"title":"Browse Jobs","link":"/jobs"},
    {"title":"Canditates","link":"/canditates"},
    {"title":"Contact US","link":"/contact"},
    {"title":"Blog","link":"/blog"},
    {"title":"login","link":"/login"},
    {"title":"Sign Up","link":"signin"}
      ]
     },
}




function Nav() {
    const t = useTranslations();
    const data = t("nav.menu");
    return(
    <div>
    {
    data.map((item,index)=>(
    <i>
    <Link href={item.link}>{item.title}</Link>
    </i>)
    )
    }
    </div>
   )}

I expect to have list of items. But I says map is not a function and code: 'INVALID_MESSAGE',originalMessage: 'Message at nav.menu resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages'

0

There are 0 best solutions below