i18next / i18next-express-middleware

[deprecated] can be replaced with i18next-http-middleware
https://github.com/i18next/i18next-http-middleware
MIT License
206 stars 52 forks source link

translation returns [object Object] #188

Open sowmiyaseshadriii opened 5 years ago

sowmiyaseshadriii commented 5 years ago

Hi Team,

I would like to know how to stringify the [object Object] in the i18next translation. the configuration and translation all works fine but when i try to fetch whole object , it shows up
[object Object]

//en.json
{
"country":{
   "SG": "Singapore",
   "IN": "India",
   "AU": "Australia"
 }
}
//front end (ejs)
<div>
              <select class="form-control">
                  <option><%-t("country",{returnObjects: true})%></option> // shows [object Object]
                </select>
</div>

can you please help , tried JSON.stringify like below

<%-t(JSON.stringify("country"),{returnObjects: true})%> // shows country
jamuhl commented 5 years ago
<option><%-JSON.stringify(t("country",{returnObjects: true}))%></option>

should work