iosobjective-ciphonexcodeios9.3

ios9 : NSLocalizedString inside framework


I had create a framework that send data to server. Whenever I get response from the server I translate it using NSLocalizedString but it not working.

I tried to change Main Bundle to my Framework Bundle like this :

NSString* mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString* frameworkBundlePath = [mainBundlePath stringByAppendingPathComponent:@"Frameworks/MYFRAMEWORK.framework"];
NSBundle *bundle = [NSBundle bundleWithPath:frameworkBundlePath];

[bundle localizedStringForKey:@"Message" value:@"" table:nil];

But still not working. is there any way to localized message when the Localizable.string is inside the framework ?

Thanks


Solution

  • Finally, I tried to recreate Localizable.string and whenever I want to localize I use this :

    NSString *message = [[NSBundle bundleForClass:self.class] localizedStringForKey:@"MESSAGE" value:nil table:nil];
    

    I put this code inside class of framework, so bundle of self.class is direct to framework bundle. Thank's for everybody help.