iosobjective-clocalizationnslocalizedstringlocalizable.strings

App localization showing the key instead of the value in iOS


I've been using localization in my app, but for some reason, some of the strings (not all of them) won't translate, I see the key instead the value. I've tried to check if the app finds the localization files by doing this:

NSString *enPath = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];
NSString *hePath = [[NSBundle mainBundle] pathForResource:@"he" ofType:@"lproj"];
NSString *ruPath = [[NSBundle mainBundle] pathForResource:@"ru" ofType:@"lproj"];
NSString *esPath = [[NSBundle mainBundle] pathForResource:@"es" ofType:@"lproj"];
NSString *frPath = [[NSBundle mainBundle] pathForResource:@"fr" ofType:@"lproj"];
NSString *arPath = [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"];

And none of them is nil.

I've checked the name of the localization file and it's Localizable.strings as it should be. Also checked if the key exists inside the Localizable.strings files and it does.

I've also tried:

Also tried to do everything that is in this question.

It's important to say that this is not just a Simulator/Cache problem. It's also showing on devices which download the app. (I have Enterprise account).

What more can I do in order to identify nor fix the problem?


Solution

  • So I found the problem. In 4 places in my strings file there was a row as followed:

    "KEY" ;= "Value"
    

    This line cause some kind of a crash, but let the compiler to build successfully for some reason. That's why I couldn't find the bug, only when I decided to take the last Key and Value which are not translate and move them to the top of the Localizable.strings file. Then I was able to understand and see that the problem is somewhere in the middle of the file and the top Keys and Values are translated fine.