Sto creando un'app per Mac e desidero localizzare le mie etichette. Ho pensato che un file .strings
sarebbe una scelta migliore. Ma ho problemi a leggere il file .strings
in Objective-C. Sto cercando un metodo più semplice.Leggi il file .strings in Objective-C?
Questo è il mio contenuto .string
del file:
"LABEL_001" = "Start MyApp";
"LABEL_002" = "Stop MyApp";
"LABEL_003" = "My AppFolder";
...
ho già guardato http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/LoadingResources/Strings/Strings.html.
Questo è il mio codice:
NSBundle *bundle = [NSBundle mainBundle];
NSString *strFilePath = [[NSBundle mainBundle] pathForResource:@"Labels" ofType:@"strings"];
NSString *tt =NSLocalizedStringFromTableInBundle(@"LABEL_001",strFilePath,bundle, nil);
NSLog(@"STRING ::: %@",tt);
Ma il TT stringa dà "LABEL_001"
, voglio "Start MyApp"
Che cosa sto facendo di sbagliato?
Hai guardato NSLocalizedString? – Luke