0

App is written in Objective-c, but it also needs some c files. And the c files contain some strings need to be localized. Such as:

sprintf("%dx%d, %d balls", w, h, ballCount);
printf("Hello");

Usually Objective-c can get localized string like this:

NSString* text = [NSString stringWithFormat: NSLocalizedString(@"%dx%d, %d balls",@""), w, h, ballCount];
NSString* text2 = NSLocalizedString(@"Hello",@"");

Localizable.strings

"%dx%d, %d balls" = "%dx%d, %d couilles";
"Hello" = "Bonjour";

Can c file read localized string files like Objective-c?

jdleung
  • 1,088
  • 2
  • 10
  • 26
  • 1
    Not entirely sure what you're asking. There are a number of ways to separate out localized strings. Look here for one method: https://stackoverflow.com/questions/403747/bests-practices-for-localized-texts-in-c-cross-platform-applications – torstenvl Dec 12 '19 at 07:00
  • It's all about the parsing since it's a simple text file. – Larme Dec 12 '19 at 09:13
  • @torstenvl sorry, cannot find a solution from the reference. – jdleung Dec 12 '19 at 14:37
  • @Larme localized string is stored in file `Localizable.strings`, how can parse it? Can give a sample code? Thanks. – jdleung Dec 12 '19 at 14:40
  • @jdleung, the link provides a clear answer for achieving what you want to do. If your question is "how can I parse an objective C localizable.strings file?" then nobody can help you unless you explain the file format and show your first attempts. – torstenvl Dec 13 '19 at 13:12

0 Answers0