For some reason I cannot get the Settings.bundle to recognize my additional languages. I must be missing something obvious, but I just cannot figure it out. Here's what I've got:
Project Structure in XCode:
Root.plist file:
Root.plist file http://img227.imageshack.us/img227/571/screenshot20100624at334.png
French Root.strings file
french Root.strings file http://img121.imageshack.us/img121/571/screenshot20100624at334.png
From everything I've read, I believe the project structure is right. The StringsTable in the Root.plist matches the name of the individual .strings files, and the Key for each item in the Root.plist has a match in the .strings files as well.
Why don't I see French text in my settings when I change the default iPhone language?
Thanks in advance!
For me, the problem was leaving off a semi-colon!
In localizable.strings, you get a runtime error if you omit the ";", but in Root.strings, you don't get any warnings, you can run it fine, but it just won't work!
So double-check to make sure you punctuate each key:value pair with a semi-colon!
I'll go ahead and answer my own question since I solved the problem myself through testing and failing. Hopefully this will help someone else in the future.
First, I think my Root.plist file may have been corrupted. I'm not exactly sure why, but I completely deleted the Settings.bundle, and re-created it to be sure.
Second, and perhaps most importantly, the main issue was the "key" in the root.strings file didn't match to the "key" field in the Root.plist, it actually matches the "Title" field.
Once I made those changes to the Root.strings file, it all started to work.
All you have to do is keep (or Add, if it's not there) "Strings Filename" in the Root.plist, after your settings.
Then, add Value "Root" (or, the name of your file and the translations) to make the created lang.lproj translations functional.
In my case, it appeared as if "Strings Filename" was set to "Root" in the Property List View of Root.plist, but when viewed the file in Source Code View, it was actually "StringsTable" pointing to "Root". The solution is to add another entry where "Strings Filename" points to "Root". (I also tried deleting the previous entry, but then it stops working, so you need both.)
In Xcode 5 there is still no obvious way to localize the Settings.bundle.
The problem
Xcode doesn't allow you to localize a file that is only shown because it is a file inside a folder that's directly shown in Xcode (hence the blue folder icons in the tree).
The Solution:
right-click the Root.strings file and select "Show in Finder"
List item
move the Root.strings file one folder up, so that the en.lproj folder is empty and the
Cmd-Drag the Root.strings file is next to the Root.plist.
delete the now empty en.lproj
go back to Xcode, notice that the tree will reflect the changes you now made
cmd-drag the file in the tree outside to outside the settings-bundle, so that it appears next to your source-code.
Do not copy the file
a dialog will appear asking you what to do with the file.
DO NOT select the checkbox to copy the file (you need this to be a reference)
DO NOT select a target to include the strings-file (the settings.bundle is already assigned to the correct target)
in the file inspector you can now choose to localize the file and to add languages to the localizations. The files will be placed correctly inside the settings.bundle and the tree will automatically reflect these changes, too.
After some repeated tries to activate localization,following steps worked for me:
Close xcode
Drag and duplicate the settings bundle onto the desktop (or wherever)
Open bundle contents
Drag Root.strings into
the en.lproj folder
Duplicate the en.lproj folder and rename to
whatever language you want (using 2-letter code ie fr.lproj)
Replace the original settings bundle with the new one(without
opening xcode).
Now Open xcode and the new files and folders
should be there
Now delete the older app and run xcode,Works fine in simulator and on device.
NOTE:Closing xcode,updating of duplicated setting bundle outside xcode and replacing updated back only will help.
Related
I have localized my Info.plist file, because I have to have different names for the app in different languages.
Since I did that, the project window shows this button: choose info.plist file.
If I click this button a window pops up with no choices. And worst than that, the project will not compile, giving an error error: could not read data from '/Users/user/Documents/myApp/Info.plist': The file “Info.plist” couldn’t be opened because there is no such file.
In fact the message is correct, because Xcode removed it from that location and added a copy of Info.plist to every localized directory (en.lproj, PT.lproj, etc.).
So... how do I fix this?
After fighting with Xcode, the only solution that works is this: http://useyourloaf.com/blog/2010/12/15/localize-iphone-application-name.html
You cannot localize Info.plist as I did. you have to create a strings file and localize that. Some magic links the the strings file to the info.plist.
I had a Localizable.strings file in my project for which I wanted to add more localizations.
So I went to the Project Settings and clicked the "+" to add languages. Somehow I cannot do that anymore on the right panel as there is no "+" button.
Xcode creates the cn.lproj folder inside the en.lproj folder in the file system which is messy but some other lproj folders such as de.lproj do get created where they belong.
How can I move an xx.lproj folder to where it belongs without breaking everything in Xcode? I am afraid leaving them where xcode is putting them can cause errors at run time because cn.lproj should not be a sub-folder of en.lproj.
As it turns out it's an Xcode bug, but fortunately it can be resolved.
First step is to backup your project. Then move the wrongfully placed lproj folders out of en.lproj and if you want, put all of them in a localized subfolder.
Then delete all the link-broken files (red) from the Project Navigator. For the stacked files that have an arrow you will have to delete the root item. Do not choose "Move to Trash". Then make sure in the Project Settings you have all the localizations you want. Drag the "localized" sobfolder containing all the lproj folders into Xcode wherever you want it to be, and make sure it gets added to the current target (Add to target checkmark must be checked in the list). In my case everything was functional as expected after doing this. And as a nice side effect I got rid of these annoying stacked files with the arrow and instead have a very clear group structure consisting of a localized and several lproj folders which makes much more sense to me.
The correct way to add a localization would be through your Project Info pane in Xcode.
It looks like this:
I would think trying to do it any other way might be asking for trouble (or hassle).
I think, you should have a folder en.lpoj for English.
Now if you click "+" and choose xx as language you should get another one named "xx.lpoj" nearby of the old one (on the same level so to say) and NOT inside the en.lproj.
So delete this wrong sub-folder and do it again ...
I'm trying to add an additional iPhone Settings File type to my Settings.Bundle and reference it in my Root.plist as a Child Pane type, but it isn't working. I've followed the documentation from Apple here, but it will not keep the plist file as an "iPhone Settings" type. I'm assuming that is why I can't drag it to my Settings.Bundle file either.
Basically, add a new plist by selecting File > Add New File...; select Resources under iOS, and then select plist type.
Now add some plist properties to the file.
Now right-click and choose "Property List Type" and select "iPhone Settings." You'll notice the keys in the file change. That's good. Save.
Now, click on another file to view that file and click back to the new settings file. Did it change back to the old property names and property type? It does for me, so it's staying as an iPhone Settings file type, and thus isn't working.
Anyone else have this problem? I'm wondering if it is an Xcode thing, or if it's a project preference/option/setting that I need to change.
One obvious thing that caused me to waste some time: kill the settings app after making changes.
It still doesn't save the settings type, but I got it working by copying the plist file into bundle from the command line. You can also right-click the "Settings.bundle" file and select "Show Package Contents" and copy the file in Finder.
I renamed my project.. and step by step I renamed all the targets, AppDelegate classes etc. Anyway it builds now but crashes as it can't find the .momd in the below code:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"MyApp" withExtension:#"momd"];
How do I get it to 'refresh' or build this momd file again? I have read various potential solutions involving adding a version on the .xdatamodeld file but heres the other thing.
When I click on the .xdatamodeld file it doesn't open up the editor anymore. It just does nothing. Right click bring me zero options.
I tried deleting the xdatamodeld file and creating a new one, but it has the same problem. When I press on it it doesn't open the editor.
When I create a brand new core data xcode project template, it does open the editor when I press on it. What am I doing wrong here?
I re-added the .xcdatamodeld file to my project and deleted the old reference. Works again now.
I'm still using Xcode 3, but when I double-click an .xdatamodeld file, it just opens the organizer. If I double-click an .xdatamodel file, it launches the project. This is probably because the xdatamodeld a folder, not a single file. It sounds like your problem is that the project file has lost its tracking to the mom you're using.
Here are some notes I made during past troubleshooting:
Troubleshooting dbase access — getting the right mom:
The first thing to suspect is that the managedObjectContext is not pointing to the correct data model (or managed object model, “mom”). (Actually, you are probably using the type:#“momd”, but it’s the target mom that’s been lost.)
In your app delegate, look for the accessor method managedObjectModel (created by Xcode when you stipulated Core Data store upon creating the project). Put a breakpoint in this method at the line that returns the mom.
Execute the program, and when it hits the breakpoint, go to the debugger model, and type “po” followed by the name of the mom variable being returned. (This is gdb’s “print object” command.)
What prints out will include “entities {” followed by a description of the entities in your data model. If nothing follows the brace, a blank mom is being returned — you’re not accessing the correct data model.
If clicking on the xcdatamodel in Xcode shows the full data model as expected, is it enclosed in an xcdatamodeld? That’s a sort of bundler/router/path file, and it may have lost its way. Do this:
- First, is the current xcdatamodel, the one with the green check icon, the first one? If not, drag it into first place, then test the app again.
- In Finder, make a copy of your xcdatamodel elsewhere for safekeeping.
- Get rid of the xcdatamodeld, in Finder and/or Xcode (I’m not sure which order I did this in). When done, it should not appear in Xcode.
- Drag the xcdatamodel (the one in the project folder) from the Finder to Xcode’s Groups & Files pane for the project, and choose the option that makes a copy for the project.
- Select the xcdatamodel, Design>DataModel>AddModelVersion. Now you should have a new xcdatamodeld file.
- Run the test again, doing the gdb print object command at breakpoint. Hopefully you’ll get a nice long printout, representing your data model.
- In future, avoid grouping the xcdatamodel/d files into a folder in Xcode. That seems to confuse things.
Examining the contents of the xcdatamodel/d files in Finder:
These are actually folders in disguise, as you will see if you remove their extensions. The guts of the data model is a plist, which you can open by double-clicking.
If you do this, test your app afterward and make sure it is still able to access your database. If not, follow the steps above.
I was in same situation, and finally fixed.
In my case, problem come from Xcode project group property: path.
Check path property of your project group that has xcdatamodeld file.
In my situation, it was different from xcdatamodeld file really exists,
and path of xcdatamodeld file was ../Model/XX.xcdatamodeld (example)
Anyway there were no problem, but someday I removed directory that is group's path property.
So Xcode couldn't find xcdatamodeld file. I add new xcdatamodled file, but this situation repeated.
Check if your xcdatamodeld file really exists in your project setting.
The solution for me was to revert back to a working copy of my .xcdatamodeld. Then, instead of renaming it via finder or the navigator pane of XCode 4, I selected the .xcdatamodeld file in the left navigation pane and edited the .xcdatamodeld's group name in the right pane of XCode 4 under the identity heading at the top.
Once I changed the name there to match my new project name, XCode automatically updated the name of the file on the file system for me.
I did not have to edit the path property as moon6pence suggested.
I have a project with two Info.plist files (one for each target). In the second Info.plist, when I add a field it shows the internal name instead of the English name. For example UISupportedInterfaceOrientations instead of "Supported Interface Orientations".
Also, when I click on the dropdown list to see all options, some of the options that are available in the first .plist file are not in the second (eg CFBundleIconFiles). The two problems are really the same thing (anything which shows the internal name does not appear in the dropdown).
The Bundle Verion is 1.1 in both files, the CFBundleInfoDictionaryVersion are both the same, as are the plist version and the DTD.
What's stopping the second plist from giving me these options? Thanks.
alt text http://img.skitch.com/20100708-ctia2e6yfwgd7twdnepryidayr.jpg
Xcode has a couple of different editors to show the contents of plist files. One of them is the generic plist editor, which shows the names of the keys without translation. The plist editor can also be in the specialized Info.plist mode, where it knows about the structure of this special type of plist file and translates keys to english.
I don't know how Xcode decides which editor to use, so the following is just guessing: I assume Xcode looks into the selected target to check the path to the Info.plist file and if it is the edited file, uses the specialized editor. So if you have one target selected, but open the other targets Info.plist it might use the generic editor instead.
Xcode also manages file types for each file in the project. You can override Xcode's automatic guesses by opening the file's settings (click on the file in the outline view and press command-I). Maybe there's a file type to identify Info.plist files.
As a last resort, you can always open the file by right clicking it in the outline view. In the context menu from "Open as ..." you can choose how to open it. I usually use "Source Code File" since I like to see the original XML.
Typically, there are times when not all options are shown. If you know it is supposed to exist, you can just add the key (via copy/paste) from the XML file of the other info.plist. I normally just open it up as XML and work in that mode (which gives non-English names).
All keys can be found here: http://developer.apple.com/iphone/library/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
In the latest XCode, it has been converting everything automatically to English names for me though even when I try to paste as a non-English name in the property list editor.
Short Answer
Select iPhone Info.plist from the View > Property List Type menu.
Explanation
This actually has nothing to do with the plist file itself. It's how Xcode (via the Property List Editor) presents the file.
You can test this by, in Finder, making a copy of a correctly-displaying plist file. Open the copy in the Property List Editor (usually the default application). The copy usually won't display the English names (until you change the Property List Type).
Xcode will remember the type you select and save it in the .xcodeproj file.