Localised concatenation of strings

Originator:kiel.gillard
Number:rdar://37880652 Date Originated:6/2/2018
Status:Duplicate/12306012/Open Resolved:
Product:Foundation Product Version:
Classification:Suggestion Reproducible:
 
I'd like to generate localised string from the following code:
```
let skills = ["nunchuck", "bow hunting", "computer hacking"]
let notLocalizedJoined = skills.joined(separator: ", ")
```

Looking at the wikipedia article for "comma", not only is there different kinds of separators, but the elements are ordered differently or some languages mightn't have a separator at all.

And this is to say nothing about generating a list where optionally, say in English, the word "and" could precede the final element:
```
"nunchuck, bow hunting and computer hacking"
```

Turns out there's an `icu::ListFormatter` class in the ICU libraries, maybe it's time for an `NSListFormatter`?

I would have loved to submit a pull request implementing this in the Swift Foundation project but I quickly realised CoreFoundation should be consistent and offer the same functionality upon which the Swift Foundation project should bridge. If only CoreFoundation was open source *hint*!

https://en.m.wikipedia.org/wiki/Comma#In_other_languages
http://icu-project.org/apiref/icu4c/classicu_1_1ListFormatter.html
https://forums.swift.org/t/localised-string-array-join/10241

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!