Post

Replies

Boosts

Views

Activity

Unable to detect changes to language from Settings post a initial manual override
We have a requirement in the App in which for certain countries/regions we have to support only certain languages. If the User's current language is not supported, We would have a custom fallback/default language for specific regions. like it could be Arabic for middle east countries, English for Europe etc. Since iOS localization allows fallback to only one Base localizations, we had to take a custom approach to implement the same. To achieve the same, we checked the User's current language and Country and if required we overrode the "kLanguageBundleKey" property within the Bundle class, and set the following user defaults, (here for example say english) Foundation.UserDefaults.standard.set(["en"], forKey: "AppleLanguages") Foundation.UserDefaults.standard.synchronize(). And it works! The problem is that in iOS, post this override, when the user changes language from the Phone's settings app. Launches our app, Bundle.main.preferredLocalizations.first always gives what we overwrote and not the one present in the Phone's settings. Given this, Is there way to get the user's current language even after such overrides? or should we do the language overrides some other way?
1
0
114
3d