Swift3
import Foundation
extension String {
func sliceFrom(start: String, to: String) -> String? {
return (range(of: start)?.upperBound).flatMap({ (sInd) -> String? in
(range(of: to, range: sInd..<endIndex)?.lowerBound).map { eInd in
substring(with: sInd..<eInd)
}
})
}
}
let englishLocale : NSLocale = NSLocale.init(localeIdentifier : "en_US")
let currentLocale = NSLocale.current
var theEnglishName : String? = englishLocale.displayName(forKey: NSLocale.Key.identifier, value: currentLocale.identifier)
if let theEnglishName = theEnglishName
{
countryName = theEnglishName.sliceFrom(start: "(", to: ")")
print("the localized country name is \(countryName)")
}