<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I just uploaded this as a Xcode extension. You can download it <a href="https://github.com/owenzhao/Localization-Helper">here</a>.</div><div class="gmail_default" style="font-family:georgia,serif">As long as Swift is not supporting this, you can use my Xcode extension.</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 Thu, Nov 3, 2016 at 10:36 AM, Zhao Xin <span dir="ltr"><<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>></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">Hello everyone. Thanks to you all for replies in this thread. </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">I am currently working on a Xcode Extension for this purpose. I would like to bring it to github in this week. This will be my first Xcode extension, also my first github open sourced project. </div><div class="gmail_default" style="font-family:georgia,serif"><br></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="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 3, 2016 at 6:14 AM, Dave Abrahams via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
on Wed Nov 02 2016, Jens Alfke <jens-AT-mooseyard.com> wrote:<br>
<br>
>> On Nov 2, 2016, at 12:50 PM, Dave Abrahams via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br>
>><br>
>> In my opinion, we can and must do much better for Swift. If there's<br>
>> something about “%” formatting that you particularly value, I'd like to<br>
>> know about it, so I can make sure it's accomodated.<br>
><br>
> It offers more control over formatting, like min/max widths, number<br>
> base, decimal places, etc. Yes, you can do this in the code inside the<br>
> interpolated string, but IMHO it’s awkward because it requires knowing<br>
> a bunch of extra methods for string conversion, truncation, etc. It’s<br>
> a lot easier for me to remember and type “%x” than it is to remember<br>
> and type the method that converts an int to a hex string.<br>
<br>
</span>In my view this should look like<br>
<br>
"... \(x.format(radix: 16, width: 12))... "<br>
<br>
Where the possible arguments to format() are statically known to the<br>
compiler (and code completion!) based on the type of x.<br>
<span><br>
><br>
> Also (and more importantly for localization) the formatting details<br>
> are part of the localizable format string, not hardwired. One example<br>
> of this is formatting currency, where a US localization would use<br>
> “$%.2f” but other currencies might call for more or fewer decimal<br>
> places.<br>
<br>
</span>Yep, I'm paying attention to that, thanks.<br>
<span><br>
> There are other examples where one might swap format strings for other<br>
> purposes like different-width layouts for monospaced/terminal output.<br>
<br>
</span>I think we can leverage the same mechanisms used for localization to<br>
handle those.<br>
<span><br>
> There’s also a nonstandard extension used by Cocoa/CF’s formatters,<br>
> that allows the parameters to be reordered. (I haven’t used it so I<br>
> don’t know the syntax offhand.) This is of course important for<br>
> localization, to follow a language’s grammar.<br>
<br>
</span>Right, that's crucial.<br>
<span><br>
> I think these features could be added to interpolation. Just as a<br>
> quick idea, maybe a syntax that allows formatting metacharacters to be<br>
> added at the start of the interpolation, like “Please pay $\((.2)<br>
> total)” where the “(.2) specifies two decimal places, or “The address<br>
> is \((x) addr)”.<br>
<br>
</span>I think the “.format(...)” approach is better, but it's equally<br>
important that there are sufficient outside-the-Swift-source knobs for<br>
localizers to add language-specific formatting parameters.<br>
<div class="m_8949609036151275825HOEnZb"><div class="m_8949609036151275825h5"><br>
--<br>
-Dave<br>
______________________________<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>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>