5

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?

Erik B
  • 40,889
  • 25
  • 119
  • 135
  • http://stackoverflow.com/questions/4072349/non-english-default-language-for-ios-app .. If you read the solution I think can give you a pretty decent idea on how to handle the problem – ksn Aug 24 '11 at 12:11
  • @ksn That question is about language prioritization. Which isn't what I'm asking about. I still tried the answer and it didn't work. I don't even have an `English.lproj` directory. – Erik B Aug 24 '11 at 12:32
  • @ksn I had an `en.lproj` folder, but removing it didn't make a difference. – Erik B Aug 24 '11 at 13:18

3 Answers3

3

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...

  • 1
    I'm sorry, but this answer is incorrect. If you want an app purely in Swedish (or any other language), here's how to do it: http://stackoverflow.com/a/7204674/310121 – Erik B Dec 15 '11 at 18:49
  • The response is correct. You may want to try it before saying that it is incorrect. – Carles Estevadeordal Dec 15 '11 at 21:33
  • "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." Is incorrect. If you would try the response I linked you would know that this response is incorrect. – Erik B Dec 16 '11 at 22:48
  • I never said that your response was incorrect. But, as you said, by default the locale is set to english, and changing the text manually after the object is created does the trick too. Nevertheless, I will edit my response to include a link to your way, which in my opinion is a little bit more difficult to implement but, by far, more scalable. – Carles Estevadeordal Dec 19 '11 at 10:38
0

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??

prakash
  • 58,901
  • 25
  • 93
  • 115
  • It isn't, the phone is set to Swedish, but Done and Edit are still in English. Are you saying that adding an empty `Swedish.lproj` folder should do the trick? – Erik B Aug 24 '11 at 13:06
  • I copied `en.lproj` and renamed it to `sv.lproj`. I even tried removing `en.lproj` in the build phase, but no luck. Any suggestions? – Erik B Aug 24 '11 at 13:21
  • I deleted `en.lproj` from the project and now the build fails because it doesn't find `InfoPlist.strings` and `MainWindow.xib`. Why does it not look in `sv.lproj`? – Erik B Aug 24 '11 at 13:28
  • For adding swedish localization, you should use Xcode to create the desired localization. Renaming a copy wouldn't work. Supposing you use Xcode4, select the file and make sure utilities view (side bar on right side) is visible, and look for the section named Localization where you can add additional ones and remove English. This way, xcode knows what gets added and removed so the build won't fail. – prakash Aug 26 '11 at 19:56
0

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
rydgaze
  • 1,050
  • 13
  • 24