Seems like you are looking for the name of each identifier. You can get those from the NSLocale
like:
Locale.availableIdentifiers.map {
(id: $0, name: (NSLocale.current as NSLocale).displayName(forKey: .languageCode, value: $0) ?? "-")
}
So you can rise them as you like. For example, showing them in a list:
struct ContentView: View {
let localeSheet: [(id: String, name: String)] = {
Locale.availableIdentifiers.map {
(id: $0, name: (NSLocale.current as NSLocale).displayName(forKey: .languageCode, value: $0) ?? "-")
}.sorted { $0.name < $1.name }
}()
var body: some View {
List(localeSheet, id: .id) {
Text($0.name)
Spacer()
Text($0.id)
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…