在iOs中手动加载不同的本地化笔尖

我正在开发一个支持多语言的应用程序。 正如你所期望的那样,我不时地用这样的代码加载一些nib文件:

self.currentController = [[newClass alloc] initWithNibName:@"CustomController" bundle:nil]; 

该应用程序将从其languange文件夹中加载相应的本地化xib版本。 现在,我想知道是否可以手动加载本地化的nib文件。 例如,不是简单地加载CustomController,而是加载CustomController的english / french / german / 版本。

有什么办法可以做到这一点?

提前谢谢你的帮助!

PS我知道这可能不是在iphone / ipad应用程序中更改语言的正确方法,但这不是我的决定

[稍后编辑]这看起来有点奇怪,像一个黑客,但它似乎工作(加载德国的笔尖):

 NSString* path= [[NSBundle mainBundle] pathForResource:@"de" ofType:@"lproj"]; NSBundle* languageBundle = [NSBundle bundleWithPath:path]; self.currentController = [[newClass alloc] initWithNibName:@"CustomController" bundle:languageBundle]; 

我在这里find了提示: http : //learning-ios.blogspot.com/2011/04/advance-localization-in-ios-apps.html

不过感觉并不完全正确,我想知道是否还有其他解决scheme。 对于初学者来说,我觉得这会给老版本的iOs带来麻烦,因为language文件夹有不同的命名约定

所以,就像我在编辑中所说的那样,我发现这是一个解决scheme:

 NSString* path= [[NSBundle mainBundle] pathForResource:@"de" ofType:@"lproj"]; NSBundle* languageBundle = [NSBundle bundleWithPath:path]; self.currentController = [[newClass alloc] initWithNibName:@"CustomController" bundle:languageBundle]; 

如果你需要加载一个文本到本地化的标签

 NSString* path= [[NSBundle mainBundle] pathForResource:[[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0] ofType:@"lproj"]; NSBundle* languageBundle = [NSBundle bundleWithPath:path]; someLabel.text = [languageBundle localizedStringForKey:@"textKey" value:@"" table:nil]; 

更多信息在这里: http : //learning-ios.blogspot.com/2011/04/advance-localization-in-ios-apps.html

这个方法可能会引起很多问题。 对于初学者来说,可能会影响到每个人的东西:你需要让本地化的xib使用的所有资源都是本地化的。 如果我使用这种方法加载一个新的本地化的xib,并且xib包含一个常规的非本地化的图像,它将不会显示,直到它本地化。 其他问题更为特殊,并且与您检索本地化数据的方式有关。

最后,我不认为我会使用这个,因为对于目前的应用程序来说,这太麻烦了,但未来可能会变得方便。