[swift-evolution] Localization support for string interpolation

Daniel Höpfl daniel at hoepfl.de
Thu Apr 21 09:21:23 CDT 2016


On 2016-04-21 12:41, Uli Kusterer wrote:
> [...]
>  One request: Could you perhaps use positional syntax? In some
> languages, the word order of the placeholders needs to change, and
> there needs to be a way to detect that the translator swapped two
> placeholders. In NSLocalizedString, that is done via %1$@, %2$@.

Using it in the translated string already works (see test cases).

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.

Greetings,
    Daniel


More information about the swift-evolution mailing list