Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLocalizedString with format

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)]; 
like image 476
Peter Warbo Avatar asked Feb 20 '13 16:02

Peter Warbo


People also ask

What is nslocalizedstring in C++?

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.

What is nslocalized string in Swift?

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.

Is it safe to call nslocalizedstring in Xcode?

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.

Is nslocalizedstring thread safe?

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.


1 Answers

[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]; 
like image 119
Hot Licks Avatar answered Oct 04 '22 16:10

Hot Licks