0

I have developed a web app that allows you to upload a file i18n and editing. For convenience to edit the file I convert it into a json object, made the changes and subsequently drain the modified json file. Is there a way to convert json modified in a i18n string like to directly download the i18n?

 {
 "errors": {
 "cannot.fetch.credit":"Ops... non riesco a leggere il credito.",
 "not.enough.credit.to.buy":"Non hai abbastanza credito per comprare questo biglietto."
 },
 "status": {
"title": "Il tuo stato",
"scanqrbus": "Inquadra il QR code all'interno del bus",
"tickets": {
    "title": "Biglietto"
}
 },
"offline": {
"connectionless": "Connessione assente",
"reconnect": "Riconnetti",
"nostart": "Puoi prenotare biglietti solo quando la connessione è attiva",
"nosignup": "Connessione assente"
}

}

Get a thing like this?

     i18n.map("it", {
     errors: {
   "cannot.fetch.credit":"Ops... non riesco a leggere il credito.",
   "not.enough.credit.to.buy":"Non hai abbastanza credito per comprare      questo biglietto."
},
   status: {
   title: "Il tuo stato",
   scanqrbus: "Inquadra il QR code all'interno del bus",
   tickets: {
   title: "Biglietto"
      }
   },
   offline: {
   connectionless: "Connessione assente",
   reconnect: "Riconnetti",
   nostart: "Puoi prenotare biglietti solo quando la connessione è attiva",
   nosignup: "Connessione assente"
 }});

There is a similar method to JSON.parse() ?

Mister98
  • 69
  • 1
  • 8
  • Not quite sure what you're asking - do you want to start a download? or do you want to pass the results of `JSON.parse` to a `i18n.map` method (and if so what's the problem with doing that)? – Dominic May 15 '16 at 19:04
  • @DominicTobias I want to have the same object that step at the start, with changed values. And then saw the object departing is transformed into a json, I want to convert a json in a i18n. – Mister98 May 15 '16 at 19:06
  • @DominicTobias What do you mean by i18n.map method ? How can I do? – Mister98 May 15 '16 at 19:15
  • It's unclear what you're asking so I doubt you'll get an answer. Try and rephrase to be clearer (I think no one knows what you're trying to do) – Dominic May 16 '16 at 08:42
  • @DominicTobias I want to convert the json format in the i18n . I want to have a string containing the second piece of code. – Mister98 May 16 '16 at 11:28
  • I think people are confused because if you want a string why don't you just do `'i18n.map("it", ' + jsonString + ');'`? – Dominic May 16 '16 at 11:29
  • @DominicTobias I also thought of doing so , however, the json file is structurally different from how it must be for i18n . The keys associated with the item must not have the " ". "errors",for example,must be only errors without the "". – Mister98 May 16 '16 at 11:35
  • Ah ok I see - that's strange as it will break for keys with `-` for example – Dominic May 16 '16 at 13:27
  • http://stackoverflow.com/questions/11233498/json-stringify-without-quotes-on-properties – Dominic May 16 '16 at 13:28
  • 1
    Thanks :) Now it work – Mister98 May 16 '16 at 18:11

0 Answers0