[swift-users] Swift localisation, percentage sign escaping
Saagar Jha
saagar at saagarjha.com
Thu May 11 12:42:00 CDT 2017
Interpolation doesn’t need escaping, but String(format:) does.
Saagar Jha
> On May 11, 2017, at 02:44, Adam Sutcliffe via swift-users <swift-users at swift.org> 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 <>
> adam at peak.net <mailto:name at peak.net>
> peak.net <http://peak.net/>_______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170511/50cbb768/attachment.html>
More information about the swift-users
mailing list