Erik B
Erik B

Reputation: 42554

How to make Cocoa understand that my iPhone app isn't in English?

I work on an iPhone app that is purely in Swedish and it will never be localized to any other languages. All the strings in the app is in Swedish, so we don't even have Localizable.strings.

The problem is that the strings generated by Cocoa (such as Done and Edit) are in English. I've tried setting Localization native development region in the Info.plist to Swedish, but that changed nothing. It shouldn't be harder than that to tell Cocoa that my app is in Swedish, but obviously it is.

I've also tried a bunch of other stuff without any luck. So what do I need to do to make Cocoa localize its strings to Swedish?

Upvotes: 5

Views: 907

Answers (3)

Carles Estevadeordal
Carles Estevadeordal

Reputation: 1229

The strings generated by Cocoa (such as Done and Edit) are in English because your iPhone language settings are set to English (in Settings -> General -> International -> Language ). If you set the language settings to Swedish you should see the texts in Swedish.

This is how the iPhone works by default, if you want to change the texts of some buttons to force them to Swedish you will have to create an outlet of them and change the text manually. For example like this UIBarButtonItem (with a default text Done (in english)):

UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneContact)] autorelease];
doneButton.title =@"Whatever";
self.navigationItem.rightBarButtonItem = doneButton;

I hope that this may help you...

Upvotes: 3

rydgaze
rydgaze

Reputation: 1060

you might have to do use extract all strings from the XIB and translate it (at least it is a one time process) and then reupdate the XIB. The following command line can help you do that.

ibtool --generate-strings-file out.strings yourWindow.xib

// Update the out.strings with your language translation

ibtool --strings-file out.strings yourWindow.xib --write yourWindow.xib

Upvotes: 0

prakash
prakash

Reputation: 59669

From the CFBundle documentation:

kCFBundleDevelopmentRegionKey The name of the development language of the bundle. When CFBundle looks for resources, the fallback is to look in the lproj whose name is given by the kCFBundleDevelopmentRegionKey in the Info.plist file. You must, therefore, ensure that a bundle contains an lproj with that exact name containing a copy of every localized resource, otherwise CFBundle cannot guarantee the fallback mechanism will work. Available in iOS 2.0 and later. Declared in CFBundle.h.

I would say: you should enable localizations, prepare swedish.lproj and remove English perhaps?

btw, Done & Edit shall automatically adjusted to currently active language. isn't it??

Upvotes: 0

Related Questions