Question

I have Localizable.strings files for eng, span, port, rus, arab, chin.

A very strange issue started to happen, the key is showing up instead of the value. What makes it strange is that this is what caused it stop working:

I had:

self.title = NSLocalizedString(@"1OF5", @"");

In ViewControllerA, which worked fine. I then copy and pasted the line of code to ViewControllerB. Now the key '1OF5' is showing up instead of the value in the .strings file.

All the other NSLocalizedStrings work fine throughout the app (100+ of them), except this one >:|

I have tried:

  1. Deleting app and re-installing
  2. Restarting device
  3. Cleaning project and re-installing
  4. Restarting device, cleaning project, and re-installing
  5. Deleting the .strings file and adding it in again

I am pulling my hair out on this one. Any help would be much appreciated.

Was it helpful?

Solution

NSLocalizedString is a macro for -[NSBundle localizedStringForKey:value:table:], where table is nil. This all means that, through this macro, you look for your string in the resource file Localizable.strings located in your application's main bundle.

Ensure that the string referenced by the key "10F5" is located in a file called Localizable.strings inside your main bundle. If it is not in the main bundle, then you need to make use of the macro NSLocalizedStringFromTableInBundle instead.

One last thing: At the risk of raising a stupid point, make sure you're being consistent with your '0' or 'O'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top