0

I have a string which hold a varying part in the middle according to some cases.

Example: You lost 255 points.

The point value "255" is the varying part and I want to hold the non-varying part in my string file. However I don't want to have two entries in my strings file like.

"string_start" = "You lost" "string_end" = "points."

Btw the points part which is (255) in the example is an NSMutableAttributedString to support a different color and font style.

Thanks in Advance.

Reaper
  • 124
  • 2
  • 16

1 Answers1

1

I would do it like this:

[NSString stringWithFormat:NSLocalizedString(@"You lost %d points", nil), 255]

and you localize @"You lost %d points" in whatever language you want.

Hiroshi Horie
  • 315
  • 2
  • 11
  • I know I didnt mention but If the %d part (point part) is an NSAttributedString with different font and color. Do you know how to format the string ? – Reaper Jun 04 '15 at 13:20