English 中文(简体)
本地化
原标题:Localization with %@

I am trying to localize the text "System Name:" in the code below:

NSString *systemName = [NSString stringWithFormat:@"System Name: %@", [[UIDevice
currentDevice] systemName];

I do this by changing the code to this:

NSString *systemName = NSLocalizedString(@"SystemNameKey", @"System Name Info");

In my Localizable.strings file, I add the following code:

"SystemNameKey" = "System Name: %@", [[UIDevice currentDevice] systemName];

Of course, this will not work because UIKit is not imported into the Localizable.stings, and not surprisingly, when I add the import code, it does not work. I am sure there is an alternate way of doing this that I m just not thinking of at the moment. Any ideas? I feel like I m missing something really obvious.

最佳回答

你们应当努力这样做:

NSString *systemNameLocalized = NSLocalizedString(@"SystemNameKey", @"System Name Info");
NSString *systemName = [NSString stringWithFormat:systemNameLocalized, [[UIDevice currentDevice] systemName]];

页: 1 档案:

"SystemNameKey" = "System Name: %@";
问题回答

暂无回答




相关问题
System.out.println and System.err.println out of order

My System.out.println() and System.err.println() calls aren t being printed to the console in the order I make them. public static void main(String[] args) { for (int i = 0; i < 5; i++) { ...

Groovyscript grails system commands

Is there a possibility of running my "grails run-app" command from my groovy script? I tried "cmd /c dir".execute() and it was working but "cmd /c grails run-app" doesn t seem to work :( Can anybody ...

Differences in code between Windows 32 bits and 64 bits

I was experimenting with the following code to simulate GetProcAddress. // Retrieve NT header from base address. IMAGE_NT_HEADERS *GetNtHeaderFromBase( void *pBaseAddr ) { IMAGE_DOS_HEADER *...

How to print bytes in hexadecimal using System.out.println?

I ve declared a byte array (I m using Java): byte test[] = new byte[3]; test[0] = 0x0A; test[1] = 0xFF; test[2] = 0x01; How could I print the different values stored in the array? If I use System....

热门标签