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.

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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 ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.