[swift-users] Localization in Swift.

Jens Alfke jens at mooseyard.com
Wed Nov 2 00:49:16 CDT 2016


> On Nov 1, 2016, at 10:40 PM, Zhao Xin <owenzx at gmail.com> wrote:
> 
> For example, if I want show the user that I have to ask him to give me permission of a folder, the `url.path` has no need to translate.

We’re getting off-topic, but paths do need to be translated, at least on Mac systems. The names of many standard folders like “Applications” and “Documents” are hardwired to English in the filesystem but are localized in the UI. Some application names get localized too (there’s a table in the app’s Info.plist that can substitute localized names.)

Anyway, string interpolation is convenient, but I wouldn’t say it should be the only way to format strings in Swift; it’s a lot less flexible than the C-style “%” substitutions. For comparison, even though C++’s iostreams use “<<“ to format strings by concatenation, I still end up using “%” based formatting a lot, depending on the use case.

—Jens


More information about the swift-users mailing list