Re: [swift-users] Localization in Swift.

2016-11-03 Thread Zhao Xin via swift-users
I just uploaded this as a Xcode extension. You can download it here . As long as Swift is not supporting this, you can use my Xcode extension. Zhaoxin On Thu, Nov 3, 2016 at 10:36 AM, Zhao Xin wrote: > Hello everyone. Thanks to

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Zhao Xin via swift-users
Hello everyone. Thanks to you all for replies in this thread. 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. Zhaoxin On Thu, Nov 3, 2016 at 6:14 AM,

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Dave Abrahams via swift-users
on Wed Nov 02 2016, Jens Alfke wrote: >> On Nov 2, 2016, at 12:50 PM, Dave Abrahams via swift-users >> wrote: >> >> In my opinion, we can and must do much better for Swift. If there's >> something about “%” formatting that you particularly value, I'd like to >> know

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 2, 2016, at 12:50 PM, Dave Abrahams via swift-users > wrote: > > In my opinion, we can and must do much better for Swift. If there's > something about “%” formatting that you particularly value, I'd like to > know about it, so I can make sure it's accomodated.

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Dave Abrahams via swift-users
on Tue Nov 01 2016, Jens Alfke wrote: >> On Nov 1, 2016, at 10:40 PM, Zhao Xin wrote: >> >> 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. > > We’re getting off-topic, but paths do

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 2, 2016, at 11:23 AM, Marco S Hyman via swift-users > wrote: > > On Nov 1, 2016, at 11:42 PM, Zhao Xin via swift-users > wrote: >> >> I have already give a workable implementation above. > > Your implementation assume \(x) is always

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 1, 2016, at 10:56 PM, Zhao Xin wrote: > > I am not talking to eliminate "%" style function. I am talking to add more > compatibility to `NSLocalizedString` with `\(foo)` style. I don’t think the ExpressibleByStringInterpolation protocol provides enough information

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Zhao Xin via swift-users
I am not talking to eliminate "%" style function. I am talking to add more compatibility to `NSLocalizedString` with `\(foo)` style. As there is no rule forbidding that, it should work. If someone doesn't need the flexible parts, why he has to use the complicated way? Zhaoxin On Wed, Nov 2, 2016

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Jens Alfke via swift-users
> On Nov 1, 2016, at 10:40 PM, Zhao Xin wrote: > > 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. We’re getting off-topic, but paths do need to be translated, at least on Mac systems.

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Jens Alfke via swift-users
> On Nov 1, 2016, at 7:52 PM, Zhao Xin 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

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Zhao Xin via swift-users
The second should be let says = String.localizedStringWithFormat(NSLocalizedString(" > ​blabla > % > ​@ > ​blabla > ", comment: " > ​blabla > "), > ​String(​ > count > ​)​ > ) ​Zhaoxin​ On Wed, Nov 2, 2016 at 10:50 AM, Zhao Xin wrote: > I think in Swift. > > let count = 10

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Jens Alfke via swift-users
> On Nov 1, 2016, at 1:53 AM, Zhao Xin via swift-users > wrote: > > 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.

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Brent Royal-Gordon via swift-users
> I managed to replace my code with > > let newSays = String.localizedStringWithFormat(NSLocalizedString("It runs %d > times", comment: "new run times"), count) > > However, I still thing it would be better if we could use \(foo) directly, as > it is more Swift style. Any idea why this can't

[swift-users] Localization in Swift.

2016-11-01 Thread Zhao Xin via swift-users
I encountered a localization problem today. At first I translated a string like this. let count = 10 > let says = NSLocalizedString("It runs \(count) times", comment: "run > times") I couldn't get the translation taking effect. So I open the setting "Localization Debugging" in scheme and get