How would I use NSLocalizedString
for this string:
[NSString stringWithFormat:@"Is “%@“ still correct for “%@“ tap “OK“ otherwise tap “Change“ to choose new contact details", individual.contactInfo, individual.name];
When using stringWithFormat before I've used it in the following manner:
[NSString stringWithFormat:@"%d %@", itemCount, NSLocalizedString(@"number of items", nil)];
NSLocalizedString is a Foundation macro that returns a localized version of a string. It has two arguments: key, which uniquely identifies the string to be localized, and comment, a string that is used to provide sufficient context for accurate translation.
NSLocalized String is a Foundation macro that returns a localized version of a string. It has two arguments: key, which uniquely identifies the string to be localized, and comment, a string that is used to provide sufficient context for accurate translation.
As such, you can safely call NSLocalizedString from any execution context. The values for key and comment must be string literal values. Xcode can read these values from source code to automatically create localization tables when exporting localizations, but it doesn’t resolve string variables.
For information about inserting plural nouns and units into localized strings, see Localizing Strings That Contain Plurals. As of OS X 10.11 and iOS 9, NSBundle is thread-safe. As such, you can safely call NSLocalizedString from any execution context.
[NSString stringWithFormat:NSLocalizedString(@"Is “%@“ still correct for “%@“ tap “OK“ otherwise tap “Change“ to choose new contact details", @"Query if parm 1 is still correct for parm 2"), individual.contactInfo, individual.name];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With