[swift-evolution] Localization support for string interpolation

Daniel Höpfl daniel at hoepfl.de
Tue Apr 26 02:38:20 CDT 2016


On 24.04.16 23:33, Chris Lattner wrote:
> 
>> On Apr 21, 2016, at 12:42 AM, Daniel Höpfl via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Hi there!
>>
>> TL;DR: Here’s my idea for a better localized strings handling in Swift.
>> It includes both, support for string interpolation support for
>> NSLocalizedString, and a new string delimiter `...` that can be used
>> instead of NSLocalizedString("...”).
> 
> FWIW, this is closely related to the idea of extending string interpolation to support generalized “printf” style modifiers, which would allow very expressive formatting inline in a string interpolation.  This has not yet come to pass, but a write up of the ideas are available here:
> https://github.com/apple/swift/blob/master/docs/TextFormatting.rst

As I understand it, TextFormatting is focused on what happens inside the
interpolation brackets. The localization support has its focus on the
string parts outside the brackets.

I left out how to localize the parts inside the brackets on purpose
because that always involves developer’s decision. How to find the
translation of the string parts does not have to.

My proposal is just a Swiftyfied version of NSLocalizedString and, as
TextFormatting says: "Cocoa programmers can still use Cocoa localization
APIs for localization jobs"

So: Yes, these two proposals are related but IMO not that closely.

Greetings,
   Daniel


More information about the swift-evolution mailing list