[swift-evolution] Localization support for string interpolation

Uli Kusterer kusterer at orangejuiceliberationfront.com
Thu Apr 21 11:29:49 CDT 2016

On 21 Apr 2016, at 16:21, Daniel Höpfl <daniel at hoepfl.de> wrote:
> I assume you want it to be part of the key? Like:
>   DHLocalizedString("first: \("a"), second: \("b")")
> Localizable.strings:
>   "first: %1$@, second: %2$@" = "vor %2$@ kommt %1$@";
> Then one would have to change <https://github.com/dhoepfl/DHLocalizedString/blob/master/DHLocalizedString/DHLocalizedString.swift#L68>.
> Could be done but I'm not sure if I'd like to have to include the position in the key, even if there is only one argument. Could be an exception, of course.

 Yeah, idea here is principle of least surprise. Most lcoalization tools pre-populate the translations with the keys, so having the positional indices in there would mean nobody forgets it and then gets back a translation with the contents reversed (admittedly, since you're using the same %@ format for everything, at least your code won't crash. In ObjC, if someone swapped out a %@ and a %d, you got some "hilarious" results).

— Uli Kusterer
“The Witnesses of TeachText are everywhere..."

More information about the swift-evolution mailing list