2

I'd like to figure out the system's preferred language, I've put at the top in the system's preferences. I was hoping Locale.preferredLanguages or Locale.current would work, unfortunately it seems to only return those languages that are also supported in the application's bundle.

enter image description here

Daniel
  • 1,473
  • 3
  • 33
  • 63

2 Answers2

6

The reason why I didn't get the preferred language was because I set Application Language to English in the options of my Xcode Scheme. If you don't have it on System Language, Locale.preferredLanguages or Locale.current will always just return the language you specified (of cause).

enter image description here

Daniel
  • 1,473
  • 3
  • 33
  • 63
2

Locale.current is correct and will work, but it may require you to restart the app or your computer if you changed languages recently.

print(Locale.current.debugDescription)

Outputs my system language sv_SE (current) for me on a non-localised project.

Oskar
  • 3,625
  • 2
  • 29
  • 37
  • 1
    Thanks Oskar, that should work of cause. So does `Locale.preferredLanguages[0]`. The cause of my issue was elsewhere (see my answer) – Daniel Apr 21 '17 at 09:14