SwiftMoment
SwiftMoment copied to clipboard
Local en_CA provides empty strings for fromNow()
If your Region is Canada, the system should use the base en strings because en_CA is not provided. Instead, we see empty strings.
this is an ios9 change; region is now tacked onto the end of locales (it's even more troublesome for chinese languages e.g. zh-Hant_CN, etc)
some discussion here re: locale http://stackoverflow.com/questions/32976486/nslocale-preferredlanguages-contains-us-since-ios-9
I think while user region and language settings may be diverse, we may or may not want to enforce locale settings according to languages supported by the app. (i.e. my app supports english and chinese version only, so maybe I would only want to ensure those 2 language for strings?)
Question: Is there a way to set "global" locale for SwiftMoment? Would like to avoid passing locale during init.
let availableLanguages = ["ar", "bg", "cs", "da", "de", "en_US", "en", "es", "fi", "fr", "gre", "he", "hu", "is", "it", "ja", "ko", "lv", "ms", "nb", "pl", "pt-PT", "ro", "ru", "sk", "sq", "sv", "th", "tr", "uk", "vi", "zh-Hans", "zh-Hant"]
let localeIdentifier = NSBundle.preferredLocalizationsFromArray(availableLanguages).first ?? self.locale.localeIdentifier
print ("best matched lang: \(localeIdentifier)")