What are the best practices for JSON response from multi lingual API

Viewed 2389

I wanted to add languages to the current API response in English. The current API response looks like this:

{
   status : "success",
   data : {
    query: "contains search query",
    queryType: "search"

    results: [
        {
            title: "Marvel Captain America T-shirt",
            price: 624,
            category: "t-shirt",
            gender: "men",                  
        },
        .....
    ],
    language: "english",
    currency: "rupee",    
   }
}

There are two ways I can go about developing the API, one would be to use different cores for API response, and call according to language preference in the app but my app also requires certain English elements to be preserved. The other way being to put all the languages in the response with a certain structure to differentiate each one. In either case I want the english elements to be preserved.

So if gender: 'men', but language is french, so I want an additional field like gender_display: 'hommes' or gender_fr: 'hommes'

Addition: The search results are coming from Solr

2 Answers
Related