Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Use preferredLocalizations #5

Open
ksmandersen opened this issue Jan 2, 2015 · 0 comments
Open

Use preferredLocalizations #5

ksmandersen opened this issue Jan 2, 2015 · 0 comments

Comments

@ksmandersen
Copy link
Member

From http://nshipster.com/new-years-2015/#nsbundle--preferredlocalizations.

Sometimes, you need to know which language your app is running in. Often, people will use NSLocale +preferredLanguages. Unfortunately this tells nothing about the language the app is actually displaying. It will just give you the ordered list as found in "Settings → General → Language & Region → Preferred Language" Order on iOS, or "System Preferences → Language & Region → Preferred Languages" on OS X.

Imagine that the preferred language order is {English, French} but your app is German only. Calling [[NSLocale preferredLanguages] firstObject] will give you English when you want German.

The proper way to get the actual language used by the app is to use [[NSBundle mainBundle] preferredLocalizations].

I believe this also solves your issue @duemunk.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant