<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I think in Swift.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="georgia, serif" style="font-size:12.800000190734863px">let count = 10<br></font><font face="georgia, serif" style="font-size:12.800000190734863px">let says = NSLocalizedString("<div class="gmail_default" style="font-family:georgia,serif;display:inline">blabla</div>\(count)<div class="gmail_default" style="font-family:georgia,serif;display:inline">blabla</div>", comment: "<div class="gmail_default" style="font-family:georgia,serif;display:inline">blabla</div>")</font></blockquote><div><br></div><div class="gmail_default" style="font-family:georgia,serif">can be roughly interpreted as</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:12.800000190734863px">let </span><span style="font-family:georgia,serif;font-size:12.800000190734863px">says</span><span style="font-size:12.800000190734863px"> = String.</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">localizedStringWithFormat(</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">NSLocalizedString("<div class="gmail_default" style="font-family:georgia,serif;display:inline">blabla</div>%<div class="gmail_default" style="font-family:georgia,serif;display:inline">@</div><div class="gmail_default" style="font-family:georgia,serif;display:inline">blabla</div>", comment: "<div class="gmail_default" style="font-family:georgia,serif;display:inline">blabla</div>"), count)</span></blockquote><div><br></div><div class="gmail_default" style="font-family:georgia,serif">So if Swift does not want to do much effort on this , it could just find every localized string that is with '\(foo)' in `<span style="font-size:12.800000190734863px">NSLocalizedString` and converted to `</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">String.</span><wbr style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">localizedStringWithFormat(</span><wbr style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">NSLocalizedString...` internally.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Zhaoxin</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 2, 2016 at 12:08 AM, Jens Alfke <span dir="ltr"><<a href="mailto:jens@mooseyard.com" target="_blank">jens@mooseyard.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Nov 1, 2016, at 1:53 AM, Zhao Xin via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
><br>
> I began to realize that` \(count)` was not dealed well in localization. The compiler calculated the full string then looking for the translation, instead of looking for the translation first.<br>
<br>
</span>NSLocalizedString was designed (in the 1990s) to be used with methods like String(format:…) that take printf-style “%”-substituted format strings.<br>
Swift’s string interpolation is obviously a different mechanism entirely.<br>
<br>
I suspect that Swift interpolation won’t work well for localized strings because the string and the code are so tightly connected. Localization very often needs to change the order of parameters, for instance. It’s also unclear where things like number formatting happen in Swift interpolation; when localizing a string, the conversion needs to be done using the same locale as the string lookup, which might not happen if the string-to-number conversion is separate and uses the default locale.<br>
<span class="HOEnZb"><font color="#888888"><br>
—Jens</font></span></blockquote></div><br></div>