[swift-users] Localization in Swift.

Zhao Xin owenzx at gmail.com
Wed Nov 2 00:40:39 CDT 2016


I has known that, and it is the developer's choice,  which means, the
developer has already known that. There are many circumstances that there
are no needs to translate at all. For example, if I want show the user that
I have to ask him to give me permission of a folder, the `url.path` has no
need to translate.

And of course,
` String.localizedStringWithFormat(NSLocalizedString("​blabla%​@​blabla",
comment: "​blabla"), ​` has already allows to do that. I just think it
should be in a more Swift way by using `\(foo)`.

Zhaoxin

On Wed, Nov 2, 2016 at 11:45 AM, Jens Alfke <jens at mooseyard.com> wrote:

>
> 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/20161102/28186363/attachment.html>


More information about the swift-users mailing list