I'm having some trouble debugging my NSLocalizedString
implementation. Should be simple, but whatever I do, the function only returns the KEY
string.
I'm using XCode 4.5 and iOS6, so I:
- Added a new file called
File.strings
.
- In my project settings I added English and Spanish as language settings.
- Clicked "Make Localized" in the file inspector, and made sure that both English and Spanish options were selected, and also that the Target membership to my target was selected.
- Added
"KEY" = "TestEnglish";
to my english File.strings
- Added
"KEY" = "TestSpanish";
to my spanish File.strings
- Added
NSLog(@"Localization: %@\n", NSLocalizedString(@"KEY", nil));
to my .m
file.
When I run the app, the value "KEY"
is always displayed printed in the NSLog
.
To jump into this a bit more, I tried this as well:
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 "KEY
" is printed, yet, path
is a valid path.
Does anyone have any clue how to debug this? I feel like I've read every SO question/answer out there, but none of the suggestions help.
I realize that NSLocalizedString
returns the KEY
string when it cannot match a key, but I don't see how I can debug why my app might not be matching the KEY.
I've also deleted/cleaned the app about a dozen times.