<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">The second should be</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-family:arial,sans-serif;font-size:12.800000190734863px">let </span><span style="font-size:12.800000190734863px">says</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"> = String.</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">localizedStringWithForm<wbr>at(</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">NSLocalizedString(&quot;<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>&quot;, comment: &quot;<div class="gmail_default" style="font-family:georgia,serif;display:inline">​blabla</div>&quot;), <div class="gmail_default" style="font-family:georgia,serif;display:inline">​String(​</div>count<div class="gmail_default" style="font-family:georgia,serif;display:inline">​)​</div>)</span></blockquote><div><br></div><div class="gmail_default" style="font-family:georgia,serif">​Zhaoxin​</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 2, 2016 at 10:50 AM, Zhao Xin <span dir="ltr">&lt;<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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(&quot;<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>&quot;, comment: &quot;<div class="gmail_default" style="font-family:georgia,serif;display:inline">​blabla</div>&quot;)</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><span style="font-size:12.800000190734863px">localizedStringWithForm<wbr>at(</span><span style="font-size:12.800000190734863px">NSLocalizedString(&quot;<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>&quot;, comment: &quot;<div class="gmail_default" style="font-family:georgia,serif;display:inline">​blabla</div>&quot;), 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  &#39;\(foo)&#39; 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><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">localizedStringWithFor<wbr>mat(</span><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="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 2, 2016 at 12:08 AM, Jens Alfke <span dir="ltr">&lt;<a href="mailto:jens@mooseyard.com" target="_blank">jens@mooseyard.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
&gt; On Nov 1, 2016, at 1:53 AM, Zhao Xin via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; 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="m_1387146376226795233HOEnZb"><font color="#888888"><br>
—Jens</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>