Forced localisation
saintjab opened this issue · comments
Hi, great library. Thanks for the good work. Is there a way to force the library to load a specific localised resource, like init and force to use a particular lproj strings? Thanks
Found the solution. I edited the + (NSBundle *)bundle method to handle it
- (NSBundle *)bundle {
static NSBundle *bundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *systemLanguage = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];//you can use conditional statement after here to load a specific bundle since you now have you language codes here (e.g. 'en' for English, 'zh-Hans' for Chinese (Simplified) etc)
NSURL *url = [[NSBundle mainBundle] URLForResource:@"SORelativeDateTransformer" withExtension:@"bundle"];
bundle = [[NSBundle alloc] initWithURL:url];
NSString *path = [bundle pathForResource:systemLanguage ofType:@"lproj"];
bundle = [NSBundle bundleWithPath:path];
});
return bundle;
}