Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to localize Settings.bundle in xcode4?

I am working on xcode4 and created a Settings.bundle for my project. I can edit the Root.plist file in xcode4 but it is not possible to edit the Root.strings file. It isn't even displayed in the editor.

enter image description here

I can not expand the en.lproj folder as you see in the picture.

But when I do right-click, open in external editor it gives me:

enter image description here

Double click on Root.strings gives me:

enter image description here

I tried it several times, creating a new window-based application project and creating a new Settings.bundle. I always can not localize it. Any ideas?

like image 741
UpCat Avatar asked Mar 22 '11 18:03

UpCat


3 Answers

In XCode 4.2 you have to follow this steps (just a modification of Xcode 3.2.2 and localization of Settings.bundle)

  1. Reveal your Settings.bundle in Finder.
  2. Right click (or Ctrl-click) on it and select Show Package contents.
  3. Create a new folder called as the desired language (e.g., fr.lproj).
  4. Copy the Root.strings file from the en.lproj folder and paste in fr.lproj folder.
like image 81
Javi Avatar answered Oct 28 '22 17:10

Javi


EDIT: Apple fixed, once again, the wrong bug. Their change rendered my workaround useless. It just doesn't work anymore, you can't add files to the Settings.bundle.

Please refer to the answer of Javi for a method that seems to work.


I hope you like ugly workarounds.

  1. Right click on the settings bundle in the side bar.
  2. Select New File
  3. Pick Resource / Strings file
  4. Name it Root.strings, make sure it is placed inside settings.bundle
  5. In the side bar the file will be visible twice. In the "root" section, and in the Settings.bundle. But both point to the same files.
  6. Select the Root.strings file in the root section. (AFAIR you have to convert it to UTF16)
  7. Add localization, xcode will ask you if you want to replace the file. Yes, you want this.
  8. Add as much localizations as you want. You should be able to edit the file in the root section of the sidebar.

I hope this works for you, for me it does.

And if you haven't done it please report the bug at bugreport.apple.com


I'll install the new release now, let's see if this is fixed. Edit: Not fixed.


EDIT: I don't know If I understood your second question correctly. But when you add a localization to the file that appears outside of the bundle it adds a localization folder to the settings.bundle

enter image description here

After adding spanish localization to Root.strings:

enter image description here

The actual file is in the foo.lproj folder, it just doesn't show them in the xcode sidebar. If you check the location in the file system you'll see they are inside the settings bundle. enter image description here

Yesterday I checked with a english and german file and it worked correctly in the simulator. I guess it's just a wrong sidebar layout. The underlying locations and the handling of the files seems correct.

like image 25
Matthias Bauch Avatar answered Oct 28 '22 16:10

Matthias Bauch


For me it worked to change the File Type (in the File Inspector) of the Folder "en.lproj" from "Default / Directory" to "Directory". Magic.

like image 31
dalind Avatar answered Oct 28 '22 16:10

dalind