NSLocalization on xCode 4.5 and iOS 6

2019-06-27 00:06发布

Is there any way to use Localizable.strings with NSLocalizedString(@"KEY", @"") in xCode 4.5 for iOS6 like in older iOS5?

Here is my sample code:

In Localizable.strings
"KEY" = "Hello World!";

In .m script
NSString *tempString = NSLocalizedString(@"KEY", NULL);
NSLog(@"My String is: %@", tempString);

The log for iOS5.1 is: "My String is: Hello World!"
The log for iOS6 is: "My String is: KEY"

...I'm really going to become crazy! Where is my error? Thanks a lot!!!

6条回答
Melony?
2楼-- · 2019-06-27 00:13

Their is no need to create a new project and copy, just delete the localizable files, create it once again and you will be fine.

查看更多
Summer. ? 凉城
3楼-- · 2019-06-27 00:18

Change the language settings of simulator.

查看更多
smile是对你的礼貌
4楼-- · 2019-06-27 00:27

The localized strings in my current app still work in iO6. I typically just use NSLocalizedString(@"KEY", NULL); Are you sure yours is working properly for 5.1?

查看更多
beautiful°
5楼-- · 2019-06-27 00:27

The only solution I have found is:

  1. restart with a new project from xCode template
  2. enable Localization for at least 2 languages
  3. drag inside all old files from corrupted project
  4. copy the contend of old storyboards into new ones
  5. do frequent snapshots just in case of necessity

I really don't know where was the problem, but now all works again well as usual.

查看更多
Explosion°爆炸
6楼-- · 2019-06-27 00:28

Look at answer for post: IOS String Localization stops working when adding additional localization

It works for me. Clean build + remove from simulator (or phone) fix the error.

查看更多
乱世女痞
7楼-- · 2019-06-27 00:33

I was missing a semi-colon at the end of a line in one of my string-files. The compiler didn't report it even when I cleaned the project at built it again. First after restarting XCode the error was reported and I could find it and fix it.

查看更多
登录 后发表回答