[swift-evolution] Localization support for string interpolation
daniel at hoepfl.de
Fri Apr 22 02:09:01 CDT 2016
On 21.04.16 18:29, Uli Kusterer wrote:
> 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
If you want to play around with it, I added a branch in the proof of
concept repo that uses positional arguments in the keys.
> (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).
While it is possible to use different placeholders (%d, %f, ...)
depending on the type of the interpolation argument, I don't think it is
What you said is one reason, then it makes genstrings harder since
finding the type requires to parse more than just the string and while
there might be cases where you want to have e.g. "%+17.3f" in the
translated text, you normally should use a (localized) formatter here
anyways, so always having the description() here is probably okay and
makes the keys/translations more consistent.
More information about the swift-evolution