translate / amagama

Web service for implementing a large-scale translation memory
http://amagama.translatehouse.org
GNU General Public License v3.0
90 stars 27 forks source link

JSON support #3206

Closed mzeidhassan closed 8 years ago

mzeidhassan commented 8 years ago

Hello team,

I am trying to get data out of amagama server to a Drupal site. I am using a module that retrieves data from JSON. Here is a link to the tutorial http://frontmag.no/artikler/utvikling/show-external-json-data-drupal-views, but for some reason it doesn't work because there is no key given when I go for example to http://0.0.0.0.0:8888/tmserver/en/ar/unit/review

Here is what I get when I go to that path:

[{
    "quality": 83.33333333333334,
    "rank": 100.0,
    "source": "Review",
    "target": "تحكيم"
}, {
    "quality": 71.42857142857143,
    "rank": 100.0,
    "source": "Reviews",
    "target": "استعراض"
}]

The Drupal module requires a path to the JSON file. Where is this located in amagama installation? I hope you can really help me with this one since I am not familiar with JSON.

Thanks again for your support and the prompt replies. I appreciate it.

Kind regards, Mohamed

unho commented 8 years ago

I am not sure I follow. What you got is valid JSON. The view that created it is https://github.com/translate/amagama/blob/master/amagama/views/api.py#L68-L80

mzeidhassan commented 8 years ago

I need to pass the URL of the JSON file to the module. What is the path or URL to the JSON file? The JSON file output should be as follows.

{
  'term':[
    {
      'source': 'review',
      'target': 'مراجعة',
    },
...
]}

As you can see, there is a key here in this format, but in Amagama output, there is no key.

unho commented 8 years ago

amaGama returns valid JSON. I checked with four random JSON validators I found googling:

So I don't understand what is your problem with that output. Perhaps are you having trouble to parse it?

unho commented 8 years ago

We got no further feedback, so closing this.