https://developer.foursquare.com/overview/versioning it says:
You can specify the locale by setting the Accept-Language HTTP header in your request. Alternatively, you can add a locale=XXX parameter to your request but HTTP header specification is preferred. We currently support en (default), es, fr, de, it, ja, th, tr, ko, ru, pt, and id.
and
If nothing is specified, for geographical entities (e.g., city names), we'll fall back to using the language that's most popular in the country for that venue.
Now, how do we get the locale of the API result? If I query with tr
locale, it may answer me back with en
or another fallback locale. I couldn't find it neither inside the results nor the response headers.
I need this to cache and show the users the right data. My website's fallback language is en
for example, but the API might give me de
for example.
Thanks.
Edit Here's an example of what I try to tell;
URL:
https://api.foursquare.com/v2/venues/4adcda50f964a520354121e3
?client_id=[client_id]&client_secret=[client_secret]&v=20161115&locale=tr
Headers:
array (
'Accept-Language' => 'tr',
'Accept' => 'application/json'
)
Result (Cropped some unrelated items):
{
"meta": {
"code": 200,
"requestId": "582bfe9e1ed21964a18d3aab"
},
"response": {
"venue": {
"id": "4adcda50f964a520354121e3",
"name": "La Pedrera (Casa Milà) (Casa Milà 'La Pedrera')",
"contact": {
"phone": "+34902202138",
"formattedPhone": "+34 902 20 21 38",
"twitter": "catfundacio",
"facebook": "429182007214758",
"facebookUsername": "lapedrera.barcelona",
"facebookName": "La Pedrera-Casa Milà"
},
"location": {
"address": "Pg. Gràcia, 92",
"crossStreet": "Carrer Provença",
"lat": 41.39509128050475,
"lng": 2.1618343621091296,
"postalCode": "08008",
"cc": "ES",
"city": "Barselona",
"state": "Cataluña",
"country": "İspanya",
"formattedAddress": [
"Pg. Gràcia, 92 (Carrer Provença)",
"08008 Barselona Catalonia",
"İspanya"
]
},
"canonicalUrl": "https:\/\/foursquare.com\/v\/la-pedrera-casa-mil%C3%A0\/4adcda50f964a520354121e3",
"categories": [
{
"id": "4bf58dd8d48988d12d941735",
"name": "Anıt \/ Abide",
"pluralName": "Anıtlar \/ Abideler",
"shortName": "Abide",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/building\/government_monument_",
"suffix": ".png"
},
"primary": true
},
{
"id": "4bf58dd8d48988d130941735",
"name": "Bina",
"pluralName": "Binalar",
"shortName": "Bina",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/building\/default_",
"suffix": ".png"
}
}
],
"description": "La Pedrera (Casa Milà) és un edifici construït per Antoni Gaudí i declarat Patrimoni de la Humanitat. Actualment és la seu de la Fundació Catalunya-La Pedrera.",
"storeId": "",
"tags": [
"gallery",
"gaudi",
"modernisme",
"museum",
"photobooth",
"sicted"
],
"shortUrl": "http:\/\/4sq.com\/72NCMi",
"timeZone": "Europe\/Madrid",
"hours": {
"status": "09:00'e kadar kapalı",
"isOpen": false,
"isLocalHoliday": false,
"timeframes": [
{
"days": "Pzt\u2013Paz",
"includesToday": true,
"open": [
{
"renderedTime": "09:00\u201321:00"
}
],
"segments": [
]
}
]
},
"attributes": {
"groups": [
{
"type": "wifi",
"name": "Kablosuz Bağlantı",
"summary": "Ücretsiz Wi-Fi",
"count": 1,
"items": [
{
"displayName": "Kablosuz Bağlantı",
"displayValue": "Ücretsiz"
}
]
}
]
},
"bestPhoto": {
"id": "55672a92498ec352981dd144",
"createdAt": 1432824466,
"source": {
"name": "Foursquare Web",
"url": "https:\/\/foursquare.com"
},
"prefix": "https:\/\/irs2.4sqi.net\/img\/general\/",
"suffix": "\/39082263_M0PK-NTv3A-0tI4j_aEIp5k6BEkliQTkMXS9TIPg_NQ.jpg",
"width": 620,
"height": 478,
"visibility": "public"
}
}
}
}
The addresses, categories, some of the names, timeframes, attributes
sections are in fact Turkish, but the description and the most of the names are in fallback/local language which is Spanish in this case.
The locale is not specified in the API response.
If you don't specify anything in the Accept-Language
HTTP header the response will default to the language that's most popular in the country. However, if you do specify a local the API won't fallback to anything else.
If your website's language is english, you can specify en
in the Accept-Language
HTTP header and the API will give you english too.