iOS 5とストーリーボードの展開ターゲットを持つアプリの場合、ストーリーボード上の最初のViewControllerが次の場所にあるタブをローカライズするために次のようなものを使用しますUITabBarController
。
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// ...
if ([self.window.rootViewController isKindOfClass:UITabBarController.class]) {
UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController;
// Localize tab items
NSArray *tabBarItems = tabBarController.tabBar.items;
[tabBarItems enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(UITabBarItem *item, NSUInteger tabIndex, BOOL *stop) {
NSString *keyName = [NSString stringWithFormat:@"tabBarItem%i", tabIndex];
item.title = NSLocalizedString(keyName, @"TabBarItems");
}];
} else {
// The root view controller is not the UITTabBarController
}
// ...
}
そして私のファイルにこのようなものがありLocalizable.strings
ます:
// MARK: TabBar
"tabBarItem0" = "My First Tab Label";
"tabBarItem1" = "My Second Tab Label";
"tabBarItem2" = "My Third Tab Label";