-
Notifications
You must be signed in to change notification settings - Fork 0
Improve preferredLanguages based language selection fallback #129
Description
The logic for selecting a storm language in StormLanguageController eventually falls back to simply using the user's list of preferred languages for picking the language to show them. However at the moment this is a simple check which will only work with non-regional language codes such as es as apposed to en-US.
This means that if the languages available in Storm were usa_en and usa_es but the user had their phone set to es-SPA for example (Not sure if this even exists, it's just an example) this wouldn't be taken into account and the user would be shown the app in usa_en due to it being alphabetically first!
To fix this we need to compare on both the language and the locale, but first we need functions to standardise both the storm and iOS localisation codes to be ISO 639-2 (3 character language designator) + ISO 3166-1 alpha -3 (3 character region designator) so we can do the comparison.
Once we do that, languages with a full match (Both language and region) should be sorted first base on their position in Locale.preferredLanguages and then languages that just match the language designator!