Locale bugs

Originator:an00na
Number:rdar://27599001 Date Originated:28-Jul-2016 05:50 PM
Status:Open Resolved:
Product:iOS SDK Product Version:10.0 beta 3
Classification:Other Bug Reproducible:Always
 
Summary:
1. en_US and en-US are mixed: current and autoupdatingCurrent uses en_US for localeIdentifier but en-US for collatorIdentifier, inconsistent format. 
2. us1 == autoupdatingCurrent, autoupdatingCurrent == current, but current != us1, transitivity of equality is broken.
3. current and autoupdatingCurrent uses en-US for collatorIdentifier in app but en_US in playground, inconsistent.
4. displayName(forKey:value:) does not work for current and autoupdatingCurrent in playground, always returning nil.

Steps to Reproduce:
1. Run sample app and read console logs.
2. Run sample playground and read console logs.

Code:

        let us1 = Locale(localeIdentifier: "en_US")
        let us2 = Locale(localeIdentifier: "en-US")
        let current = Locale.current
        let autoupdatingCurrent = Locale.autoupdatingCurrent
        
        print("localeIdentifier:", us1.localeIdentifier, us2.localeIdentifier, current.localeIdentifier, autoupdatingCurrent.localeIdentifier)
        print("collatorIdentifier:", us1.collatorIdentifier, us2.collatorIdentifier, current.collatorIdentifier, autoupdatingCurrent.collatorIdentifier)
        
        print("us1 == us2", us1 == us2)
        print("us1 == current", us1 == current)
        print("us1 == autoupdatingCurrent", us1 == autoupdatingCurrent)
        print("us2 == current", us2 == current)
        print("us2 == autoupdatingCurrent", us2 == autoupdatingCurrent)
        print("current == autoupdatingCurrent", current == autoupdatingCurrent)
        
        print("us1 localized localeIdentifier:", us1.displayName(forKey: .identifier, value: us1.localeIdentifier))
        print("us2 localized localeIdentifier:", us2.displayName(forKey: .identifier, value: us2.localeIdentifier))
        print("current localized localeIdentifier:", current.displayName(forKey: .identifier, value: current.localeIdentifier))
        print("autoupdatingCurrent localized localeIdentifier:", autoupdatingCurrent.displayName(forKey: .identifier, value: autoupdatingCurrent.localeIdentifier))

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!