I'm working on an app with multi-language support.
As you may expect, from time to time I load some nib files using a code like this:
self.currentController = [[newClass alloc] initWithNibName:@"CustomController" bundle:nil];
The app will then load the corresponding localized xib version from its languange folder.
Now, I am wondering if it is possible to load the localized nib file manually.
For example, instead of simply loading the CustomController, loading the english / french / german / etc. version of the CustomController.
Is there a way I can achieve this?
Thank you for your help in advance!
P.S. I know this may not be the proper way to change languages in an iphone/ipad app, but this is not my decision
[later edit]
This looks a bit weird and like a hack, but it seems to work (loading the german nib):
NSString* path= [[NSBundle mainBundle] pathForResource:@"de" ofType:@"lproj"];
NSBundle* languageBundle = [NSBundle bundleWithPath:path];
self.currentController = [[newClass alloc] initWithNibName:@"CustomController" bundle:languageBundle];
I found the tip here: http://learning-ios.blogspot.com/2011/04/advance-localization-in-ios-apps.html
It doesn't feel completely right though, I am wondering if there are other solutions too.
For starters, I have the feeling this will cause trouble with older versions of iOs, since the language folder had a different naming convention
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…