Currency name from currency codes doesn't work for all

Dear All,

Going through the list of currency codes in

Locale.commonISOCurrencyCodes

the following expression returns currency names

Locale.autoupdatingCurrent.localizedString(forCurrencyCode: currencyCode)

Surprisingly, this expression does not return names for some of the most common currency codes like EUR, USD and other.

How do I get a full list of names?

Any hint appreciated!

Answered by DTS Engineer in 794573022

This works on my machine. Consider this program:

import Foundation

func main() {
    let loc = Locale.autoupdatingCurrent
    print(loc.identifier)
    // en_GB
    print(loc.localizedString(forCurrencyCode: "GBP") ?? "-")
    // British Pound
    print(loc.localizedString(forCurrencyCode: "USD") ?? "-")
    // US Dollar
    print(loc.localizedString(forCurrencyCode: "EUR") ?? "-")
    // Euro
}

main()

I’m testing with a command-line tool project in Xcode 15.4 on macOS 14.5.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This works on my machine. Consider this program:

import Foundation

func main() {
    let loc = Locale.autoupdatingCurrent
    print(loc.identifier)
    // en_GB
    print(loc.localizedString(forCurrencyCode: "GBP") ?? "-")
    // British Pound
    print(loc.localizedString(forCurrencyCode: "USD") ?? "-")
    // US Dollar
    print(loc.localizedString(forCurrencyCode: "EUR") ?? "-")
    // Euro
}

main()

I’m testing with a command-line tool project in Xcode 15.4 on macOS 14.5.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Currency name from currency codes doesn't work for all
 
 
Q