Re: [swift-users] Swift localisation, percentage sign escaping

2017-05-11 Thread Zhao Xin via swift-users
Forgot to show an example.

In Swift, below code won't work,

let says = NSLocalizedString("It runs \(count) times", comment: "run times")

You should use

let says = String.localizedStringWithFormat(NSLocalizedString("It runs %@
times", comment: "run times"), String(count))

Zhaoxin

On Fri, May 12, 2017 at 2:23 AM, rintaro ishizaki via swift-users <
swift-users@swift.org> wrote:

>
>
> 2017-05-11 18:44 GMT+09:00 Adam Sutcliffe via swift-users <
> swift-users@swift.org>:
>
>> Hi,
>>
>> I've been having an issue with a localised string,, one of which has a
>> percentage sign in it:
>>
>> "GAMERANK_5_DESC" = "Wow! You're racing ahead. Only 5%% of our users get
>> here!";
>>
>> the key is built as such:
>>
>> Obj-c : NSString *key = [NSString stringWithFormat:@"GAMERANK_%@_DESC"
>> ,rank];
>>
>> Swift: let key = "GAMERANK_\(rank)_DESC"
>>
>> Then localised with the same macro:  NSLocalizedString(key, @"");
>>
>> The output is different though:
>>
>> Obj- C = "Wow! You're racing ahead. Only 5% of our users get here!"
>> Swift = "Wow! You're racing ahead. Only 5%% of our users get here!"
>>
>
> How do you check the output?
> If you are using NSLog(output) in Obj-C and print(output) in Swift, that
> is why.
> The first parameter of NSLog is a format.
>
>
>>
>> Is this a bug in the swifts localisation parsing? Does the percentage
>> sign not need to be escaped in Swift?
>>
>> Cheers
>>
>> --
>>
>> –
>> ADAM SUTCLIFFE
>> Software Engineer
>>
>> –
>> +44 (0)7786 692 639
>> a...@peak.net 
>> peak.net
>>
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Swift localisation, percentage sign escaping

2017-05-11 Thread rintaro ishizaki via swift-users
2017-05-11 18:44 GMT+09:00 Adam Sutcliffe via swift-users <
swift-users@swift.org>:

> Hi,
>
> I've been having an issue with a localised string,, one of which has a
> percentage sign in it:
>
> "GAMERANK_5_DESC" = "Wow! You're racing ahead. Only 5%% of our users get
> here!";
>
> the key is built as such:
>
> Obj-c : NSString *key = [NSString stringWithFormat:@"GAMERANK_%@_DESC"
> ,rank];
>
> Swift: let key = "GAMERANK_\(rank)_DESC"
>
> Then localised with the same macro:  NSLocalizedString(key, @"");
>
> The output is different though:
>
> Obj- C = "Wow! You're racing ahead. Only 5% of our users get here!"
> Swift = "Wow! You're racing ahead. Only 5%% of our users get here!"
>

How do you check the output?
If you are using NSLog(output) in Obj-C and print(output) in Swift, that is
why.
The first parameter of NSLog is a format.


>
> Is this a bug in the swifts localisation parsing? Does the percentage sign
> not need to be escaped in Swift?
>
> Cheers
>
> --
>
> –
> ADAM SUTCLIFFE
> Software Engineer
>
> –
> +44 (0)7786 692 639
> a...@peak.net 
> peak.net
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Zhao Xin via swift-users
Yes, I had. There was a `class` and `static` post under it. But I disagreed
that and  my interpretation was just opposite.

Zhaoxin

On Fri, May 12, 2017 at 1:11 AM, Adrian Zubarev <
adrian.zuba...@devandartist.com> wrote:

> Have you read closely the bug issue before posting your answer?
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> Am 11. Mai 2017 um 19:05:13, Zhao Xin (owe...@gmail.com) schrieb:
>
> No. I think it is just a compromise.
>
> Zhaoxin
>
> On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev <
> adrian.zuba...@devandartist.com> wrote:
>
>> I don’t think this is the answer that was asked for. I bet it’s more a
>> technical question from the internal point of of view.
>>
>>
>> --
>> Adrian Zubarev
>> Sent with Airmail
>>
>> Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (
>> swift-users@swift.org) schrieb:
>>
>> In Swift, you use `static in struct and enum` and `class in class`. For
>> example,
>>
>> struct Foo {
>>
>> static func bar() {
>>
>>
>>
>> }
>>
>> }
>>
>>
>> class ClassFoo {
>>
>> class func bar() {
>>
>>
>>
>> }
>>
>> }
>>
>>
>> Another the `class func bar()` can replace to `static` as well. Here the
>> `static` and `class` are equal in functions of classes.
>>
>>
>> And `class` is a keyword.
>>
>>
>> class ClassFoo2 {
>>
>> static func bar() {
>>
>>
>>
>> }
>>
>> }
>>
>>
>> Zhaoxin
>>
>>
>>
>> On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users <
>> swift-users@swift.org> wrote:
>>
>>> I was expecting static to be a builtin. Does anybody know why it must be
>>> a keyword?
>>>
>>> Background. https://bugs.swift.org/browse/SR-4834
>>>
>>> ___
>>> swift-users mailing list
>>> swift-users@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-users
>>>
>>>
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Jose Cheyo Jimenez via swift-users
I can understand class being a keyword because you use the same word to declare 
an object. So `class` is used in different contexts like you showed below. That 
is not the case for static. Class can appear at the top level but IFAIK static 
will not appear at top level declarations. 

> On May 11, 2017, at 9:59 AM, Zhao Xin  wrote:
> 
> In Swift, you use `static in struct and enum` and `class in class`. For 
> example,
> 
> struct Foo {
> static func bar() {
> 
> }
> }
> 
> class ClassFoo {
> class func bar() {
> 
> }
> }
> 
> Another the `class func bar()` can replace to `static` as well. Here the 
> `static` and `class` are equal in functions of classes.
> 
> And `class` is a keyword.
> 
> class ClassFoo2 {
> static func bar() {
> 
> }
> }

static func bar() = final class func bar() 
But if you type final class the compiler will say to make it static instead. 

static func bar() != class func bar()

Static is only an attribute modifier. Class is a modifier and a declaration 
depending on context.  Why must static be a keyword when every other modifier 
is not? 

> 
> Zhaoxin
> 
> 
>> On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users 
>>  wrote:
>> I was expecting static to be a builtin. Does anybody know why it must be a 
>> keyword? 
>> 
>> Background. https://bugs.swift.org/browse/SR-4834
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>> 
> 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Swift localisation, percentage sign escaping

2017-05-11 Thread Saagar Jha via swift-users
Interpolation doesn’t need escaping, but String(format:) does.

Saagar Jha

> On May 11, 2017, at 02:44, Adam Sutcliffe via swift-users 
>  wrote:
> 
> Hi,
> 
> I've been having an issue with a localised string,, one of which has a 
> percentage sign in it:
> 
> "GAMERANK_5_DESC" = "Wow! You're racing ahead. Only 5%% of our users get 
> here!";
> 
> the key is built as such:
> 
> Obj-c : NSString *key = [NSString stringWithFormat:@"GAMERANK_%@_DESC",rank];
> 
> Swift: let key = "GAMERANK_\(rank)_DESC"
> 
> Then localised with the same macro:  NSLocalizedString(key, @"");
> 
> The output is different though:
> 
> Obj- C = "Wow! You're racing ahead. Only 5% of our users get here!"
> Swift = "Wow! You're racing ahead. Only 5%% of our users get here!"
> 
> Is this a bug in the swifts localisation parsing? Does the percentage sign 
> not need to be escaped in Swift?
> 
> Cheers
> 
> -- 
> 
> –
> ADAM SUTCLIFFE
> Software Engineer
> 
> –
> +44 (0)7786 692 639 <>
> a...@peak.net 
> peak.net ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Swift localisation, percentage sign escaping

2017-05-11 Thread Adam Sutcliffe via swift-users
Hi,

I've been having an issue with a localised string,, one of which has a
percentage sign in it:

"GAMERANK_5_DESC" = "Wow! You're racing ahead. Only 5%% of our users get
here!";

the key is built as such:

Obj-c : NSString *key = [NSString stringWithFormat:@"GAMERANK_%@_DESC"
,rank];

Swift: let key = "GAMERANK_\(rank)_DESC"

Then localised with the same macro:  NSLocalizedString(key, @"");

The output is different though:

Obj- C = "Wow! You're racing ahead. Only 5% of our users get here!"
Swift = "Wow! You're racing ahead. Only 5%% of our users get here!"

Is this a bug in the swifts localisation parsing? Does the percentage sign
not need to be escaped in Swift?

Cheers

-- 

–
ADAM SUTCLIFFE
Software Engineer

–
+44 (0)7786 692 639
a...@peak.net 
peak.net
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Adrian Zubarev via swift-users
Furthermore:

In a class declaration, the static keyword has the same effect as marking the 
declaration with both the class and final declaration modifiers.
Source.



-- 
Adrian Zubarev
Sent with Airmail

Am 11. Mai 2017 um 19:07:53, Austin Zheng (austinzh...@gmail.com) schrieb:

`class` and `static` in classes have subtly different meanings, if I recall 
correctly. A `class` declaration can be overriden in subclasses; a `static` one 
can't.

Best,
Austin

On Thu, May 11, 2017 at 10:04 AM, Zhao Xin via swift-users 
 wrote:
No. I think it is just a compromise.

Zhaoxin

On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev 
 wrote:
I don’t think this is the answer that was asked for. I bet it’s more a 
technical question from the internal point of of view.



-- 
Adrian Zubarev
Sent with Airmail

Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (swift-users@swift.org) 
schrieb:

In Swift, you use `static in struct and enum` and `class in class`. For example,

struct Foo {
    static func bar() {
        
    }
}

class ClassFoo {
    class func bar() {
        
    }
}

Another the `class func bar()` can replace to `static` as well. Here the 
`static` and `class` are equal in functions of classes.

And `class` is a keyword.

class ClassFoo2 {
    static func bar() {
        
    }
}

Zhaoxin


On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users 
 wrote:
I was expecting static to be a builtin. Does anybody know why it must be a 
keyword? 

Background. https://bugs.swift.org/browse/SR-4834

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Adrian Zubarev via swift-users
Have you read closely the bug issue before posting your answer?



-- 
Adrian Zubarev
Sent with Airmail

Am 11. Mai 2017 um 19:05:13, Zhao Xin (owe...@gmail.com) schrieb:

No. I think it is just a compromise.

Zhaoxin

On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev 
 wrote:
I don’t think this is the answer that was asked for. I bet it’s more a 
technical question from the internal point of of view.



-- 
Adrian Zubarev
Sent with Airmail

Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (swift-users@swift.org) 
schrieb:

In Swift, you use `static in struct and enum` and `class in class`. For example,

struct Foo {
    static func bar() {
        
    }
}

class ClassFoo {
    class func bar() {
        
    }
}

Another the `class func bar()` can replace to `static` as well. Here the 
`static` and `class` are equal in functions of classes.

And `class` is a keyword.

class ClassFoo2 {
    static func bar() {
        
    }
}

Zhaoxin


On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users 
 wrote:
I was expecting static to be a builtin. Does anybody know why it must be a 
keyword? 

Background. https://bugs.swift.org/browse/SR-4834

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Austin Zheng via swift-users
`class` and `static` in classes have subtly different meanings, if I recall
correctly. A `class` declaration can be overriden in subclasses; a `static`
one can't.

Best,
Austin

On Thu, May 11, 2017 at 10:04 AM, Zhao Xin via swift-users <
swift-users@swift.org> wrote:

> No. I think it is just a compromise.
>
> Zhaoxin
>
> On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev <
> adrian.zuba...@devandartist.com> wrote:
>
>> I don’t think this is the answer that was asked for. I bet it’s more a
>> technical question from the internal point of of view.
>>
>>
>>
>> --
>> Adrian Zubarev
>> Sent with Airmail
>>
>> Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (
>> swift-users@swift.org) schrieb:
>>
>> In Swift, you use `static in struct and enum` and `class in class`. For
>> example,
>>
>> struct Foo {
>>
>> static func bar() {
>>
>>
>>
>> }
>>
>> }
>>
>>
>> class ClassFoo {
>>
>> class func bar() {
>>
>>
>>
>> }
>>
>> }
>>
>>
>> Another the `class func bar()` can replace to `static` as well. Here the
>> `static` and `class` are equal in functions of classes.
>>
>>
>> And `class` is a keyword.
>>
>>
>> class ClassFoo2 {
>>
>> static func bar() {
>>
>>
>>
>> }
>>
>> }
>>
>>
>> Zhaoxin
>>
>>
>>
>> On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users <
>> swift-users@swift.org> wrote:
>>
>>> I was expecting static to be a builtin. Does anybody know why it must be
>>> a keyword?
>>>
>>> Background. https://bugs.swift.org/browse/SR-4834
>>>
>>> ___
>>> swift-users mailing list
>>> swift-users@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-users
>>>
>>>
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Zhao Xin via swift-users
No. I think it is just a compromise.

Zhaoxin

On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev <
adrian.zuba...@devandartist.com> wrote:

> I don’t think this is the answer that was asked for. I bet it’s more a
> technical question from the internal point of of view.
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (
> swift-users@swift.org) schrieb:
>
> In Swift, you use `static in struct and enum` and `class in class`. For
> example,
>
> struct Foo {
>
> static func bar() {
>
>
>
> }
>
> }
>
>
> class ClassFoo {
>
> class func bar() {
>
>
>
> }
>
> }
>
>
> Another the `class func bar()` can replace to `static` as well. Here the
> `static` and `class` are equal in functions of classes.
>
>
> And `class` is a keyword.
>
>
> class ClassFoo2 {
>
> static func bar() {
>
>
>
> }
>
> }
>
>
> Zhaoxin
>
>
>
> On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users <
> swift-users@swift.org> wrote:
>
>> I was expecting static to be a builtin. Does anybody know why it must be
>> a keyword?
>>
>> Background. https://bugs.swift.org/browse/SR-4834
>>
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Adrian Zubarev via swift-users
I don’t think this is the answer that was asked for. I bet it’s more a 
technical question from the internal point of of view.



-- 
Adrian Zubarev
Sent with Airmail

Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (swift-users@swift.org) 
schrieb:

In Swift, you use `static in struct and enum` and `class in class`. For example,

struct Foo {
    static func bar() {
        
    }
}

class ClassFoo {
    class func bar() {
        
    }
}

Another the `class func bar()` can replace to `static` as well. Here the 
`static` and `class` are equal in functions of classes.

And `class` is a keyword.

class ClassFoo2 {
    static func bar() {
        
    }
}

Zhaoxin


On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users 
 wrote:
I was expecting static to be a builtin. Does anybody know why it must be a 
keyword? 

Background. https://bugs.swift.org/browse/SR-4834

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Zhao Xin via swift-users
In Swift, you use `static in struct and enum` and `class in class`. For
example,

struct Foo {

static func bar() {



}

}


class ClassFoo {

class func bar() {



}

}


Another the `class func bar()` can replace to `static` as well. Here the
`static` and `class` are equal in functions of classes.


And `class` is a keyword.


class ClassFoo2 {

static func bar() {



}

}


Zhaoxin



On Fri, May 12, 2017 at 12:17 AM, Jose Cheyo Jimenez via swift-users <
swift-users@swift.org> wrote:

> I was expecting static to be a builtin. Does anybody know why it must be a
> keyword?
>
> Background. https://bugs.swift.org/browse/SR-4834
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users