I'm developing an App on IOS which will get some information from Wikipedia. I should request the information from Wikipedia based on user language.
For example in english the URL is: https://en.wikipedia.org/w/api.php?...
but in french it's: https://fr.wikipedia.org/w/api.php?...
Is there a service on Wikipedia to find the appropriate base URL?
At this time I have written the following code but I'm not sure it's the best way to proceed and if it will work with all languages.
let locaLanguageCode = NSLocale.currentLocale().objectForKey(NSLocaleLanguageCode) as? String
var languageCode = "en"
if let newLanguage = locaLanguageCode {
languageCode = newLanguage
}
Alamofire.request(.GET, "https://" + languageCode + ".wikipedia.org/w/api.php", parameters: ["action": "query", "list" : "geosearch", "gscoord" : "48.804318|2.122081", "gsradius" : "10000", "gslimit" : "10", "format" : "json"])
.responseJSON { response in
debugPrint(response)
print("Request \(response.request)") // original URL request
print("Response \(response.response)") // URL response
print("Data \(response.data)") // server data
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
}