I want to use NSLocalizedString in my app but it always failed. What i do is:
Then I use NSLocalizedStrings as follow but it doesn't work!
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSString *v1 = NSLocalizedString(@"MyWindow", nil);
//NSString *v1 = [[NSBundle mainBundle] localizedStringForKey:(@"MyWindow") value:@"" table:nil];
[label setStringValue:v1];
}
In my 3 .strings files I define the below key/value: "MyWindow" = "Ma Fenetre";
Normally, my label should display "Ma Fenetre" and not "MyWindows" You can download an example project here and tell me where is the issue.
Bellow the content of Resources folder in my app bundle :
DerivedData om$ find test/Build/Products/Debug/test.app/Contents/Resources/
test/Build/Products/Debug/test.app/Contents/Resources/
test/Build/Products/Debug/test.app/Contents/Resources//de.lproj
test/Build/Products/Debug/test.app/Contents/Resources//de.lproj/File.strings
test/Build/Products/Debug/test.app/Contents/Resources//en.lproj
test/Build/Products/Debug/test.app/Contents/Resources//en.lproj/File.strings
test/Build/Products/Debug/test.app/Contents/Resources//fr.lproj
test/Build/Products/Debug/test.app/Contents/Resources//fr.lproj/File.strings
test/Build/Products/Debug/test.app/Contents/Resources//MainMenu.nib
Thanks Elfoiros
NSLocalizedString
uses Localizable.strings
file by default. Change your File.strings
name and try again.