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.
Asked
Active
Viewed 1,610 times
2

Daniel
- 1,473
- 3
- 33
- 63
2 Answers
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).

Daniel
- 1,473
- 3
- 33
- 63
-
1Thank you for mentioning the Xcode Scheme took hours to find the issue. – Luai Kalkatawi Oct 20 '18 at 10:47
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
-
1Thanks 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