I am developing my own framework using Xcode 4, and I'm using it in two sample apps (a console one, and a Mac OS X Cocoa application).
I'm trying to add localization to the framework, so I've created two versions of a Localizable.strings
file (en and fr versions), but every time I'm trying to print a localized string from the sample apps, I only get its technical name. For example, with the following line inside the framework's code:
NSLog(NSLocalizedString(@"LOC_TEST", nil));
I only get "LOC_TEST"
displayed in the output...
Localization works fine with the Cocoa app itself however (meaning the Cocoa app's localized strings are shown appropriately).
Following this article, I have tried to add localizations in the framework's plist file:
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>fr</string>
</array>
But it didn't change anything...
What am I missing?
The cause for not picking a right .strings file by framework is in NSLocalizedString
macro:
#define NSLocalizedString(key, comment) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
Framework's location of .strings file is not [NSBundle mainBundle]
as specified in macro.
From what I see, you'd need to use NSLocalizedStringFromTableInBundle
instead and specify your framework's bundle location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With