I would like to localize the string "I love the number x" where x is an integer. So I have 2 questions, how do I do that in localizedStringForKey and what is the key value pair in my Localization.strings?
Asked
Active
Viewed 1,189 times
1
-
Possible duplicate of [How do I localize a string with formatting placeholders?](http://stackoverflow.com/questions/4881628/how-do-i-localize-a-string-with-formatting-placeholders) – Larme Jan 24 '16 at 11:58
-
I see no mention of .string file – Happiehappie Jan 24 '16 at 12:48
-
Also I'm asking for swift. – Happiehappie Jan 24 '16 at 14:17
-
`NSLocalizedString()` calls `localizedStringForKey`. You're looking for placeholders, and you can use `stringWithFormat:`. Functions that do the same in Objective-C or in Swift, no? – Larme Jan 24 '16 at 14:40
-
Then what should my key/value be in my localisation.strings – Happiehappie Jan 24 '16 at 15:44
-
key: whatever you want, value "I love the number %d", then `var str = String.stringwithformat("NSLocalizedString("myKey", comment:""), myInt)`, or something like that (I don't speak Swift). – Larme Jan 25 '16 at 09:01