tags:

views:

554

answers:

1

Hi:

we're developing an iphone application to be distributed in Spain. It contains a Tab bar, but we're not quite sure how to change More and Edit into Spanish. I'm sure there's a simple solution... anybody know a way to do it?

Thanks,

Antonio

==== Edit 1 ====

This is how we add the tabbar. As you see, we create a tabBarItem for each button, but the More button comes automatically when there are more than 5 (as should be expected).

for (int i = 0; i < [buttonNames count]; i++) {
   switch (i) {
      case 1:
         viewController = [[fotos alloc] init];
         break;
      case 2:
         viewController =[[videos alloc] init];
         break;
      case 3:
         viewController =[[deportes alloc] init];
         break;
      default:
         viewController = [[MyAppViewController alloc] initWithCategory:i strCategory:[tempNames objectAtIndex:i]];
         break;
   }

   UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
   UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:[buttonNames objectAtIndex:i] image:[UIImage imageNamed:[imgNames objectAtIndex:i]] tag:i];
   nav.tabBarItem = tabBarItem;
   [controllers addObject:nav];
   [viewController release];
   [nav release];
   [tabBarItem release];
}

// Create the toolbar and add the view controllers
tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:controllers animated:YES];
tabBarController.customizableViewControllers = controllers;
tabBarController.delegate = self;

// Set up the window
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

==== Solved ====

All I needed was a es.lproj directory in my project. I create a new file in XCode (File > New File... > Mac OS X / Other > Strings File), I name it Localizable.strings and save it in es.lproj. Any strings that need to be localized need to be defined in this file (see Localizing iPhone Apps - Internationalization), but all other strings generated by the OS (the More, Edit and Done buttons in the tabBar, video controls, etc.) will be automatically translated.

+2  A: 

If you are using the built in defined types it should automagically work. If they are your own text, you'll need to be using NSLocalizedString from the code, run genstrings from Terminal, and then provide a Spanish lproj inside your bundle.

slf
Hi, thanks for your answer. That's what I thought, but for some reason all those labels are in English, even though my iphone is configured in Spanish. How can I tell if we're using a "built in defined type"? See my edit, it might help! thanks!
Antonio
You aren't using the predefined types from interface builder because you are overriding the values with your `buttonnames` array. Check this out: http://www.stone.com/The_Cocoa_Files/Internationalize_Your_App.html It's a bit outdated but it still applies.
slf
hmm, actually, I'm not using IB at all... all the sections are created programmatically, but the More button doesn't change to its Spanish equivalent, even though I get Current Locale: es_ES. I've noticed that when I load a video with MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:urlAddress]];all the controls are in English...Any ideas?thanks
Antonio
From your comment I can't tell if you are testing on the device or the simulator. I've had a few problems switching locale on the simulator, but it worked fine on the device. Make sure you are testing with a device.
slf
If you are testing with a device, anything in YOUR code needs to be localized by using NSLocolizedString and there MUST be an es_ES value defined by you in an lproj
slf
hello again, and thanks for your help. This issue is when I compile for device (I still haven't tried changing locale on the simulator). Ok, say I have all strings localized via the Localizable.strings in en.lproj and es.lproj. When I do, I understand how all the sections in the tabbar get translated to Spanish, but the More and Edit buttons, as well as the video controls (Done, Loading Movie..., etc.) appear automatically, so I don't know what the key/value pairs would be for these. I've created the above files and dirs, but still those words appear in English...
Antonio
however, if I do this:NSArray *languages = [defaults objectForKey:@"AppleLanguages"];NSString *currentLanguage = [languages objectAtIndex:0];I get "en". Hmmm, wouldn't this be the preferred language ??
Antonio
Ok, DONE!! Thanks for your help, it was much simpler than I expected :). I'll edit my question to post the solution.
Antonio