I currently have some rather long obj-c calls that look like this:
This produces, a message that looks something like this:
"Maximum capacity is 92% of design capacity."
(But localized to the user's language, of course.)
My question is... is there some way I could write this so that I only have one entry in my strings file (Capacity) instead of two (Capacity1 and Capacity2).
I'm thinking such a call might look something like:
And then inside of my strings file, I could include the %i. Why?
I feel like the code would look simpler and I'd have to explain less to my translator. Oh, it would also make modifying the message so that if I decide to change how many variables are in it easier.
So, any help would be greatly appreciated. Thanks!
Code:
[NSString stringWithFormat:@"%@ %i%% %@", NSLocalizedString(@"Capacity1", @""), [[device objectForKey:kDeviceDesignPercent] intValue], NSLocalizedString(@"Capacity2", @"")]
This produces, a message that looks something like this:
"Maximum capacity is 92% of design capacity."
(But localized to the user's language, of course.)
My question is... is there some way I could write this so that I only have one entry in my strings file (Capacity) instead of two (Capacity1 and Capacity2).
I'm thinking such a call might look something like:
Code:
[NSString stringWithFormat:@"%@", NSLocalizedString(@"Capacity", @""), [[device objectForKey:kDeviceDesignPercent] intValue]
And then inside of my strings file, I could include the %i. Why?
I feel like the code would look simpler and I'd have to explain less to my translator. Oh, it would also make modifying the message so that if I decide to change how many variables are in it easier.
So, any help would be greatly appreciated. Thanks!
Last edited: