3
votes

I use SORelativeDateTransformer in my project.

I localized my project (translated storyboard and created Localizable.strings(I used NSLocalizedString)) and that part translates perfect.

The problem is that SORelativeDateTransformer uses it's own SORelativeDateTransformer.strings(uses NSLocalizedStringFromTable), which works in demo, but not in my project.

Upd.: Found also that some labels, that I translated to Norwegian localization keep English words. Oughh!

Any ideas?

1
Did you ever found a solution for this?saintjab
Thanks for getting back to me. Any other library that you are using now which I can use instead?saintjab
@saintjab Sorry for not being helpful. No, as I remember I just copied strings from SORelativeDateTransformer.strings to Localizable.strings and replaced all NSLocalizedStringFromTable calls in that project with NSLocalizedString.Shmidt
I have just posted an update as answer based on how I did it. Thanks for your help.saintjab

1 Answers

1
votes

I know this question is quite old but here is a solution I used. There is a way to force SORelativeDateTransformer to load a particular Localisation string base on your preference. If you did manual installation instead of using pod then you can edit the .m base on your preference. For instance this is how I am implementing it in the + (NSBundle*) bundle method

+ (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;
}

This should do the trick.