如何遍历数组ini18next翻译ejs

时间:2019-06-17 03:48:11

标签: javascript arrays object ejs i18next

我已经使用i18next实现了翻译, https://github.com/i18next/i18next 我正在尝试迭代前端的嵌套数组,但无法在翻译模式下工作,https://www.i18next.com/translation-function/objects-and-arrays请帮助

en.json

{
  "title": "List of Countries",
  "list":[{
     "name": "Singapore",
     "code": "SG"
  },{
    "name": "Thailand",
    "code": "TH"
 }]
}


index.ejs

<h2><%=t("list.0.name")%></h2> //working fine

//using map not working

<% t("list").map(e=>{%>
  <a href="#"><%=t(e.name)%></a>
<%})%>

0 个答案:

没有答案