I am working on a simple command that uses an external API to translate a phrase to pirate lingo.
The code:
$(eval text=$(urlfetch json https://api.funtranslations.com/translate/pirate.json?text=$(1)); translation=text.contents.translated)
An example of the JSON output from the API call (the URL fetched is https://api.funtranslations.com/translate/pirate.json?text=hello%20guys):
{
“success”: {
“total”: 1
},
“contents”: {
“translated”: “Ahoy guys”,
“text”: “hello guys”,
“translation”: “pirate”
}
}
For some reason the output is always the first word, not the entire string.
I am sure I made a mistake somewhere but I really cannot see it. Any help will be greatly appreciated