i'm developing app on ios information wikipedia. should request information wikipedia based on user language.
for example in english url is: https://en.wikipedia.org/w/api.php?...
but in french it's: https://fr.wikipedia.org/w/api.php?...
is there service on wikipedia find appropriate base url?
at time have written following code i'm not sure it's best way proceed , if work 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)") } }
Comments
Post a Comment