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 you all for replie

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 about it, so I can make s

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Brent Royal-Gordon via swift-users
(Resending something that was accidentally off-list.) > On Nov 1, 2016, at 11:09 PM, Jens Alfke via swift-users > wrote: > > I don’t think the ExpressibleByStringInterpolation protocol provides enough > information to make this work. It hands the implementation a list of values > to concatena

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. It offers more control

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 need to be transla

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 %@x. It’s also not an implementation. It’s just

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Marco S Hyman via swift-users
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 %@x. What does it do when given -- to use an example from the swift book: "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)”

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Zhao Xin via swift-users
I have already give a workable implementation above. let count = 10 > let says = NSLocalizedString(" > ​blabla > \(count) > ​blabla > ", comment: " > ​blabla > ") ​to let says = > String.localizedStringWithFormat(NSLocalizedString("​blabla%​@​blabla", > comment: "​blabla"), ​String(​count​)​

Re: [swift-users] Localization in Swift.

2016-11-01 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 to make this work.

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. The names of many

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Zhao Xin via swift-users
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

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 won’t be localized.

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 >> let says = NSLoc

Re: [swift-users] Localization in Swift.

2016-11-01 Thread Zhao Xin via swift-users
I think in Swift. let count = 10 > let says = NSLocalizedString(" > ​blabla > \(count) > ​blabla > ", comment: " > ​blabla > ") ​can be roughly interpreted as let says = String.localizedStringWithFormat(NSLocalizedString(" > ​blabla > % > ​@ > ​blabla > ", comment: " > ​blabla > "), count) ​S

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. NSLocalizedString was design

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 h

[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 th