Requesting ability to fetch alpha 2 code of a country using just it's name
thecoffeehog opened this issue · 12 comments
I am unsure whether this is already present but based on the documentation of the plugin this seems to be absent as of now.
Hi @thecoffeehog, how would you want to use it? Just to make sure I fully understood your request.
@miguelpruivo Thanks for the quick response.
We are making an app for travellers, so user's system country may not be the user's country in which he/she currently is.
So we call the Google Maps API to get users location and then maybe call your plugin to get the Alpha 2 code by passing the country name from the Maps API.
We need the Alpha 2 code because our backend uses it, but I believe people will have other users for it as well.
@thecoffeehog using the country code directly to fetch the codes may not seem very reliable, because the country name can be in many languages, for example, United States can be United States or Estados Unidos (based on base language) but it's possible. This will only work if you get the country name in its original language, ie., United States, España, etc.
You don't have do country code? That way will work right away.
Oh, in my case I don't have the locale. I am thinking of using https://restcountries.eu/#api-endpoints-full-name to get the Alpha 2 code.
@thecoffeehog in which language are the country names that you get?
@miguelpruivo In US English
That's what I suspected @thecoffeehog. That way isn't really reliable that's why working with codes directly is always better. That API works for you with US English but if for some reason country name is in another language, it fails as well.
@miguelpruivo That's true. What do you suggest?
@thecoffeehog I believe that Google Maps API has a way to provide you with the country code, at least Places has.
@miguelpruivo Oh, I will check it. Thanks!
@thecoffeehog keep me updated. I'll leave this issue open for now, but feel free to close it if you find a solution.
Thanks!
@miguelpruivo Sure.