[swift-users] Localization in Swift.

Jens Alfke jens at mooseyard.com
Tue Nov 1 22:45:50 CDT 2016


> On Nov 1, 2016, at 7:52 PM, Zhao Xin <owenzx at gmail.com> wrote:
> 
> The second should be
> 
> let says = String.localizedStringWithFormat(NSLocalizedString("​blabla%​@​blabla", comment: "​blabla"), ​String(​count​)​)

That’s not quite right, because the conversion of `count` to a string won’t be localized. Some languages use non-ASCII digits, use characters other than “.” for decimal points, etc. Depending on the exact type of `count`, it would need to be something like:

	String.localizedStringWithFormat(NSLocalizedString("​blabla%​d​blabla", comment: "​blabla"), ​count​)​

Hardcoding this specific kind of transformation into the parser seems like a bad idea, since NSLocalizedString isn’t part of the language. Why don’t you just use localizedStringWithFormat instead of string interpolation in your code?

—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161101/e9a13cef/attachment.html>


More information about the swift-users mailing list