Merge remote-tracking branch 'origin/master' into swift-4.0-branch
diff --git a/Foundation/NSLocale.swift b/Foundation/NSLocale.swift
index 8cefe1d..266f377 100644
--- a/Foundation/NSLocale.swift
+++ b/Foundation/NSLocale.swift
@@ -28,7 +28,7 @@
}
open func object(forKey key: NSLocale.Key) -> Any? {
- return CFLocaleGetValue(_cfObject, key.rawValue._cfObject)
+ return _SwiftValue.fetch(CFLocaleGetValue(_cfObject, key.rawValue._cfObject))
}
open func displayName(forKey key: Key, value: String) -> String? {
@@ -91,7 +91,7 @@
extension NSLocale {
public var localeIdentifier: String {
- return (object(forKey: .identifier) as! NSString)._swiftObject
+ return object(forKey: .identifier) as! String
}
open class var availableLocaleIdentifiers: [String] {
diff --git a/TestFoundation/TestNSLocale.swift b/TestFoundation/TestNSLocale.swift
index bfd69ad..02a22cd 100644
--- a/TestFoundation/TestNSLocale.swift
+++ b/TestFoundation/TestNSLocale.swift
@@ -22,6 +22,7 @@
("test_Identifier", test_Identifier),
("test_copy", test_copy),
("test_availableIdentifiers", test_availableIdentifiers),
+ ("test_localeProperties", test_localeProperties),
]
}
@@ -112,4 +113,14 @@
func test_availableIdentifiers() {
XCTAssertNoThrow(Locale.availableIdentifiers)
}
+
+ func test_localeProperties(){
+ let enUSID = "en_US"
+ let locale = Locale(identifier: enUSID)
+ XCTAssertEqual(String(describing: locale.languageCode!), "en")
+ XCTAssertEqual(String(describing: locale.decimalSeparator!), ".")
+ XCTAssertEqual(String(describing: locale.currencyCode!), "USD")
+ XCTAssertEqual(String(describing: locale.collatorIdentifier!), enUSID)
+ }
+
}