<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Forgot to show an example.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">In Swift, below code won&#39;t work, </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif"><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(209,47,27)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> says = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">NSLocalizedString</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures">&quot;It runs </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">\</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">count</span><span style="font-variant-ligatures:no-common-ligatures">) times&quot;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">, comment: </span><span style="font-variant-ligatures:no-common-ligatures">&quot;run times&quot;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">)</span></p></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">You should use </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif"><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> says = String.localizedStringWithFormat(NSLocalizedString(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">&quot;It runs %@ times&quot;</span><span style="font-variant-ligatures:no-common-ligatures">, comment: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">&quot;run times&quot;</span><span style="font-variant-ligatures:no-common-ligatures">), String(count))</span></p></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 12, 2017 at 2:23 AM, rintaro ishizaki via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">2017-05-11 18:44 GMT+09:00 Adam Sutcliffe via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I&#39;ve been having an issue with a localised string,, one of which has a percentage sign in it:</div><div><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1" style="color:rgb(255,91,83);font-family:menlo;font-size:11px"><br></span></div><div><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1" style="color:rgb(255,91,83);font-family:menlo;font-size:11px">&quot;GAMERANK_5_DESC&quot;</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s2" style="font-family:menlo;font-size:11px"> = </span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1" style="color:rgb(255,91,83);font-family:menlo;font-size:11px">&quot;Wow! You&#39;re racing ahead. Only 5%% of our users get here!&quot;</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s2" style="font-family:menlo;font-size:11px">;</span></div>







<div><div><br></div><div>the key is built as such:</div><div><br></div><div>Obj-c : <font face="monospace, monospace">NSString *key = <span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1">[</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s2">NSString</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1"> </span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s3">stringWithFormat</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1">:</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s4" style="color:rgb(255,91,83)">@&quot;GAMERANK_%@<wbr>_DESC&quot;</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1">,rank];</span></font></div>







<div><br></div><div>Swift: <font face="monospace, monospace">let key = <span class="m_482283850225711947gmail-m_1268100777993203592gmail-s2">&quot;GAMERANK_\(</span>rank)_DESC&quot;</font></div><div><br></div><div>Then localised with the same macro:  <span class="m_482283850225711947gmail-m_1268100777993203592gmail-s1" style="color:rgb(189,153,255);font-family:menlo;font-size:11px">NSLocalizedString</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s2" style="font-family:menlo;font-size:11px">(key, </span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s3" style="font-family:menlo;font-size:11px">@&quot;&quot;</span><span class="m_482283850225711947gmail-m_1268100777993203592gmail-s2" style="font-family:menlo;font-size:11px">);</span></div>







<div><br></div><div>The output is different though:</div><div><br></div><div>Obj- C = <span style="color:rgb(255,91,83);font-family:menlo;font-size:11px">&quot;Wow! You&#39;re racing ahead. Only 5% of our users get here!&quot;</span></div><div>Swift = <span style="color:rgb(255,91,83);font-family:menlo;font-size:11px">&quot;Wow! You&#39;re racing ahead. Only 5%% of our users get here!&quot;</span></div></div></div></blockquote><div><br></div></span><div>How do you check the output?</div><div>If you are using NSLog(output) in Obj-C and print(output) in Swift, that is why.</div><div>The first parameter of NSLog is a format.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=""><div dir="ltr"><div><div><br></div><div>Is this a bug in the swifts localisation parsing? Does the percentage sign not need to be escaped in Swift?</div><div><br></div><div>Cheers</div><span class="m_482283850225711947gmail-HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_482283850225711947gmail-m_1268100777993203592gmail_signature"><div dir="ltr"><div><font face="HelveticaNeue-Light"><br>–</font></div><div><font face="HelveticaNeue-Medium">ADAM SUTCLIFFE</font></div><div><font face="HelveticaNeue-Light">Software Engineer</font></div><div><font face="Helvetica Neue"><br></font></div><div><font face="HelveticaNeue-Light">–</font></div><div><font face="HelveticaNeue-Light"><a value="+447000000000" style="color:rgb(17,85,204)">+44 (0)7786 692 639</a></font></div><div><font face="HelveticaNeue-Light"><a href="mailto:name@peak.net" style="color:rgb(17,85,204)" target="_blank">adam@peak.net</a></font></div><div><font face="HelveticaNeue-Light"><a href="http://peak.net/" style="color:rgb(17,85,204)" target="_blank">peak.net</a></font></div></div></div>
</font></span></div></div>
<br></span><span class="">______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
<br></span></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>