localization - ios i want localize by stringWithFormat -


i want localize stringwithformat this:

nsstring *string = [nsstring stringwithformat:@"login %d in",2013];     uialertview *alertview = [[uialertview alloc] initwithtitle:nslocalizedstring(@string, nil)                                                         message:@"message"                                                        delegate:nil                                               cancelbuttontitle:nil                                               otherbuttontitles:@"sure", nil];     [alertview show]; 

also write in localizable.string:

"login %d in" = "login %d in"; 

and doesn't work.can me?thank...

you have localize format string itself. doing else doesn't make sense because string can practically when it's formatted (that's purpose of format strings, after all). out of curiosity, haven't seen things like

"%d seconds remaining" = "%d secondes restants"; "hello, %@!" = "bonjour, %@ !"; 

in localizable.strings file of applications used yet?

nsstring *localizedfmt = nslocalizedstring(@"login %d in", nil); uialertview *av = [[uialertview alloc]     initwithtitle:[nsstring stringwithformat:localizedfmt, 2013],     // etc... ]; 

the security freak's notice: although the common , easiest approach localize formatted strings, it's not entirely safe.

an attacker can change localized format string in aforementioned localizable.strings file of app bogus, example, string contains more conversion specifiers stringwithformat: has arguments (or mismatching specifiers - treating integers pointers, anyone?), , stack smashing-based attack can carried out against application - beware of hackers.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -