1
votes

First of all,I did this follow this site http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014

I create a new Localizable.strings file,and localize it ,then add English and Japanese support.

I edit my Localizable.strings(en) file as follow:

"APPTITLE" = "Calibrate";

I edit my Localizable.strings(ja) file as follow:

"APPTITLE" = "こんにちわ";

At the source code,the early code : self.title = @"PianoDisc Calibrate"; instead of : self.title = NSLocalizedString(@"APPTITLE", nil);

Then I run it,But I get "APPTITLE" not "こんにちわ";

My environment is iPad mini,ios 8.1 system,Xcode 7 or 6.4. I'm also searched long time on the StackOverflow,like as NSLocalizedString only retrieves the key, not the value in Localizable.strings (IOS) ,I have tried the all answer,But it still not work. There are some info,I use follow code,

NSString *path = [[NSBundle mainBundle] pathForResource:@"ja" ofType:@"lproj"]; NSLog(@"!!!!!!!!!!!!!!!!%@",path);

sometimes get null,sometimes get the true path.

What I'm missing? Thanks anyway!

1
BTW:I use code to build UI,not use StoryBoard or xib file. I had created a tiny test project,It's worked.SilenceCrazy
Does it only not work for this particular string? If you only have one string localized so far, check if your localization files are added to the target you build.Daniil Korotin
How to do this? You mean ensure that localizable.strings file included by "Target -> Build Phases -> Copy Bundle Resources"? And like I mentioned, NSString *path = [[NSBundle mainBundle] pathForResource:@"ja" ofType:@"lproj"]; NSLog(@"!!!!!!!!!!!!!!!!%@",path); if this path get null,What should I do?SilenceCrazy
No,At this moment, I use NSString *path = [[NSBundle mainBundle] pathForResource:@"ja" ofType:@"lproj"]; NSLog(@"!!!!!!!!!!!!!!!!%@",path);can get active path. like this:/var/mobile/Containers/Bundle/Application/309429D6-826F-4D2A-8167-7AD357EB7343/PD Calibrate.app/en.lprojSilenceCrazy
Thanks anyway ,I resolved it. Some guy remind that "check you haven't somehow messed up with the Build Rules (Xcode 4 -> select your target -> tab "Build Rules") There, check if you don't have too many "CopyStringsFile" rules that aren't using "CopyStringsFile". If so you can remove them all but one." I have try ,It's work.SilenceCrazy

1 Answers

1
votes

I resolved it. Some guy remind that "check you haven't somehow messed up with the Build Rules (Xcode 4 -> select your target -> tab "Build Rules") There, check if you don't have too many "CopyStringsFile" rules that aren't using "CopyStringsFile". If so you can remove them all but one." This step just resolve my problem,thanks god.