Localizable.strings failing to load every other build?

Viewed 6710

I have been having a strange problem with the localization system built into Cocoa. I used genstrings to create a localizable.strings file for my project, and the file loads and replaces the strings as expected in my app.

However, it appears to only work every other build. I will build the code with XCode, test it on my device, and it will display the correct strings no problem. The next build, however, will fail to load the strings file (At least, that's what I'm assuming.) This is not random, but predictably every other build. I am doing nothing fancy with the Localizable.strings file.

I have no idea where to even start in diagnosing this issue, and I was wondering if anyone had experience with doing localizations on Cocoa.

I am using NSLocalizedString throughout my code base like so:

NSLocalizedString(@"ReallyNewGame", @"Are you sure you want to start a new game?")

The corresponding entry in my Localizable.strings file:

/* Are you sure you want to start a new game? */
"ReallyNewGame" = "Do you really want to start a new game?";

Here are the relavent parts of my Info.plist:

<key>CFBundleDevelopmentRegion</key>
<string>English</string>

Here is a screenshot of what happens every other build of the app:

Correct: How it looks when correct

Incorrect: How it looks when incorrect

I am baffled as to why this happens. I do not do anything manually with the Localizable.strings file and I have cleaned my project several times on XCode. Any pointers in the right direction would be greatly appreciated. If you need any more information, I will attempt to provide it.

Thanks!

7 Answers

I just found something that was killing me! I had the same issue: Depending on the STRINGS file, sometimes it Works, some times doesn't/

What I found, is that if some line in your .strings file finishes with double semicolon

;;

all the lines below ware ignored!

For example: This works great: As you can see, the NSLocalizationString commands replaces correctly the strings at the template

Now, note the double semicolon

The upper image works great: As you can see, the NSLocalizationString commands replaces correctly the strings at the template But the other image shows that, before the double semicolon, it will ignore everything. It is a complete mess! No resources compilation error, nothing. Just a nightmare!

Hope it helps someone to don't get insomnia!

Related