tags:

views:

55

answers:

2

NSLog(@"Feature: %@, Cost: %f, ID: %@",[product localizedTitle], [[product price] doubleValue], [product productIdentifier]);

How to internationalize above statement with the following code:

NSLocalizedString(@"Feature", @""); NSLocalizedString(@"Cost", @"");

Its Urgent!

+1  A: 
NSLog(@"%@", [NSString stringWithFormat:NSLocalizedString(@"myKey",nil),[product localizedTitle], [[product price] doubleValue], [product productIdentifier]]);

In your Localizable.strings file:

"mykey" = "Feature: %@, Cost: %f, ID: %@";

Make sure you have an entry in each locale, including English.

TyB
Thanks TyB It worked for me :-)
Harsh
+1  A: 

For localizing price...

NSNumberFormatter *moneyFormatter = [[NSNumberFormatter alloc]init];    
[moneyFormatter setNumberStyle:kCFNumberFormatterCurrencyStyle];
[moneyFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];    
[moneyFormatter setLocale:product.priceLocale];

NSString *defaultString = [moneyFormatter stringFromNumber:product.price]];
[moneyFormatter release];

ProductIdentifier is unique and it is same for all languages, for strings use product.localizedTitle and product.localizedDescription properties.

Chandan Shetty SP
You have to use moneyFormatter because in US price is in "$" symbol and for other countries it is different.
Chandan Shetty SP
Hi Chandan thanks for giving your kind consideration. I will also need the answer u gave to me.
Harsh