Question

I am having UITabBar in my application.

The thing is that I am developing in language not being currently supported by Apple. The need is to localize some system elements which currently appear in English. One of them is button "More" on UITabBar.

Could anybody give me a hand how to do it? I have read that it is not possible to change that button title in simple way.

Big thanks for any help :)

Was it helpful?

Solution

There are a few things that you need to do.

  1. Localize the storyboard (eg: text on Buttons)
  2. Create a Localizable.strings for other custom strings not inside the storyboard
  3. Localize any UI Elements (eg: images) that contain text

You may follow the exact steps from this tutorial: http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014

For only button: enter image description here

If without Storyboard:-

I think your code will be like

[self.myButton setTitle:NSLocalizedString(@"More", nil) forState:UIControlStateNormal];

inside Localizable.strings for that language

 "More"="THE TRANSLATION";

Update:

Make a custom class for UITabBarController and add the following code in viewDidLoad

UITabBarItem * tabBarItem =  [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Yo", nil) image:[UIImage imageNamed:@"Image Name"] tag:0];
[[self.moreNavigationController.viewControllers objectAtIndex:0] setTabBarItem:tabBarItem];
[[self.moreNavigationController.viewControllers objectAtIndex:0] setTitle:NSLocalizedString(@"Yo", nil)];

Then you can just use Localizable.strings to localize the text. I purposely put "Yo" on the test project.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top