UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Changing Locale in a playground (Xcode 12.6 beta)

Forums > Swift

@daa  

I watched the talk "Formatters: Make data human-friendiy" from WWDC 2020 and want to understand/reproduce the examples, especially for "How we can make well-formated lists"

Question: What do I have to change in my playground to reproduce the results of the examples.

// English Localisation
let items = [ "English", "French", "Spanish"]
ListFormatter.localizedString(byJoining: items)

let items1 = ["English", "Spanish"]
ListFormatter.localizedString(byJoining: items1)

let items2 = ["Spanish", "English"]
ListFormatter.localizedString(byJoining: items2)

// Spanisch Localisation
let itemsInSpanish = ["Ingleés", "Espñol"]
ListFormatter.localizedString(byJoining: itemsInSpanish)

let itemsINSpanish2 = [ "Espanol", "Ingles" ]
ListFormatter.localizedString(byJoining: itemsINSpanish2)

Thank you

3      

@daa  

Found an answer.

Anytime we're showing a list of items that's formatted as human readable text, we can use ListFormatter.

Thanky you @ Quinn “The Eskimo!” via Apple Developer Forum

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.