Skip to content

Instantly share code, notes, and snippets.

@Alexander-Ignition
Created October 11, 2018 06:44
Show Gist options
  • Save Alexander-Ignition/2c752b05a64ab0feb62b7af935c20999 to your computer and use it in GitHub Desktop.
Save Alexander-Ignition/2c752b05a64ab0feb62b7af935c20999 to your computer and use it in GitHub Desktop.
Currency Symbol
extension Locale {
static func locale(forCurrencyCode currencyCode: String) -> Locale? {
return availableIdentifiers.lazy
.map { Locale(identifier: $0) }
.first { $0.currencyCode == currencyCode }
}
static func currencySymbol(forCurrencyCode currencyCode: String) -> String? {
return locale(forCurrencyCode: currencyCode).flatMap { $0.currencySymbol }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment