Localization strings do not always work with ShareKit in a project

since I removed some localizations from my application, I have this problem: when I first load my application, I see a localized string of my key in the shortcut. The second time I download the application, xxxxxkey appears. The next time I download the application, everything will be fine (showing a localized string). How can it be?

I would be glad if someone could point me in the right direction. I am on Xcode 4.2.

Thanks in advance!

+1
source share
1 answer

I also experienced this after adding the ShareKit library to my project. As it turned out, the problem was that ShareKit had a localizable.strings file and that my own project included a file with the same name. I'm not sure why, but when you started the application, both of these two localizable characters were matched, not both. If you rename the localizable.strings file so that there is no conflicting file name, the problem should go away.

If you rename the localizable.strings file, you need to update the code that loads the lines from that particular string file using the NSLocalizedStringFromTable macro instead of NSLocalizedString. For example, I renamed ShareKit localizable.strings to ShareKit.strings and edited the first line of this method as follows:

NSString* SHKLocalizedString(NSString* key, ...) { // Localize the format // Was: // NSString *localizedStringFormat = NSLocalizedString(key, key); NSString *localizedStringFormat = NSLocalizedStringFromTable(key, @"ShareKit", key); va_list args; va_start(args, key); NSString *string = [[[NSString alloc] initWithFormat:localizedStringFormat arguments:args] autorelease]; va_end(args); return string; } 
+5
source

All Articles