0

I am making an app where I want to detect the language of the current country that the iPhone is in. By this I don't mean the locale (which doesn't change if you're vacationing in a foreign country). Ex: If I live in the US and travel to Mexico, I want the detected language to be Spanish.

I am willing to use the GoogleMaps pod if necessary. Just wondering if there's an easier way built into the iOS frameworks. I see a lot of SO questions / answers using NSLocale but people warning that it's only for the phone setting.

p.s. I'm using Swift

bigpotato
  • 26,262
  • 56
  • 178
  • 334
  • Keep in mind that lots of countries have people that speak several different languages. – rmaddy Dec 05 '15 at 03:34
  • i guess i would just have to create a dictionary of all the national languages, and default to english if not found – bigpotato Dec 05 '15 at 03:35
  • for user location i think this one can help : http://stackoverflow.com/questions/25296691/swift-get-users-current-location-coordinates – Or Assraf Dec 05 '15 at 04:54

2 Answers2

1

You can use CLLocation Manager, to obtain current country (by using placemarks). But then you need to somehow check if you have the language for particular country is available in your app (for example create a dictionary of all languages and compare it, as you mentioned in the comment). There are no frameworks to get current country language in iOS. You need to build your own logic.

m.aibin
  • 3,528
  • 4
  • 28
  • 47
-1

you are better off defaulting to the language setting of the device. Let the device dictate the language as that is the language the user wants to use.