I am having trouble debugging my NSLocalizedString implementation. It should be simple, but whatever I do, the function returns a KEY string.
I use Xcode 4.5 and iOS6, so I:
- A new file named
File.strings . - In the settings of my project, I added English and Spanish as the language settings.
- Click "Make Localized" in the file inspector and make sure that both English and Spanish are selected and that the target membership is selected for my purpose.
- Added
"KEY" = "TestEnglish"; in my english File.strings - Added
"KEY" = "TestSpanish"; in my spanish File.strings - Added
NSLog(@"Localization: %@\n", NSLocalizedString(@"KEY", nil)); into my .m file.
When I launch the application, the value "KEY" always displayed in NSLog format.
To get to this a bit more, I also tried this:
NSString *path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]; NSString *str = [[NSBundle bundleWithPath:path] localizedStringForKey:@"KEY" value:@"" table:nil]; NSLog(@"Localization: %@\n", str);
and still the value is "KEY ", but path is a valid path.
Does anyone know how to debug this? I feel like I read every question / answer, but none of the suggestions will help.
I understand that NSLocalizedString returns a KEY string when it cannot match the key, but I don't see how I can debug why my application might not match the KEY.
I also uninstalled / cleaned the application about a dozen times.
source share